Oracle Context Option QuickStart Go to Product Documentation Library
Library
Go to books for this product
Product
Go to Contents for this book
Contents



Go to previous file in sequence Go to next file in sequence

CHAPTER 3. Using Theme Queries and the Linguistic Services


This chapter provides a quick description of the tasks that must be performed to enable theme queries with Oracle ConText Option, as well as to generate linguistic output for use in an application. It also provides examples of theme queries and queries using linguistic output.

Note: Theme queries and the Linguistic Services are only available for English-language text.

The following topics are covered in this chapter:

Attention: Before you can perform the QuickStart tasks described in this chapter, ConText Option must be installed and certain implementation tasks must be completed. If the required installation and installation tasks have not been completed, see "Implementing ConText Option (Chapter 4)."

Theme Query and Linguistic Services Task Map

QuickStart Tasks

Perform the following tasks to set up a text column in a table, index the column, and perform theme queries on the column, as well as generate linguistic output for the column:

Startup and Hot Upgrade

The first two setup tasks for theme queries and the Linguistic Services are:

These tasks can be performed in any order.

Start ConText Servers

Similar to text indexing and queries, theme indexing is performed by ConText servers with the DDL (D) personality and theme queries are processed by ConText servers with the Query (Q) personality.

However, to enable a ConText server to generate linguistic output through the Linguistic Services, the Linguistic (L) personality must be specified for the server.

The following command starts a ConText server with the appropriate personalities for creating a theme index, performing theme queries, and generating linguistic output:

	$ ctxsrv -user ctxsys/ctxsys -personality DQL -log ctx.log &

Attention: If you are going to generate theme indexes, perform theme queries, or make requests for the Linguistic Services, do not use the ctxsrvx executable to start ConText server processes.

Suggestion: Once linguistic output has been generated for a column, if the text in the column is not going to change, you can shut down ConText servers with the Linguistic personality or remove the Linguistic personality from the the personality mask for the server.

Additional Information:
Oracle ConText Option Administrator's Guide

Perform Hot Upgrade of Columns

The procedure for upgrading a column for theme indexing is the same as the procedure for text indexing, except that the lexer used in the policy for theme indexing is not the same as the lexer (BASIC LEXER) used in the text indexing policy.

To create a theme indexing policy, the Theme Lexer is specified for the policy, using the predefined Lexer preference, THEME_LEXER.

The following example illustrates using a PL/SQL block to create a column policy for theme indexing:

    begin
    ctx_ddl.create_policy('ctx_thidx',
                          'ctxdev.docs.text'
                          lexer_pref => 'THEME_LEXER');
    end;

Note that the only difference between the theme indexing policy and the text indexing policy created in the previous chapter, besides the names of the policies, is the specification of THEME_LEXER as the Lexer preference for the theme indexing policy.

In addition, note that the table and column name for both policies are the same, which results in the column having two policies and, subsequently, two indexes: one for text queries and one for theme queries.

Additional Information:
Oracle ConText Option Administrator's Guide

Theme Queries

Similar to text queries, before you can perform a theme query, you must first create a theme index for the text column you want to query.

In addition, if you want to perform two-step queries, you must create a result table which is used to store the results of the query.

Once these tasks have been performed, you can perform theme queries for your documents. The returned documents have a score which indicates the relevance of the themes in the document to the themes in the query.

Create Theme Indexes for Text Columns

To create a theme index for a column, call the CREATE_INDEX stored procedure from the CTX_DDL PL/SQL package and specify the theme indexing policy for the column.

For example:

	exec ctx_ddl.create_index('ctx_thidx')

In this example, CREATE_INDEX is called in SQL*Plus to create a theme index for the text column (CTXDEV.DOCS.TEXT) in the CTX_THIDX policy.

After a theme index is created for a column, ConText servers with the Query personality can process theme queries for the column.

Additional Information:
Oracle ConText Option Administrator's Guide

Create Result Tables (Two-Step Queries Only)

The structure of the result table for a theme query and the method for creating the table is identical to the result table used in a text query. In fact, you can use the same result table or you can create a different result table for two-step theme queries.

The theme query examples in the theme query task map (Figure 3 - 1) assume that a separate result table is used for storing the results from two-step theme queries.

Theme Query Examples

The theme query task map (Figure 3 - 1) illustrates how to perform theme queries using all three of the supported query methods. In the examples, the theme Oracle is queried.

The three methods for performing queries are identical for both text and theme queries, with the exception that theme queries are case-sensitive.

Case-Sensitivity

Unlike text queries, theme queries are case-sensitive. Theme queries for places and names will return different results than theme queries for the same words or phrases expressed as common nouns.

For example, a query for the term Oracle will produce those documents in which ConText Option determined Oracle Corporation (the expansion of Oracle) to be a major topic or theme. In contrast, a text query for the term Oracle will return all documents that contain occurrences of the terms Oracle and oracle, regardless of how the term is used in the document.

Columns with Multiple Indexes

