Skip to content

Commit 4df93ca

Browse files
committed
remove shapely
1 parent 9e3ace5 commit 4df93ca

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pydateparser/_core_date_parser.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
22
import copy
3-
from shapely.geometry import LineString
3+
#from shapely.geometry import LineString
44

55

66
class CoreDateParser:
@@ -110,12 +110,13 @@ def get_match_tokens(self, priority_matches, token_spans):
110110
start_token = 1000
111111
end_token = -1
112112
for idx in token_spans:
113-
ls1 = LineString([(char_start, 0), (char_end, 0)])
114-
ls2 = LineString(
115-
[(token_spans[idx][1], 0), (token_spans[idx][2], 0)])
116-
if ls1.intersects(ls2):
113+
if (char_start > token_spans[idx][1] and char_start < token_spans[idx][2]) or (char_end > token_spans[idx][1] and char_end < token_spans[idx][2]):
117114
start_token = min(start_token, token_spans[idx][3])
118115
end_token = max(end_token, token_spans[idx][3])
116+
# ls1 = LineString([(char_start, 0), (char_end, 0)])
117+
# ls2 = LineString(
118+
# [(token_spans[idx][1], 0), (token_spans[idx][2], 0)])
119+
# if ls1.intersects(ls2):
119120
ret_list.append(list(pm) + [start_token, end_token])
120121
ret_list = sorted(ret_list, key=lambda x: x[2]-x[1], reverse=True)
121122
final_ret_list = []

0 commit comments

Comments
 (0)