-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunc.js
64 lines (63 loc) · 2.95 KB
/
func.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function get_sents_list_by_section(sent_info_list, positions_as_page_num_list){
//page spans to sents-with-global-idx list
section_title_sents_list_list = []
for (var i = 0; i < positions_as_page_num_list.length - 1; i++){
var local_sents_str_list = []
var local_sents_list = []
var section_title = positions_as_page_num_list[i].accumulative_title
for (var j = 0; j < sent_info_list.length; j++){
if (sent_info_list[j].page_num >= positions_as_page_num_list[i].page_num &&
sent_info_list[j].page_num < positions_as_page_num_list[i+1].page_num){
local_sents_list.push(sent_info_list[j])
local_sents_str_list.push(sent_info_list[j].sent)
// section_title = positions_as_page_num_list[i].accumulative_title
}
}
section_title_sents_list_list.push({section_title:section_title,
sents:local_sents_list,
text:local_sents_str_list.join(' ')
})
}
//then deal with the last section
var local_sents_str_list = []
var local_sents_list = []
var section_title = positions_as_page_num_list[positions_as_page_num_list.length-1].accumulative_title
for (var j = 0; j < sent_info_list.length; j++){
if (sent_info_list[j].page_num >= positions_as_page_num_list[positions_as_page_num_list.length-1].page_num &&
sent_info_list[j].page_num <= doc_numPages){
local_sents_list.push(sent_info_list[j])
local_sents_str_list.push(sent_info_list[j].sent)
// section_title = positions_as_page_num_list[positions_as_page_num_list.length-1].accumulative_title
}
}
section_title_sents_list_list.push({section_title:section_title,
sents:local_sents_list,
text:local_sents_str_list.join(' ')
})
console.log('section_title_sents_list_list',section_title_sents_list_list)
return section_title_sents_list_list
}
function get_sents_list_of_each_page(sent_info_list, doc_numPages){
section_title_sents_list_list = []
for (var i = 1; i <= doc_numPages; i++){
var local_sents_str_lemma_list = []
var local_sents_str_list = []
var local_sents_list = []
var section_title = i
for (var j = 0; j < sent_info_list.length; j++){
if (sent_info_list[j].page_num == i){
local_sents_list.push(sent_info_list[j])
local_sents_str_list.push(sent_info_list[j].sent)
local_sents_str_lemma_list.push(sent_info_list[j].sent_lemma)
// section_title = positions_as_page_num_list[i].accumulative_title
}
}
section_title_sents_list_list.push({section_title:section_title,
sents:local_sents_list,
text:local_sents_str_list.join(' '),
text_lemma:local_sents_str_lemma_list.join(' ')
})
}
console.log('section_title_sents_list_list',section_title_sents_list_list)
return section_title_sents_list_list
}