存储过程代码:
CREATE OR REPLACE FUNCTION F_Paragraph(FileID varchar2)
return docstruct_view
AS
PRAGMA AUTONOMOUS_TRANSACTION;
—————————————————————————–
–a) 段落主从关系
–b) 本段落末尾是否为冒号或者无符号。
–c) 落末尾是否为句号、问号、感叹号、省略号。
–d) b是c的父, c与c是子, 且按顺序
————————————————-
–1.判断段落范围。
–1.1 如果没有目录,那么认为 第一段为 该篇文档的标题。之后到引文部分
–2. 得到 本段落末尾是否为冒号或者无符号= 文章标题段落
–3 得到 落末尾是否为句号、问号、感叹号、省略号。= 文章正文段落
–4 标题段落按段落的开始标志判断 标题层级。
————————————————-
–编写时发现,不必区分,标题序言目录引文等等。
–段落之间存在普遍规律
–2015-1-26
–MC
—————————————————————————–
mydocstruct_table docstruct_table := docstruct_table ();
mydocstruct_view docstruct_view:=docstruct_view();
mydocstruct_view1 docstruct_view:=docstruct_view();
connum int;
connum1 int;
structID varchar2(4000);–文档结构ID
structType varchar2(50);–文档类型
myDocStruct_Regular_ID varchar2(50);–段首标识匹配的正则表达式ID
myDocStruct_StarID varchar2(4000);–段首标识 字符串
myDocStruct_SameStr varchar2(4000); –相同部分 字符串
myF_DocStruct_ID varchar2(4000);–父节点id
myDocStruct_Level varchar2(4000);–段落级别
begin
/*–取目录顺序
select nvl(max(DocStruct_Num),null) into connum from Word_Sys t left join DocStruct t1 on t.docstruct_id=t1.docstruct_id where t1.doc_id= FileID and t.word_value=””目录””;
select nvl(max(DocStruct_Num),null) into connum1 from Word_Sys t left join DocStruct t1 on t.docstruct_id=t1.docstruct_id where t1.doc_id= FileID and t.word_value=””引文””;
–如果没有目录 则认为 目录的段落顺序为1.
if connum=0 then connum:=1; end if;
–如果没有引文 则认为 引文的段落顺序为.
if connum1=0 then
–如果没有引文 则认为 段落 最大顺序是文章结尾
select nvl(max(DocStruct_Num),null) into connum1 from Word_Sys t left join DocStruct t1 on t.docstruct_id=t1.docstruct_id where t1.doc_id= FileID;
connum1:=connum1+1;
end if;*/
connum:=0;
declare
cursor cur_list is
select t1.* from DocStruct t1 where t1.doc_id= FileID;
begin
for item_cs in cur_list loop
–if connum<item_cs.docstruct_num and item_cs.docstruct_num<connum1 then– 在目录和序言范围之内 不进行目录引文判断
–得到 本段落末尾是否为冒号或者无符号
–得到 落末尾是否为句号、问号、感叹号、省略号。
select f_judge_paragraphtype(item_cs.DocStruct_ID) into structType from dual;
mydocstruct_table.EXTEND;
mydocstruct_table(mydocstruct_table.count) := docstruct_table_obj(item_cs.DocStruct_ID,item_cs.Doc_ID, item_cs.Doc_Value,item_cs.F_DocStruct_ID,structType,item_cs.DocStruct_Level,item_cs.DocStruct_Num); –插入结果集
— end if;
end loop;
end;
—-确定文档结构 的 F_DocStruct_ID DocStruct_Level
–1.取得文档 的 段首标识匹配的正则表达式ID 段首标识字符串 相同部分字符串
–1.1 段首标识匹配的正则表达式ID
–1.2 段首标识字符串
–1.3 相同部分字符串
–2. 确定 F_DocStruct_ID DocStruct_Level
declare —–1.取得文档 的 段首标识匹配的正则表达式ID 段首标识字符串 相同部分字符串
cursor cur_list1 is
select * from table(cast(mydocstruct_table as docstruct_table));
begin
for item_cs1 in cur_list1 loop
select f_getstarid(item_cs1.DocStruct_ID,2) into myDocStruct_Regular_ID from dual;
select f_getstarid(item_cs1.DocStruct_ID,1) into myDocStruct_StarID from dual;
select f_getstarid(item_cs1.DocStruct_ID,4) into myDocStruct_SameStr from dual;
mydocstruct_view.EXTEND;
mydocstruct_view(mydocstruct_view.count) := docstruct_view_obj(item_cs1.DocStruct_ID,item_cs1.Doc_ID, item_cs1.Doc_Value,item_cs1.F_DocStruct_ID,item_cs1.DocStruct_Type,item_cs1.DocStruct_Level,item_cs1.DocStruct_Num,myDocStruct_Regular_ID,myDocStruct_StarID,myDocStruct_SameStr); –插入结果集
end loop;
end;
declare cursor cur_list2 is
select * from table(cast(mydocstruct_view as docstruct_view));
begin
for item_cs2 in cur_list2 loop
mydocstruct_view1.EXTEND;
mydocstruct_view1(mydocstruct_view1.count) := docstruct_view_obj(item_cs2.DocStruct_ID,item_cs2.Doc_ID, item_cs2.Doc_Value,myF_DocStruct_ID,item_cs2.DocStruct_Type,myDocStruct_Level,item_cs2.DocStruct_Num,item_cs2.DocStruct_Regular_ID,item_cs2.DocStruct_StarID,item_cs2.DocStruct_SameStr); –插入结果集
select f_find_parent_structid(item_cs2.DocStruct_ID,mydocstruct_view1,1) into myF_DocStruct_ID from dual;
select f_find_parent_structid(item_cs2.DocStruct_ID,mydocstruct_view1,2) into myDocStruct_Level from dual;
mydocstruct_view1(mydocstruct_view1.count) := docstruct_view_obj(item_cs2.DocStruct_ID,item_cs2.Doc_ID, item_cs2.Doc_Value,myF_DocStruct_ID,item_cs2.DocStruct_Type,myDocStruct_Level,item_cs2.DocStruct_Num,item_cs2.DocStruct_Regular_ID,item_cs2.DocStruct_StarID,item_cs2.DocStruct_SameStr); –插入结果集
end loop;
end;
return mydocstruct_view1;
end F_Paragraph;