Oracle Context Option Application Developer's Guide Go to Product Documentation Library
Library
Go to books for this product
Product
Go to Contents for this book
Contents
Go to Index
Index



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

CHAPTER 8. SQL*Plus Sample Code


This chapter describes the sample SQL*Plus scripts provided by ConText Option. The scripts illustrate how to use SQL*Plus to build simple queries and generate linguistic output using the Linguistic Services.

The scripts are divided into two functional areas: CTXPLUS (performing ad-hoc queries) and CTXLING (generating linguistic output).

The following topics are covered in this chapter:

Overview of CTXPLUS

The CTXPLUS sample code consists of the following SQL scripts:

Script Description
query1.sql Performs a one-step query using the input query expression and returns a hitlist, sorted by score, to the standard output.
query2.sql Performs a two-step query using the input query expression and returns a hitlist, sorted by score, to the standard output.
queryc.sql Performs an in-memory query using the input query expression and returns an unsorted hitlist to standard output
querys.sql Performs an in-memory query using the input query expression and returns a hitlist, sorted by score, to the standard output.
storeqry.sql Performs a query and stores the results as a system SQE. The results of the SQE can then be used in a query (one-step, two-step, or in-memory).
showsqe.sql Returns a list of all the system SQEs that have been stored for a policy
NOTE: This script is not currently implemented.
view.sql Selects a document based on the input textkey and returns the text of the document to the standard output.
Table 8 - 1. CTXPLUS SQL*Plus Scripts



For more information about the location of the scripts, see the Oracle7 Server installation documentation specifc to your operating system.

Concepts

The ConText Option concepts illustrated in this sample code are:

Setup

The CTXPLUS sample SQL*Plus scripts use the ARTICLES table and the DEMO_POLICY policy, as well as other demonstration objects.

Before the scripts can be used, all the required demonstration objects must be created in the database. Installation scripts are provided with ConText Option for creating the required demonstration objects.

For more information about running the demonstration installation scripts, see the Oracle7 Server installation documentation specifc to your operating system.

Using CTXPLUS

To use the CTXPLUS sample SQL scripts:

		@query1
		Enter value for query_terms: coffee|tea

		@view 14

		@storeqry
		Enter query name: test_sqe
		Enter value for query_terms: coffee|tea
Note: The script does not return the results of the query to the standard output.

		select pol_name, query_name, query_name
		from ctx_user_sqes;

CTXPLUS Examples

The following examples execute the query1.sql, query2.sql, and querys.sql scripts using the query terms California and politics and various logical operators (OR, ACCUMULATE, and AND).

These examples illustrate how one-step, two-step, and (sorted) in-memory queries produce the same results and how the operators in a query expression affect the rows and scores returned by a query:

Single Term Queries

     @query2
     Enter value for query_terms: California
     SCR  ID AUTHOR          TITLE
     ---- -- --------------- ----------------------------
     100  17 Nolo Richards   REVIEW & OUTLOOK (Editorial):
                             California Smashup
      50  18 Nolo Richards   State Farm and California
      30  25 David Shribman  In the Wilderness: Democrats'
                             Troubles In Winning
      20  49 Nolo Richards   California High Court Is
                             Asked to Lift Block Of In
      10  16 Heidi Waleson   LEISURE & ARTS: Cynthia
                             Phelps: Violist in Vogue 
     @query1
     Enter value for query_terms: politics
     SCR  ID AUTHOR          TITLE
     ---- -- --------------- ----------------------------
     20   25 David Shribman  In the Wilderness: Democrats'
                             Troubles In Winning
     10   13 Frederick C. Kl LEISURE & ARTS -- Sports:
                             Mediocrity's the Word Ar

Multiple Term Query Using OR

     @querys
     Enter value for query_terms: politics|California
     SCR  ID AUTHOR          TITLE
     ---- -- --------------- ----------------------------
     100  17 Nolo Richards   REVIEW & OUTLOOK (Editorial):
                             California Smashup
     50   18 Nolo Richards   State Farm and California
     30   25 David Shribman  In the Wilderness: Democrats'
                             Troubles In Winning
     20   49 Nolo Richards   California High Court Is Asked
                             to Lift Block Of In
     10   13 Frederick C. Kl LEISURE & ARTS -- Sports:
                             Mediocrity's the Word Ar
     10   16 Heidi Waleson   LEISURE & ARTS: Cynthia
                             Phelps: Violist in Vogue 