If a column has two or more indexes, which is common with text indexes and theme indexes, it is necessary to specify the name of the policy for the appropriate index as an argument in the CONTAINS function of a one-step query.

For example, if the QuickStart tasks for both text and theme queries have been performed, the column CTXDEV.DOCS.TEXT will have both a text index (CTX_DOCS policy) and a theme index (CTX_THIDX policy).

The theme query task map (Figure 3 - 1) illustrates how the CTX_THIDX policy is named in a one-step query to identify the index to be searched.

Additional Information:
Oracle ConText Option Application Developer's Guide

Linguistic Services

The setup tasks required for using the Linguistic Services to generate output for a document are:

Once these tasks have been performed, you can query the output tables for themes and Gists.

Create Linguistic Output Tables

The Linguistic Services generate two types of output for a document:

The output is stored in tables specified by the user when requesting the Linguistic Services. The linguistic output tables can have any name; however, they must have the following structure:

	create table ctx_themes (cid number, pk varchar2(64),
	theme varchar2(256), weight number);
	create table ctx_gist (cid number, pk varchar2(64),
	pov varchar2(256), gist long);

In these examples, two tables (CTX_THEMES and CTX_GIST) are created in SQL*Plus for storing linguistic output. The PK column in each table stores primary keys (textkeys) for each document. The CID column in each table stores policy IDs.

Note: The output from the Linguistic Services may require modification before it can be used in an application. As such, the output tables usually serve only to temporarily store the output until the output can be modified and moved to an application table.

Additional Information:
Oracle7 Server SQL Reference,
Oracle ConText Option Application Developer's Guide

Generate Linguistic Output for Text Columns

To request linguistic output for a document, call the REQUEST_THEMES and/or REQUEST_GIST procedures in the CTX_LING PL/SQL package. Then call the SUBMIT function in CTX_LING to submit the requests to the Services Queue.

The requests in the Services Queue are picked up and processed by the first available ConText servers with the Linguistic personality.

Note: REQUEST_THEMES and REQUEST_GIST must be called once for each document for which you want to generate the respective type of linguistic output.

After linguistic output is generated, you can query for lists of themes in documents and use Gists to view summarized versions of documents.

Attention: When calling REQUEST_THEMES and REQUEST_GIST, you must specify a policy name. The specified policy can can be either a text indexing policy or a theme indexing policy; however, if you are generating both themes and Gists for a document, you should use the same policy.

For example:

	exec ctx_ling.request_themes('ctx_thidx',1,'ctx_themes')
	exec ctx_ling.request_gist('ctx_thidx',1,'ctx_gist')
	variable handle number
	exec :handle := ctx_ling.submit
	print handle

In this example, theme and Gist output are requested for a document with PK=1 in the text column for the CTX_THIDX theme indexing policy. The PK value corresponds to the primary key for the document. The CTX_THEMES and CTX_GISTS tables are specified as the output tables.

Then, the SUBMIT function is called. SUBMIT submits the two separate requests as a single batch request to the Services Queue and returns a handle for the request.

Note: In this example, the CTX_THIDX policy is used to call REQUEST_THEMES and REQUEST_GIST; however, you could also use the CTX_DOCS text indexing policy to generate the same results.

Additional Information:
Oracle ConText Option Application Developer's Guide

Example Queries for Linguistic Output

The theme and Gist information is stored as structured data in the linguistic output tables and can be used to obtain a specialized view of a document.

For example, you may want to display the themes for all the documents in a column or for a single document. You may also want to display the point-of-view (POV) Gist for all documents with a specific theme or the generic Gist for a specific document.

Attention: The Linguistic personality is required only for generating linguistic output for documents. Because linguistic queries are essentially structured data queries, neither the Linguistic nor the Query personalities are required for querying the linguistic output tables.

Because linguistic information is stored in tables separate from the base text table, you probably will want to join the text table and the linguistic output tables to return detailed information for the document hits.

The following examples illustrate queries for themes and Gists:

	select theme, weight, title from ctx_themes, docs,
 	where docs.author='Smith'
 	and ctx_themes.pk=docs.pk
	order by weight desc;
	select title, gist from ctx_gist, docs
	where ctx_gist.pk=docs.pk
	and pov = 'computer software industry';

In the first example, the query returns the theme, weight, and title for each document in DOCS that has Smith as the author.

In the second example, the query returns the title and POV Gist for each document that has computer software industry as one of its points-of-view (themes) in the CTX_GIST table.

Attention: ConText Option stores themes/POVs as plural nouns or noun phrases. When you perform queries using linguistic output, the query phrase must be entered exactly as it is stored in the output table or the query will likely return no results. A list of available words or phrases to query can be obtained by selecting all unique themes from the themes/Gist output table.

Additional Information:
Oracle ConText Option Application Developer's Guide




Go to previous file in sequence Go to next file in sequence
Prev Next
Oracle
Copyright © 1996 Oracle Corporation.
All Rights Reserved.
Go to Product Documentation Library
Library
Go to books for this product
Product
Go to Contents for this book
Contents