Kevin99z commited on
Commit
7577644
1 Parent(s): 01fea5b

Upload entityName2link.json

Browse files
entityName2link.json ADDED
The diff for this file is too large to render. See raw diff
 
extract_Name2link.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import re
3
+
4
+ with open('./entity2id.json') as entity2id, open('./entityName2id.json') as entityName2id:
5
+ entity2id = json.load(entity2id)
6
+ entityName2id = json.load(entityName2id)
7
+
8
+ id2entity = {k: v for v, k in entity2id.items()}
9
+ print('entity2id has:', len(entity2id))
10
+ print('id2entity has:', len(id2entity))
11
+ print('entityName2id has:', len(entityName2id))
12
+
13
+
14
+ entityName2link = {en : id2entity[entityName2id[en]] for en in entityName2id}
15
+ json.dump(entityName2link, open('entityName2link.json', 'w'))
16
+
17
+ # entityName2link = {}
18
+ # film_pattern = re.compile(r'/([^/]*\((\d+_)?film\))>')
19
+ # for link, id in entity2id.items():
20
+ # match = film_pattern.search(link)
21
+ # if match:
22
+ # name = match.group(1).replace('_', ' ')
23
+ # name = ' '.join(name.split(' ')).strip(' ')
24
+ # film_start = name.rfind('film')
25
+ # name = name[:film_start-1] + name[film_start+4:]
26
+ # if name[-2] == '(':
27
+ # name = name[:-2]
28
+ # entityName2link[name] = link
29
+ # print('entity2link has:', len(entityName2link))
30
+ # json.dump(entityName2link, open('entity2link.json', 'w'))
31
+
inspired_unicrs.py CHANGED
@@ -4,7 +4,7 @@ import datasets
4
  import re
5
 
6
  ENTITY = 'entity'
7
- ENTITY_PATTERN = r'<entity> {} </entity>'
8
 
9
 
10
  def markup_entity(utt: str, entities: List[str]):
 
4
  import re
5
 
6
  ENTITY = 'entity'
7
+ ENTITY_PATTERN = r'<entity>{}</entity>'
8
 
9
 
10
  def markup_entity(utt: str, entities: List[str]):