POLICY_PART_OF_SPEECH
Extracts part of speech information for each word in a body of text. POLICY_NOUN_PHRASES has the list of supported languages.
Syntax
ctx_doc.policy_part_of_speech (
policy_name in varchar2,
document in varchar2 | CLOB,
restab in out nocopy noun_phrase_tab,
language in varchar2 default NULL,
format in varchar2 default NULL,
charset in varchar2 default NULL
disambiguate_tags in boolean default TRUE
);
policy_name
Specify the policy name created with CTX_DDL.CREATE_POLICY. If the specified policy includes a sectioning preference, the API will honor the sectioning preference. For instance, if HTML sectioning is specified, HTML tags will be removed before processing the input document.
document
A body of text for which the languages are to be extracted. The text is assumed to be plain text with UTF-8 character encoding.
restab
Specify the name of the CLOB locator. The query returns a table with the result of the noun phrase extraction. For each word, the following attributes are also returned:
-
pos_tags: the part of speech tags for this word. There can be multiple part of speech tags with the most likely tag listed first. -
offset: offset of the word in the input string -
length: length of the word in the input string. -
is_in_lexicon: Indicates whether the word is in the lexicon.
language
Specify the language. See the list of supported languages in this section. If this parameter is null, the language will be automatically detected. There is a cost associated with language detection.
format
The format of the input text.
charset
The character set of the input text.
Example for POLICY_PART_OF_SPEECH
The example in this section uses the abbreviations shown in Table 9-1.
set serveroutput on;
declare
the_nps ctx_doc.part_of_speech_tab;
begin
ctx_doc.policy_part_of_speech(policy_name => 'rv_policy_21',
document => 'The mayor of Chicago is giving
a brief press conference',
restab => the_nps,
disambiguate_tags => false,
language => 'english');
for i in 1..the_nps.count loop
dbms_output.put('word:' || the_nps(i).word || ',pos:[');
for j in 1..the_nps(i).pos_tags.count loop
dbms_output.put(the_nps(i).pos_tags(j) || ',');
end loop;
dbms_output.put_line(']');
end loop;
end;
/
Output for this example:
word:The,pos:[Det,]
word:mayor,pos:[N,]
word:of,pos:[Prep,]
word:Chicago,pos:[propN,]
word:is,pos:[V,]
word:giving,pos:[N,V,Adj,]
word:a,pos:[Det,]
word:brief,pos:[N,V,Adj,]
word:press,pos:[N,V,]
word:conference,pos:[N,V,]