Multiple Term Query Using ACCUMULATE

     @query1
     Enter value for query_terms: politics,California
     SCR  ID AUTHOR          TITLE
     ---- -- --------------- ----------------------------
     100  17 Nolo Richards   REVIEW & OUTLOOK (Editorial):
                             California Smashup
     50   18 Nolo Richards   State Farm and California
     50   25 David Shribman  In the Wilderness: Democrats'
                             Troubles In Winning
     20   49 Nolo Richards   California High Court Is Asked
                             to Lift Block Of In
     10   13 Frederick C. Kl LEISURE & ARTS -- Sports:
                             Mediocrity's the Word Ar
     10   16 Heidi Waleson   LEISURE & ARTS: Cynthia
                             Phelps: Violist in Vogue 

Multiple Term Queries Using AND

     @query2
     Enter value for query_terms: politics&California
     SCR  ID AUTHOR          TITLE
     ---- -- --------------- ----------------------------
     20   25 David Shribman  In the Wilderness: Democrats'
                             Troubles In Winning

Overview of CTXLING

The CTXLING demo is a set of simple, related SQL*Plus scripts. Two of the scripts automate and track linguistic extraction on the demonstration documents. The remaining scripts can be used to query this linguistic output.

The CTXLING sample code consists of the following SQL scripts:

Script Description
genling.sql Requests theme and Gist generation for each of the documents in the ARTICLES table.
status.sql Shows the status of the theme and Gist generation initiated by genling..sql.
gist.sql Displays the Gists for a document.
themes.sql Displays the themes for a document.
similar.sql Displays documents with similar themes for the input document
Table 8 - 2. CTXLING SQL*Plus Scripts



For more information about the location of the scripts, see the Oracle7 Server installation documentation specifc to your operating system.

Concepts

The ConText Option concepts illustrated in this sample code are:

Setup

The CTXLING sample SQL*Plus scripts use the ARTICLES demonstration table and the DEMO_POLICY demonstration policy, as well as other demonstration objects.

Before the scripts can be used, all the required demonstration objects must be created in the database. Installation scripts are provided with ConText Option for creating the required demonstration objects.

For more information about running the demonstration installation scripts, see the Oracle7 Server installation documentation specifc to your operating system.

Using CTXLING

To use the CTXLING sample SQL scripts:

	@genling

	Clearing theme table...
	Clearing article table...
	Initializing ling_tracking table
	Creating ling. callback function LING_COMP_CALLBACK...
	Submitting all articles for linguistic extraction...

	All articles submitted.

	@status

	Linguistic Requests left: 36 
	Request Errors....

		@gist 40

	Points of View

	01 GENERIC ...
	15 production
	16 purchases

	Which point of view gist to print: 15

		@similar 14

CTXLING Examples

The following examples illustrate using themes.sql, gist.sql, and similar.sql to view the linguistic output generated by genling.sql.

Theme Viewing

   @themes 40 

   	Commodities: Coffee Futures Prices Decline on News That
   	U.S. Might Not Participate in New International Pact
   	by John Valentine 
   
   	T#  THEME                                         WEIGHT
   	--- --------------------------------------------- ------
   	01  United States                                 11
   	02  commerce and trade                            10
   	03  coffee                                        10 
   	...

Gist Viewing

   @gist 40

   Points of View

   01 GENERIC ...
   15 production
   16 purchases

   Which point of view gist to print: 15

   Commodities: Coffee Futures Prices Decline on News That
   U.S. Might Not Participate in New International Pact
   by John Valentine 

   Consuming and producing nations appear to be poles apart
   in their positions. Producing countries proposed a quota
   that would incorporate the sales of
   ...

Theme Comparison Viewing

   @similar 40

   Commodities: Coffee Futures Prices Decline on News That
   U.S. Might Not Participate in New International Pact
   by John Valentine

   Article Themes

   01 United States
   02 commerce and trade
   03 coffee
   ...
   14 production
   15 purchases

   Which theme to query: 15

   Other articles with this theme

   ID  WT  AUTHOR          TITLE
   --- --- --------------- --------------------------------
   1   8   William Power   OTC Focus: Composite Index Falls
   33  7   Alex Kaufmann   Your Money Matters: How to Take
   5   7   George Anders   Shades of U.S. Steel: J.P.
   30  6   Michael Siconol Mutual Funds: ...And Find Out if
   47  6   Nolo Richards   Ponce Federal Bank Is in Talks
   45  5   Nolo Richards   Farley Wins Round In His Bid to
   35  2   Alix M. Freedma Supermarkets Push Private-Label




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
Go to Index
Index