To classify the documents, we use the CLASSIFIER.THIS PL/SQL procedure (a simple procedure designed for this example), which scrolls through the news_table, matches each document to a category, and writes the categorized results into the news_id_cat table.
create or replace package classifier asprocedure this;end;/
show errors
create or replace package body classifier as
procedure this
is
v_document clob;
v_item number;
v_doc number;
begin
for doc in (select tk, text from news_table)
loop
v_document := doc.text;
v_item := 0;
v_doc := doc.tk;
for c in (select queryid, category from news_categories
where matches(query, v_document) > 0 )
loop
v_item := v_item + 1;
insert into news_id_cat values (doc.tk,c.queryid);
end loop;
end loop;
end this;
end;
/
show errors
exec classifier.this