-
Notifications
You must be signed in to change notification settings - Fork 10
/
unknowaddress.py
48 lines (40 loc) · 1.47 KB
/
unknowaddress.py
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
# -*- coding: utf-8 -*-
from entities import AddressTokenInf
from entities import AddTypeInf
from entities import AddressType
from entities import AddTypes
class UnknowAddress(object):
@staticmethod
def mergeUnknow(tokens):
#for i in range(len(tokens)):
i = 0
while i < len(tokens):
token = tokens[i]
if token.data is not None:
i += 1
continue
unknowText = ''
start = token.start
while True:
unknowText += token.termText
del tokens[i]
if i >= len(tokens):
end = token.end
unKnowTokenInf = AddressTokenInf(start, end, unknowText)
item = AddTypeInf(AddressType.Unknow, 10, 0, unKnowTokenInf)
d = AddTypes()
d.put(item)
unKnowTokenInf.setData(d)
tokens.insert(i, unKnowTokenInf)
break
token = tokens[i]
if token.data is not None:
end = token.start
unKnowTokenInf = AddressTokenInf(start, end, unknowText)
item = AddTypeInf(AddressType.Unknow, 10, 0, unKnowTokenInf)
d = AddTypes()
d.put(item)
unKnowTokenInf.setData(d)
tokens.insert(i, unKnowTokenInf)
break
i += 1