File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -110,29 +110,35 @@ def shorten_title(doc):
110
110
if e .text_content ():
111
111
add_match (candidates , e .text_content (), orig )
112
112
113
+ cjk = re .compile ('[\u4e00 -\u9fff ]+' )
114
+
113
115
if candidates :
114
116
title = sorted (candidates , key = len )[- 1 ]
115
117
else :
116
118
for delimiter in [" | " , " - " , " :: " , " / " ]:
117
119
if delimiter in title :
118
120
parts = orig .split (delimiter )
119
- if len (parts [0 ].split ()) >= 4 :
120
- title = parts [0 ]
121
+ p0 = parts [0 ]
122
+ pl = parts [- 1 ]
123
+ if (len (p0 .split ()) >= 4 ) or (len (p0 ) >= 4 and cjk .search (p0 )):
124
+ title = p0
121
125
break
122
- elif len (parts [ - 1 ] .split ()) >= 4 :
123
- title = parts [ - 1 ]
126
+ elif ( len (p1 .split ()) >= 4 ) or ( len ( p1 ) >= 4 and cjk . search ( p1 )) :
127
+ title = p1
124
128
break
125
129
else :
126
130
if ": " in title :
127
- parts = orig .split (": " )
128
- if len (parts [ - 1 ] .split ()) >= 4 :
129
- title = parts [ - 1 ]
131
+ p1 = orig .split (": " )[ - 1 ]
132
+ if ( len (p1 .split ()) >= 4 ) or ( len ( p1 ) >= 4 and cjk . search ( p1 )) :
133
+ title = p1
130
134
else :
131
135
title = orig .split (": " , 1 )[1 ]
132
136
133
- if not 15 < len (title ) < 150 :
137
+ if cjk . search ( title ) and not ( 4 <= len (title ) < 100 ) :
134
138
return orig
135
-
139
+ elif not 15 < len (title ) < 150 :
140
+ return orig
141
+
136
142
return title
137
143
138
144
You can’t perform that action at this time.
0 commit comments