@@ -17,7 +17,7 @@ def __init__(self):
17
17
# constants
18
18
self .party_sizes = ['한명' , '두명' , '세명' , '셋' , '네명' , '넷' , '다섯' , '다섯명' , '여섯' , '여섯명' , '일곱' , '여덟' ]
19
19
20
- self .locations = ['방콕' , '베이징' , '붐베이' , '하노이' , '파리' , '로마' , '런던' , '마드리드' , '서울' , '도쿄' ]
20
+ self .locations = ['방콕' , '베이징' , '붐베이' , '하노이' , '파리' , '로마' , '런던' , '마드리드' , '서울' , '도쿄' , 'LA' ]
21
21
22
22
self .cuisines = ['영국' ,'중국' ,'프랑스' , '이탈리아' , '인도' , '일식' , '일본' , '한식' , '한국' , '스페인' , '타이' , '베트남' ]
23
23
@@ -26,23 +26,28 @@ def __init__(self):
26
26
self .EntType = Enum ('Entity Type' , '<party_size> <location> <cuisine> <rest_type> <non_ent>' )
27
27
28
28
def ent_type (self , ent ):
29
+ # entity = [word for word in locations if word in input_str]
29
30
if ent .startswith (tuple (self .party_sizes )):
30
- return self .EntType ['<party_size>' ].name
31
+ entity_word = [word for word in self .party_sizes if word in ent ][0 ]
32
+ return self .EntType ['<party_size>' ].name , entity_word
31
33
elif ent .startswith (tuple (self .locations )):
32
- return self .EntType ['<location>' ].name
34
+ entity_word = [word for word in self .locations if word in ent ][0 ]
35
+ return self .EntType ['<location>' ].name , entity_word
33
36
elif ent .startswith (tuple (self .cuisines )):
34
- return self .EntType ['<cuisine>' ].name
37
+ entity_word = [word for word in self .cuisines if word in ent ][0 ]
38
+ return self .EntType ['<cuisine>' ].name , entity_word
35
39
elif ent .startswith (tuple (self .rest_types )):
36
- return self .EntType ['<rest_type>' ].name
40
+ entity_word = [word for word in self .rest_types if word in ent ][0 ]
41
+ return self .EntType ['<rest_type>' ].name , entity_word
37
42
else :
38
- return ent
43
+ return ent , None
39
44
40
45
def extract_entities (self , utterance , update = True , is_test = False ):
41
46
tokenized = []
42
47
for word in utterance .split (' ' ):
43
- entity = self .ent_type (word )
48
+ entity , entity_word = self .ent_type (word )
44
49
if word != entity and update :
45
- self .entities [entity ] = word
50
+ self .entities [entity ] = entity_word
46
51
tokenized .append (entity )
47
52
tokenized_str = ' ' .join (tokenized )
48
53
0 commit comments