DBA Data[Home] [Help]

PACKAGE: CTXSYS.DRVODM

Source


1 PACKAGE drvodm AUTHID current_user AS
2 
3 TYPE CurType IS REF CURSOR;
4 
5 /* type used for svm interface to odm containing training set */
6 TYPE trainsamp IS RECORD (
7     sequence_id    NUMBER,  -- document id
8     attribute_id   NUMBER,  -- feature id >=0
9                             -- or -1 for rows that contain doc. assignment info
10     value          NUMBER   -- feature weight
11                             -- or catid for rows for doc. assignment info
12   );
13 
14 TYPE trainsamps IS TABLE OF trainsamp;
15 
16 /* type used for feature definition */
17 TYPE feature IS RECORD (
18 	text varchar2(160),     -- feature text
19 	type number(3),         -- feature type with 0:single token,
20 				--		     1:theme
21  				--		     9:stem words
22 	id   number,            -- feature id
23 	score number            -- statistic feature score which can be idf
24 				--    if need to calculate idf for feature
25 				--    weight in documents or simply document
26 			        --    frequency.
27 	);
28 TYPE features IS TABLE OF feature;
29 
30 TYPE suggestion IS RECORD (
31 	docid  number,          -- document id
32 	catid  number,          -- suggested category id
33 	scr    number           -- associate score between doc and category
34 );
35 TYPE suggestions IS TABLE of suggestion;
36 
37 TYPE kmeanmodel_rec IS RECORD (
38 	id integer,                  -- cluster id
39 	parent number,  	     -- parent id
40 	dispersion number,	     -- coherencen of the cluster
41         attribute_name varchar2(30));  -- attribute id
42 TYPE kmeanmodel is table of kmeanmodel_rec;
43 
44 /* train SVM model */
45 PROCEDURE svm_train(
46     	idx_owner varchar2,
47 	idx_name  varchar2,
48 	doctab    varchar2,
49 	docid     varchar2,
50 	cattab    varchar2,
51 	catdocid  varchar2,
52 	catid     varchar2,
53 	restab    varchar2,
54 	prefid    number
55 );
56 
57 /* ----table function used for ODM to extract feature from training set ----*/
58 /* DESCRIPTION
59    The result table is either created by users before calling this function or
60    created in this program with the specified table name and under the current
61    user (if the specified table does not exist).
62    If user create the result table (which can support table schema for
63    different users),
64    the restab should have the following three columns with the exact column
65    names:
66 	cat_id number
67 	type number(3) not null
68 	rule blob
69 */
70 FUNCTION feature_prep(
71 	index_name  varchar2, -- context index name on training document table.
72 	docid     varchar2,   -- document id column name in document table
73 	cattab    varchar2,   -- name of category table
74 	catdocid  varchar2,   -- document id column name for category table
75 	catid     varchar2,   -- category id column name for category table
76 	restab    varchar2,   -- result table to write the model
77 	preference varchar2   -- preference name
78 ) RETURN trainsamps PIPELINED;
79 
80 /* -- table function used for ODM to get features for test set ----------*/
81 /* DESCRIPTION
82    This function is used in apply time. The <restab> is the result table
83    output from calling feature preparation function based on training set.
84 */
85 FUNCTION feature_prep(
86 	index_name  varchar2, -- context index name on training document table.
87 	docid     varchar2,   -- document id column name in document table
88 	restab    varchar2    -- table storing the feature definition
89 ) RETURN trainsamps PIPELINED;
90 
91 /* ----------------------- for ODM to explain features ------------------*/
92 /* DESCRIPTION
93    The <restab> is the result table output from calling feature preparation
94    function based on training set.
95 */
96 FUNCTION feature_explain(
97 	restab    varchar2    -- table storing the feature definition
98 	) RETURN features PIPELINED;
99 
100 
101 
102 /*--------------------------------------------------------------------------*/
103 /*                                                                          */
104 /*------------The following functions is internal functions  ---------------*/
105 /*                                                                          */
106 /*--------------------------------------------------------------------------*/
107 
108 /* feature preparation table function without checking input parameter */
109 FUNCTION feature_prep_nc(
110 	idx_owner varchar2,
111 	idx_name  varchar2,
112 	doctab    varchar2,
113 	docid     varchar2,
114 	cattab    varchar2,
115 	catdocid  varchar2,
116 	catid     varchar2,
117 	restab    varchar2,
118 	prefid    number,
119 	temp_table varchar2
120 ) RETURN trainsamps PIPELINED;
121 
122 /* start classify a document.Assume: The document feature vector has been
123    generated */
124 FUNCTION get_suggestions(model_name varchar2, dur number)
125    return suggestions PIPELINED;
126 
127 /* type used for ODM setup */
128 TYPE settingdbrec_t IS RECORD (
129     id             NUMBER,
130     value          VARCHAR2(128)
131   );
132 TYPE setting_t IS TABLE of settingdbrec_t;
133 
134 FUNCTION odmtrainset return setting_t PIPELINED;
135 
136 FUNCTION  get_features
137 RETURN trainsamps PIPELINED;
138 
139 PROCEDURE fvstab(
140 	fvstab    OUT varchar2);
141 
142 PROCEDURE fi2ttab(
143 	fi2ttab    OUT varchar2);
144 
145 
146 FUNCTION odmktrainset(p_srt in varchar2,
147 p_cluster_num in number) return setting_t PIPELINED;
148 
149 -- generate model
150 PROCEDURE odm_genmodel(
151 p_fvstab in varchar2,
152 p_srtab  in varchar2,
153 p_cluster_num in number,
154 o_modname OUT varchar2);
155 
156 FUNCTION odm_readkmeanmodel(
157 	p_modname varchar2) return kmeanmodel PIPELINED;
158 
159 -- drop model
160 PROCEDURE odm_drpmodel(
161 p_modname IN varchar2);
162 
163 END drvodm;