Spaces:
Runtime error
Runtime error
Fix the function add_sentence_table second times
Browse filesAdd threshold_num and threshold_rate in the function "add_sentence_table", and using the (new_start new_end) for postprocess index
- code/prediction.py +3 -3
code/prediction.py
CHANGED
@@ -81,12 +81,12 @@ def add_sentence_table(result, pattern =":;。,?!~!: ", threshold_nu
|
|
81 |
end = boundary
|
82 |
new_start = start
|
83 |
new_end = end
|
|
|
84 |
for i, predict_char in enumerate(sample["predict_span_table"][start:end]):
|
85 |
if predict_char!=0:
|
86 |
-
|
87 |
-
prrdict_num = sum(sample["predict_span_table"][start:end])
|
88 |
sentence_num = len(sample["predict_span_table"][start:end])
|
89 |
-
if(
|
90 |
|
91 |
while(sample["predict_span_table"][new_start]==0): new_start+=1
|
92 |
while(sample["predict_span_table"][new_end-1]==0): new_end-=1
|
|
|
81 |
end = boundary
|
82 |
new_start = start
|
83 |
new_end = end
|
84 |
+
predict_num = 0
|
85 |
for i, predict_char in enumerate(sample["predict_span_table"][start:end]):
|
86 |
if predict_char!=0:
|
87 |
+
predict_num+=1
|
|
|
88 |
sentence_num = len(sample["predict_span_table"][start:end])
|
89 |
+
if(predict_num > threshold_num) or (predict_num > sentence_num*threshold_rate):
|
90 |
|
91 |
while(sample["predict_span_table"][new_start]==0): new_start+=1
|
92 |
while(sample["predict_span_table"][new_end-1]==0): new_end-=1
|