asahi417 commited on
Commit
f681059
1 Parent(s): 7ad0deb

fix dataset

Browse files
process/tweet_ner.py CHANGED
@@ -74,6 +74,7 @@ def process(tmp):
74
  entities = decode_ner_tags(i['tags'].tolist(), i['tokens'].tolist())
75
  for e in entities:
76
  e.pop("position")
 
77
  i['gold_label_sequence'] = i.pop('tags').tolist()
78
  i['text_tokenized'] = i.pop('tokens').tolist()
79
  i['text'] = ' '.join(i['text_tokenized'])
 
74
  entities = decode_ner_tags(i['tags'].tolist(), i['tokens'].tolist())
75
  for e in entities:
76
  e.pop("position")
77
+ e["entity"] = " ".join(e["entity"])
78
  i['gold_label_sequence'] = i.pop('tags').tolist()
79
  i['text_tokenized'] = i.pop('tokens').tolist()
80
  i['text'] = ' '.join(i['text_tokenized'])
process/unify_sp_symbol.py CHANGED
@@ -19,10 +19,15 @@ for i in glob("data/tweet_ner7/*.jsonl"):
19
  data = [json.loads(j) for j in f.readlines()]
20
  for d in data:
21
  d['text'] = d['text'].replace("{{USERNAME}}", "@user").replace("{{URL}}", "{URL}")
22
- d['text'] = re.sub(r'\{@([^@].)@}', r'\1', d['text'])
 
 
23
  for t in re.findall(r'{@[^@^}]*@}', d['text']):
24
  t_new = t.replace("{@", "@").replace("@}", "").replace(" ", "_")
25
  d['text'] = d['text'].replace(t, t_new)
26
- d['text_tokenized'] =
 
 
 
27
  with open(i, "w") as f:
28
  f.write("\n".join([json.dumps(j) for j in data]))
 
19
  data = [json.loads(j) for j in f.readlines()]
20
  for d in data:
21
  d['text'] = d['text'].replace("{{USERNAME}}", "@user").replace("{{URL}}", "{URL}")
22
+ d['text_tokenized'] = [y if y != "{{USERNAME}}" else "@user" for y in d['text_tokenized']]
23
+ d['text_tokenized'] = [y if y != "{{URL}}" else "{URL}" for y in d['text_tokenized']]
24
+
25
  for t in re.findall(r'{@[^@^}]*@}', d['text']):
26
  t_new = t.replace("{@", "@").replace("@}", "").replace(" ", "_")
27
  d['text'] = d['text'].replace(t, t_new)
28
+ d['text_tokenized'] = [y if y != t else t_new for y in d['text_tokenized']]
29
+ for e in d['entities']:
30
+ e['']
31
+
32
  with open(i, "w") as f:
33
  f.write("\n".join([json.dumps(j) for j in data]))