EXTRACT
The EXTRACT procedure runs entity extraction on a given document and generates an XML document describing the entities found in the document.
The XML document will give the entity text, type, and location of the entity in the document. The extraction will use the settings (rules, stop entities, and dictionary) defined in the given extraction policy.
Entity type names in the result will be uppercased. Invokers can run extraction using their own extraction policy.
Before execution, you have to issue CTX_ENTITY.COMPILE.
Syntax
CTX_ENTITY.EXTRACT(
policy_name IN VARCHAR2,
document IN CLOB,
language IN VARCHAR2,
result IN OUT NOCOPY CLOB,
entity_type_list IN CLOB DEFAULT NULL
);
policy_name
Run extraction using the given policy.
document
The input document to run extraction on.
If entity_type is NULL, all mentions with this entity_name will be listed as stop entities. It is case-sensitive.
language
Only English is supported.
result
A CLOB containing the XML description of the entities extracted from the document.
If entity_type is NULL, all mentions with this entity_name will be listed as stop entities. It is case-sensitive.
entity_type_list
Specify that extraction will only consider a subset of entity types. The entity_type_list is a comma-delimited list. If the entity_type_list is not specified, the entity extraction will consider all entity types.
Example
The following example shows the results of entity extraction on an example document. Suppose that we have created an extraction policy called pol1, and we are given the input document:
Sam A. Schwartz retired as executive vice president of Org Inc. in New York.
We then call the ctx_entity.extract procedure to generate an XML document containing the entities in this document. We insert the results CLOB into a table called entities for future viewing.
declare
myresults clob;
begin
select txt into mydoc from docs where id=1;
ctx_entity.extract('p1', mydoc, null, myresults);
insert into entities values(1, myresults);
commit;
end;
/
Then we can examine the extracted entities from the entities table. Note that each entity is tagged with its location in the input document, as well as the source used to classify the entity.
<entities>
<entity id="0" offset="75" length="8" source="SuppliedDictionary">
<text>New York</text>
<type>city</type>
</entity>
<entity id="1" offset="55" length="16" source="SuppliedRule">
<text>Org Inc.</text>
<type>company</type>
</entity>
<entity id="2" offset="27" length="24" source="SuppliedDictionary">
<text>Sam A. Schwartz</text>
<type>person_name</type>
</entity>
<entity id="4" offset="75" length="8" source="SuppliedDictionary">
<text>New York</text>
<type>state</type>
</entity>
</entities>