GIST
Use the CTX_DOC.GIST procedure to generate gist and theme summaries for a document. You can generate paragraph-level or sentence-level gists or theme summaries.
Syntax 1: In-Memory Storage
CTX_DOC.GIST(
index_name IN VARCHAR2,
textkey IN VARCHAR2,
restab IN OUT CLOB,
glevel IN VARCHAR2 DEFAULT 'P',
pov IN VARCHAR2 DEFAULT 'GENERIC',
numParagraphs IN NUMBER DEFAULT 16,
maxPercent IN NUMBER DEFAULT 10,
num_themes IN NUMBER DEFAULT 50,
use_saved_copy IN NUMBER DEFAULT CTX_DOC.SAVE_COPY_FALLBACK);
Syntax 2: Result Table Storage
CTX_DOC.GIST(
index_name IN VARCHAR2,
textkey IN VARCHAR2,
restab IN VARCHAR2,
query_id IN NUMBER DEFAULT 0,
glevel IN VARCHAR2 DEFAULT 'P',
pov IN VARCHAR2 DEFAULT NULL,
numParagraphs IN NUMBER DEFAULT 16,
maxPercent IN NUMBER DEFAULT 10,
num_themes IN NUMBER DEFAULT 50,
use_saved_copy IN NUMBER DEFAULT CTX_DOC.SAVE_COPY_FALLBACK);
index_name
Specify the name of the index associated with the text column containing the document identified by textkey.
textkey
Specify the unique identifier (usually the primary key) for the document.
The textkey parameter can be as follows:
-
a single column primary key value
-
an encoded specification for a composite (multiple column) primary key. To encode a composite textkey, use the
CTX_DOC.PKENCODEprocedure -
the rowid of the row containing the document
Toggle between primary key and rowid identification using CTX_DOC.SET_KEY_TYPE.
restab
Specify that this procedure store the gist and theme summaries to either a table or to an in-memory CLOB.
To store results to a table specify the name of an existing table.
See Also: “Gist Table” in Oracle Text Result Tables
To store results in memory, specify the name of the CLOB locator. If restab is NULL, then a temporary CLOB is allocated and returned. You must de-allocate the locator after using it.
If restab is not NULL, then the CLOB is truncated before the operation.
query_id
Specify an identifier to use to identify the row(s) inserted into restab.
glevel
Specify the type of gist or theme summary to produce. The possible values are:
-
P for paragraph
-
S for sentence
The default is P.
pov
Specify whether a gist or a single theme summary is generated. The type of gist or theme summary generated (sentence-level or paragraph-level) depends on the value specified for glevel.
To generate a gist for the entire document, specify a value of ‘GENERIC’ for pov. To generate a theme summary for a single theme in a document, specify the theme as the value for pov.
When using result table storage, if you do not specify a value for pov, then this procedure returns the generic gist plus up to 50 theme summaries for the document.
When using in-memory result storage to a CLOB, you must specify a pov. However, if you do not specify a pov, then this procedure generates only a generic gist for the document.
Note:
The pov parameter is case sensitive. To return a gist for a document, specify ‘GENERIC’ in all uppercase. To return a theme summary, specify the theme exactly as it is generated for the document.
Only the themes generated by THEMES for a document can be used as input for pov.
numParagraphs
Specify the maximum number of document paragraphs (or sentences) selected for the document gist or theme summaries. The default is 16.
Note:
The numParagraphs parameter is used only when this parameter yields a smaller gist or theme summary size than the gist or theme summary size yielded by the maxPercent parameter.
This means that the system always returns the smallest size gist or theme summary.
maxPercent
Specify the maximum number of document paragraphs (or sentences) selected for the document gist or theme summaries as a percentage of the total paragraphs (or sentences) in the document. The default is 10.
Note:
The maxPercent parameter is used only when this parameter yields a smaller gist or theme summary size than the gist or theme summary size yielded by the numParagraphs parameter.
This means that the system always returns the smallest size gist or theme summary.
num_themes
Specify the number of theme summaries to produce when you do not specify a value for pov. For example, if you specify 10, this procedure returns the top 10 theme summaries. The default is 50.
If you specify 0 or NULL, then this procedure returns all themes in a document. If the document contains more than 50 themes, only the top 50 themes show conceptual hierarchy.
use_saved_copy
Specify whether to refer to the $D table to fetch the copy of the document, and what action to take when the copy of the document is not available in the $D table.
You can specify one of the following values for the use_saved_copy parameter:
-
CTX_DOC.SAVE_COPY_FALLBACK: Fetch the copy of the document from the $D table. If the copy of the document is not present in the $D table, then fetch the document from the data store. -
CTX_DOC.SAVE_COPY_ERROR: Fetch the copy of the document from the $D table. If the copy of the document is not present in the $D table, then show an error message. Specify this value when you want to implement a specific fallback logic when the copy of the document is not available in the $D table. -
CTX_DOC.SAVE_COPY_IGNORE: Always fetch the document from the data store.
The default value is CTX_DOC.SAVE_COPY_FALLBACK.
Examples
In-Memory Gist
The following example generates a non-default size generic gist of at most 10 paragraphs. The result is stored in memory in a CLOB locator. The code then de-allocates the returned CLOB locator after using it.
set serveroutput on;
declare
gklob clob;
amt number := 40;
line varchar2(80);
begin
ctx_doc.gist('newsindex','34',gklob, pov => 'GENERIC',numParagraphs => 10);
-- gklob is NULL when passed-in, so ctx-doc.gist will allocate a temporary
-- CLOB for us and place the results there.
dbms_lob.read(gklob, amt, 1, line);
dbms_output.put_line('FIRST 40 CHARS ARE:'||line);
-- have to de-allocate the temp lob
dbms_lob.freetemporary(gklob);
end;
Result Table Gists
The following example creates a gist table called CTX_GIST:
create table CTX_GIST (query_id number,
pov varchar2(80),
gist CLOB);
The following example returns a default sized paragraph-level gist for document 34 as well as the top 10 theme summaries in the document:
begin
ctx_doc.gist('newsindex','34','CTX_GIST', 1, num_themes=>10);
end;
The following example generates a non-default size gist of at most 10 paragraphs:
begin
ctx_doc.gist('newsindex','34','CTX_GIST',1,pov =>'GENERIC',numParagraphs=>10);
end;
The following example generates a gist whose number of paragraphs is at most 10 percent of the total paragraphs in document:
begin
ctx_doc.gist('newsindex','34','CTX_GIST',1,pov => 'GENERIC', maxPercent => 10);
end;
Theme Summary
The following example returns a paragraph-level theme summary for insects for document 34. The default theme summary size is returned.
begin
ctx_doc.gist('newsindex','34','CTX_GIST',1, pov => 'insects');
end;