Initial commit
Browse files- entity2link.json +0 -0
- entityName2link.json +0 -0
- extract_Name2link.py +31 -0
- redial_unicrs.py +2 -2
entity2link.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
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 |
+
|
redial_unicrs.py
CHANGED
|
@@ -5,7 +5,7 @@ import html
|
|
| 5 |
import datasets
|
| 6 |
|
| 7 |
ENTITY = 'entity'
|
| 8 |
-
ENTITY_PATTERN = r'<entity>
|
| 9 |
|
| 10 |
|
| 11 |
def markup_entity(utt: str, entities: List[str]):
|
|
@@ -195,4 +195,4 @@ class ReDIAL(datasets.GeneratorBasedBuilder):
|
|
| 195 |
messages]
|
| 196 |
}
|
| 197 |
|
| 198 |
-
Idx += 1
|
|
|
|
| 5 |
import datasets
|
| 6 |
|
| 7 |
ENTITY = 'entity'
|
| 8 |
+
ENTITY_PATTERN = r'<entity>{}</entity>'
|
| 9 |
|
| 10 |
|
| 11 |
def markup_entity(utt: str, entities: List[str]):
|
|
|
|
| 195 |
messages]
|
| 196 |
}
|
| 197 |
|
| 198 |
+
Idx += 1
|