Log In
|
Sign Up
Search
목차 있는 문서 트리형태로 파싱 - User Function
Writer
박창섭
Description
User Function - split_bodys : 문단 나누기 recursive call parameters - 1. 대상 텍스트 : string - 2. 문단 depth : int - 3. 타이틀 제목의 경로 : string (call by Ref) - 4. 최종결과 List : list
> tuple<매치타이틀, 해당 타이틀 내용, index, 타이틀경로> (call by Ref) - 5. 매칭 시작 Regular Expression 리스트 : list
- 6. 매칭 끝 Regular Expression 리스트 : list
void split_bodys(string text, int z, string &TIT_PATH, list
> &L_TP, list
MATCH_REG, list
SUB_MATCH_REG) { list
match_list; list
sub_match_list; int x = z; bool isOccupied; isOccupied = text.match(MATCH_REG[z],0,&match_list); if(isOccupied == false && z+1 < MATCH_REG.length()) split_bodys(text, ++x, TIT_PATH, L_TP, MATCH_REG, SUB_MATCH_REG); string target_text = text; string match_str, new_text, tit; int i, m, n = 0; x++; for match_str in match_list{ n = target_text.strstr(match_str); target_text = target_text.substr(n+strlen(match_str)); new_text = target_text; int y ; for(y = z; y>=0; y--){ if(target_text.match(SUB_MATCH_REG[y],0, &sub_match_list)==true){ new_text = target_text.substr(0,target_text.strstr(sub_match_list[0])); break; } } tit = TIT_PATH+'>>'+match_str.trim(); L_TP.append( ( match_str, new_text, z, tit) ); if(x< MATCH_REG.length()) split_bodys(new_text, x, tit, L_TP, MATCH_REG, SUB_MATCH_REG); } TIT_PATH = ''; }
Tag
텍스트 트리형태 parser
Module Name
Attachments
com_parser.k (3.2kb)
Comments
Save
Save
Cancel
Save
Cancel
Warning
Login