|
@ -2,6 +2,7 @@ |
|
|
# -*- coding: utf-8 -*- |
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
|
|
|
|
import os |
|
|
import os |
|
|
|
|
|
import re |
|
|
import sys |
|
|
import sys |
|
|
import json |
|
|
import json |
|
|
from itertools import product |
|
|
from itertools import product |
|
@ -13,6 +14,10 @@ punctuationPairs = [ |
|
|
('(', ')'), |
|
|
('(', ')'), |
|
|
] |
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
endingPunctuations = [ |
|
|
|
|
|
'。', '?', '!', '”', '’', '~', '……', '——', |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
defaultPath = os.path.join( |
|
|
defaultPath = os.path.join( |
|
|
os.path.dirname(os.path.realpath(__file__)), '../../release/' |
|
|
os.path.dirname(os.path.realpath(__file__)), '../../release/' |
|
|
) |
|
|
) |
|
@ -61,10 +66,29 @@ def pairsCheck(sentence: str) -> bool: |
|
|
return True # no error match in sentence |
|
|
return True # no error match in sentence |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def endingCheck(sentence: str) -> bool: |
|
|
|
|
|
if re.search(r'^第\d+章 \S*$', sentence) is not None: # skip caption |
|
|
|
|
|
return True |
|
|
|
|
|
for endingPunctuation in endingPunctuations: |
|
|
|
|
|
if sentence.endswith(endingPunctuation): # match ending punctuation |
|
|
|
|
|
return True |
|
|
|
|
|
print('%s\033[0;31m_\033[0;39m' % sentence) |
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def contentCheck(content: list) -> None: |
|
|
def contentCheck(content: list) -> None: |
|
|
|
|
|
flag = True |
|
|
for row in content: # pairs check |
|
|
for row in content: # pairs check |
|
|
pairsCheck(row) |
|
|
flag &= pairsCheck(row) |
|
|
print('-' * 128) |
|
|
if not flag: |
|
|
|
|
|
print('-' * 128) # split line |
|
|
|
|
|
|
|
|
|
|
|
flag = True |
|
|
|
|
|
for row in content: # ending check |
|
|
|
|
|
flag &= endingCheck(row) |
|
|
|
|
|
if not flag: |
|
|
|
|
|
print('-' * 128) # split line |
|
|
|
|
|
|
|
|
# other check process |
|
|
# other check process |
|
|
|
|
|
|
|
|
|
|
|
|
|
|