IMPORT_DICTIONARY

Use the CTX_ENTITY.IMPORT_DICTIONARY procedure to import an entity extraction user dictionary into Oracle Text tables.

An import dictionary is an XML containing entries for entities, with their associated types and alternate forms. The XML schema is the same XML schema used by Entity Extraction User Dictionary Loader (ctxload). You can load only one user dictionary per policy.

Syntax

CTX_ENTITY.IMPORT_DICTIONARY(
  policy_name               IN VARCHAR2,
  data                      IN CLOB,
  isdrop                    IN BOOLEAN DEFAULT FALSE);

policy_name

Specify the policy name.

data

Specify the XML dictionary.

The XML schema is as follows:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="dictionary">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="entities" type="entityType" maxOccurs="unbounded"/>
    </xsd:sequence>
  <xsd:complexType>
</xsd:element>

<xsd:complexType name="entityType">
  <xsd:sequence>
    <xsd:element name="entity" type="entType" maxOccurs="unbounded"/>
  </xsd:sequence>
  </xsd:attribute name="language" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="entType">
  <xsd:sequence>
    <xsd:element name="value" type="xsd:string"/>
    <xsd:element name="type" type="xsd:string" minOccurs="1" maxOccurs="unbounded"/>
    <xsd:element name="alternate" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

isdrop

Specify whether the current user dictionary must be dropped. The default value is FALSE.

Example 10-4 Importing an Entity Extraction User Dictionary into an Oracle Text Table

This example shows how to import an entity extraction user dictionary into an Oracle Text table using CTX_ENTITY.IMPORT_DICTIONARY procedure.

Create an extraction policy using the default settings. By default, the Oracle-supplied features, such as rules and dictionary, are enabled.

exec ctx_entity.create_extract_policy('mypol')

Import an entity extraction user dictionary and compile the extraction policy. Then, run entity extraction on the input document. You can also specify if the current user dictionary must be dropped.

declare
   datadic clob;
   doc     clob;
   res     clob;
 begin
   datadic := '<dictionary>
   <entities language="english">
     <entity>
       <value>NewEntry</value>
       <type>MyType</type>
     </entity>
   </entities>
   </dictionary>';

   ctx_entity.import_dictionary('mypol', datadic);
   ctx_entity.compile('mypol');

   doc := 'NEWENTRY';
   ctx_entity.extract('mypol', doc, 'english', res);

   dbms_output.put_line(res);

   -- Dropping dictionary
   ctx_entity.import_dictionary('mypol', null, isdrop=>true);
   ctx_entity.compile('mypol');

   ctx_entity.extract('mypol', doc, 'english', res);
   dbms_output.put_line(res);
 end;
 /

Entity Extraction User Dictionary Loader (ctxload)

COMPILE

CREATE_EXTRACT_POLICY

EXTRACT