Zeb commited on
Commit
4b568ae
1 Parent(s): a245e72

Fix some errors

Browse files
tag_data.py CHANGED
@@ -68,8 +68,7 @@ def tokenize_lines(text, tokenizer):
68
 
69
  def get_tags_from_file(file):
70
  with open(file, 'r') as f:
71
- # Skip the first line, the file name
72
- lines = f.read().splitlines()[1:]
73
 
74
  gold_tagged_lines = []
75
  pred_tagged_lines = []
@@ -78,6 +77,7 @@ def get_tags_from_file(file):
78
  total = 0
79
  correct = 0
80
  for line in lines:
 
81
  if line == '':
82
  gold_tagged_lines.append(gold_tagged)
83
  pred_tagged_lines.append(pred_tagged)
@@ -103,10 +103,9 @@ def write_tagged_lines(filename, text, tagged_lines):
103
  f.write(line)
104
  f.write(' '.join([f'{token}__<label>__{tag}' for token, tag in tagged]) + '\n')
105
 
106
- tokenizer = AutoTokenizer.from_pretrained("CamBabyTrainers/BabyBERTa-3-8192-tokenizer")
107
 
108
  FOLDERS = ['10M', '100M', 'dev', 'test']
109
- FILENAMES = ['qed.txt', 'switchboard.txt']
110
 
111
  if __name__ == "__main__":
112
 
@@ -115,7 +114,7 @@ if __name__ == "__main__":
115
  for folder in FOLDERS:
116
  for root, dirs, files in os.walk(f"clean/{folder}"):
117
  for file in files:
118
- if file.endswith(".txt") and file.split('/')[-1] in FILENAMES:
119
  all_files.append(os.path.join(root, file))
120
 
121
  # Get map from PTB tags to universal tags
@@ -128,7 +127,7 @@ if __name__ == "__main__":
128
  for file in all_files:
129
  print(file)
130
  with open(file, 'r') as f:
131
- lines = f.readlines()
132
 
133
  # 1. Tokenize the lines in the text, tag with universal tags and write to tmp file
134
  tokenized = tokenize_lines(lines, tokenizer)
@@ -152,6 +151,5 @@ if __name__ == "__main__":
152
  os.makedirs(os.path.dirname(new_file), exist_ok=True)
153
  write_tagged_lines(new_file, lines, gold_tagged_lines)
154
 
155
-
156
  os.remove('tmp.txt')
157
  os.remove('tmp_tagged.txt')
 
68
 
69
  def get_tags_from_file(file):
70
  with open(file, 'r') as f:
71
+ lines = f.readlines()
 
72
 
73
  gold_tagged_lines = []
74
  pred_tagged_lines = []
 
77
  total = 0
78
  correct = 0
79
  for line in lines:
80
+ line = line.strip()
81
  if line == '':
82
  gold_tagged_lines.append(gold_tagged)
83
  pred_tagged_lines.append(pred_tagged)
 
103
  f.write(line)
104
  f.write(' '.join([f'{token}__<label>__{tag}' for token, tag in tagged]) + '\n')
105
 
106
+ tokenizer = AutoTokenizer.from_pretrained("CamBabyTrainers/CamBabyTokenizer-8192")
107
 
108
  FOLDERS = ['10M', '100M', 'dev', 'test']
 
109
 
110
  if __name__ == "__main__":
111
 
 
114
  for folder in FOLDERS:
115
  for root, dirs, files in os.walk(f"clean/{folder}"):
116
  for file in files:
117
+ if file.endswith(".txt"):
118
  all_files.append(os.path.join(root, file))
119
 
120
  # Get map from PTB tags to universal tags
 
127
  for file in all_files:
128
  print(file)
129
  with open(file, 'r') as f:
130
+ lines = f.readlines()[1:]
131
 
132
  # 1. Tokenize the lines in the text, tag with universal tags and write to tmp file
133
  tokenized = tokenize_lines(lines, tokenizer)
 
151
  os.makedirs(os.path.dirname(new_file), exist_ok=True)
152
  write_tagged_lines(new_file, lines, gold_tagged_lines)
153
 
 
154
  os.remove('tmp.txt')
155
  os.remove('tmp_tagged.txt')
tagged/100M/open_subtitles.txt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c46a1426dfaf065588a8c2973b4156f67b9579a6d00c7f374cfd9fba1eecf822
3
- size 896907269
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b9cd20ccc123380f59f1e0a6d1fbd4a60e51788225ef7c9c500974a591c07ecd
3
+ size 896907260
tagged/100M/qed.txt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5bb8331ac5ee04908bad5b87fe873d367d6e2b27dc90d81fd76f23da0ad80357
3
- size 285761401
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e56f972c7afcf462b6d16e582451798a3597dfe3e109c9074462bb587ad40f08
3
+ size 285761360
tagged/100M/switchboard.txt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:50d6c3d94fa08d2adc4152af2eecb1881b7dec32b003edfe71a0ff8e4ceb7860
3
- size 34572605
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d4d71e3bfa25c247d9a9f932dcc5941c8779bf0fac86b45729d5d171874a832a
3
+ size 34572556
tagged/10M/aochildes.txt CHANGED
@@ -1,6 +1,6 @@
1
  aochildes.txt
2
  aboo.
3
- aboo__<label>__NOUN .__<label>__.
4
  kee. hey. smile? hm hm. smile.
5
  kee__<label>__NOUN .__<label>__. hey__<label>__NOUN .__<label>__. smile__<label>__NOUN ?__<label>__. hm__<label>__NOUN hm__<label>__NOUN .__<label>__. smile__<label>__NOUN .__<label>__.
6
  hi. aguh. mguh! mguh? abuabuabluabuh.
 
1
  aochildes.txt
2
  aboo.
3
+ .__<label>__.
4
  kee. hey. smile? hm hm. smile.
5
  kee__<label>__NOUN .__<label>__. hey__<label>__NOUN .__<label>__. smile__<label>__NOUN ?__<label>__. hm__<label>__NOUN hm__<label>__NOUN .__<label>__. smile__<label>__NOUN .__<label>__.
6
  hi. aguh. mguh! mguh? abuabuabluabuh.
tagged/10M/gutenberg.txt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:63777a019effa6c80bfcbc33c9d7980bb577df763318f09f321c80842015ec92
3
- size 23485665
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ca236758c038e9893ab915ef94a51ded73936ae3da1727f4879ab646c19af76
3
+ size 23485642
tagged/10M/qed.txt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6b92eda693ff3f59fce72387d538945ef859bce739798347f0eaffce0e6ffbdc
3
- size 29062685
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f2ef3c76591c24bdafed5890290a5d5a675483ce560f32d77b9dcf4164b7dbd
3
+ size 29062644
tagged/10M/switchboard.txt CHANGED
@@ -1,6 +1,4 @@
1
  switchboard.txt
2
- switchboard.txt
3
- .__<label>__. txt__<label>__NOUN
4
  i think the only people who benefit from that are the lawyers. oh, that's right. i work for a law firm i, i'm serious. and i think that the lawyers have caused a lot of the problems that exist in the in the criminal system today. with plea bargaining.
5
  i__<label>__PRON think__<label>__VERB the__<label>__DET only__<label>__NOUN people__<label>__NOUN who__<label>__PRON benefit__<label>__VERB from__<label>__ADP that__<label>__PRON are__<label>__VERB the__<label>__DET lawyers__<label>__NOUN .__<label>__. oh__<label>__NOUN ,__<label>__. that__<label>__PRON 's__<label>__VERB right__<label>__ADJ .__<label>__. i__<label>__PRON work__<label>__VERB for__<label>__ADP a__<label>__DET law__<label>__NOUN firm__<label>__NOUN i__<label>__PRON ,__<label>__. i__<label>__PRON 'm__<label>__VERB serious__<label>__ADJ .__<label>__. and__<label>__CONJ i__<label>__PRON think__<label>__VERB that__<label>__ADP the__<label>__DET lawyers__<label>__NOUN have__<label>__VERB caused__<label>__VERB a__<label>__DET lot__<label>__NOUN of__<label>__ADP the__<label>__DET problems__<label>__NOUN that__<label>__ADP exist__<label>__VERB in__<label>__ADP the__<label>__DET in__<label>__ADP the__<label>__DET criminal__<label>__ADJ system__<label>__NOUN today__<label>__NOUN .__<label>__. with__<label>__ADP plea__<label>__NOUN bargaining__<label>__VERB .__<label>__.
6
  right. you know, if someone is well plea plea bargaining is a different story. well. plea bargaining is something completely different.
 
1
  switchboard.txt
 
 
2
  i think the only people who benefit from that are the lawyers. oh, that's right. i work for a law firm i, i'm serious. and i think that the lawyers have caused a lot of the problems that exist in the in the criminal system today. with plea bargaining.
3
  i__<label>__PRON think__<label>__VERB the__<label>__DET only__<label>__NOUN people__<label>__NOUN who__<label>__PRON benefit__<label>__VERB from__<label>__ADP that__<label>__PRON are__<label>__VERB the__<label>__DET lawyers__<label>__NOUN .__<label>__. oh__<label>__NOUN ,__<label>__. that__<label>__PRON 's__<label>__VERB right__<label>__ADJ .__<label>__. i__<label>__PRON work__<label>__VERB for__<label>__ADP a__<label>__DET law__<label>__NOUN firm__<label>__NOUN i__<label>__PRON ,__<label>__. i__<label>__PRON 'm__<label>__VERB serious__<label>__ADJ .__<label>__. and__<label>__CONJ i__<label>__PRON think__<label>__VERB that__<label>__ADP the__<label>__DET lawyers__<label>__NOUN have__<label>__VERB caused__<label>__VERB a__<label>__DET lot__<label>__NOUN of__<label>__ADP the__<label>__DET problems__<label>__NOUN that__<label>__ADP exist__<label>__VERB in__<label>__ADP the__<label>__DET in__<label>__ADP the__<label>__DET criminal__<label>__ADJ system__<label>__NOUN today__<label>__NOUN .__<label>__. with__<label>__ADP plea__<label>__NOUN bargaining__<label>__VERB .__<label>__.
4
  right. you know, if someone is well plea plea bargaining is a different story. well. plea bargaining is something completely different.
tagged/10M/wikipedia.txt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:5414d9772d425532ba1689ac88266b0e8863673564fd5c6f96803129429903e2
3
- size 28653673
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b6e591bb825d0b7e589520bae1cea3c2a9b99d0dca71d58510601cde20ccd51e
3
+ size 28653652
tagged/dev/qed.txt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:43bb6072b65b56859f44900162ad049518bba3f84e96a978ffbae7a7222fa1f2
3
- size 26965217
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9e2c2159991a793460bdc2801186264560e182dcf4680152501ca67708ed637f
3
+ size 26965176
tagged/dev/switchboard.txt CHANGED
@@ -1,6 +1,4 @@
1
  switchboard.txt
2
- switchboard.txt
3
- .__<label>__. txt__<label>__NOUN
4
  uh-huh. so. i always thought that was kind of weird. yeah, it's funny how we, uh, we, we romanticize people uh-huh.
5
  uh__<label>__NOUN -__<label>__. huh__<label>__NOUN .__<label>__. so__<label>__DET .__<label>__. i__<label>__PRON always__<label>__PRON thought__<label>__VERB that__<label>__DET was__<label>__VERB kind__<label>__NOUN of__<label>__ADP weird__<label>__ADJ .__<label>__. yeah__<label>__NOUN ,__<label>__. it__<label>__PRON 's__<label>__VERB funny__<label>__ADJ how__<label>__ADP we__<label>__PRON ,__<label>__. uh__<label>__NOUN ,__<label>__. we__<label>__PRON ,__<label>__. we__<label>__PRON romanticize__<label>__VERB people__<label>__PRON uh__<label>__NOUN -__<label>__. huh__<label>__NOUN .__<label>__.
6
  like, for instance, where as the teenager, you know, you romance a, romanticize a rock star, but when he gets married, then you don't care any more or something like that, um, right. and i think it's the same with your characters on t v. do you think that's why most rock stars nowadays keep their marriages secret, or at least they keep it quiet.
 
1
  switchboard.txt
 
 
2
  uh-huh. so. i always thought that was kind of weird. yeah, it's funny how we, uh, we, we romanticize people uh-huh.
3
  uh__<label>__NOUN -__<label>__. huh__<label>__NOUN .__<label>__. so__<label>__DET .__<label>__. i__<label>__PRON always__<label>__PRON thought__<label>__VERB that__<label>__DET was__<label>__VERB kind__<label>__NOUN of__<label>__ADP weird__<label>__ADJ .__<label>__. yeah__<label>__NOUN ,__<label>__. it__<label>__PRON 's__<label>__VERB funny__<label>__ADJ how__<label>__ADP we__<label>__PRON ,__<label>__. uh__<label>__NOUN ,__<label>__. we__<label>__PRON ,__<label>__. we__<label>__PRON romanticize__<label>__VERB people__<label>__PRON uh__<label>__NOUN -__<label>__. huh__<label>__NOUN .__<label>__.
4
  like, for instance, where as the teenager, you know, you romance a, romanticize a rock star, but when he gets married, then you don't care any more or something like that, um, right. and i think it's the same with your characters on t v. do you think that's why most rock stars nowadays keep their marriages secret, or at least they keep it quiet.
tagged/test/qed.txt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7de66d6908250d7a5024a4bf1150a3e15efb80ead0a447f74aa361dd574c8ecc
3
- size 33511376
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:633e5955149474b4611cbcec2c3b01792f9f7f7b5ea43933e57e4fa129a0ac6d
3
+ size 33511335
tagged/test/switchboard.txt CHANGED
@@ -1,6 +1,4 @@
1
  switchboard.txt
2
- switchboard.txt
3
- .__<label>__. txt__<label>__NOUN
4
  huh. well, here in seattle, uh, it's the air's getting more and more polluted. we're, uh, we're in kind of a basin and, uh, seattle is on puget sound which is a inland waterway between two mountains. and, uh, there's been a lot, a lot of growth, population growth around here
5
  huh__<label>__NOUN .__<label>__. well__<label>__NOUN ,__<label>__. here__<label>__NOUN in__<label>__DET seattle__<label>__NOUN ,__<label>__. uh__<label>__NOUN ,__<label>__. it__<label>__PRON 's__<label>__VERB the__<label>__DET air__<label>__NOUN 's__<label>__VERB getting__<label>__VERB more__<label>__ADJ and__<label>__CONJ more__<label>__VERB polluted__<label>__VERB .__<label>__. we__<label>__PRON 're__<label>__VERB ,__<label>__. uh__<label>__NOUN ,__<label>__. we__<label>__PRON 're__<label>__VERB in__<label>__DET kind__<label>__NOUN of__<label>__ADP a__<label>__DET basin__<label>__NOUN and__<label>__CONJ ,__<label>__. uh__<label>__NOUN ,__<label>__. seattle__<label>__NOUN is__<label>__VERB on__<label>__ADP puget__<label>__PRON sound__<label>__NOUN which__<label>__PRON is__<label>__VERB a__<label>__DET inland__<label>__ADJ waterway__<label>__NOUN between__<label>__ADP two__<label>__NUM mountains__<label>__NOUN .__<label>__. and__<label>__CONJ ,__<label>__. uh__<label>__NOUN ,__<label>__. there__<label>__PRON 's__<label>__VERB been__<label>__VERB a__<label>__DET lot__<label>__NOUN ,__<label>__. a__<label>__DET lot__<label>__NOUN of__<label>__ADP growth__<label>__NOUN ,__<label>__. population__<label>__NOUN growth__<label>__NOUN around__<label>__ADP here__<label>__.
6
  and, uh, it's, uh, it's getting worse i think most of it is from cars. yeah. yeah. definitely.
 
1
  switchboard.txt
 
 
2
  huh. well, here in seattle, uh, it's the air's getting more and more polluted. we're, uh, we're in kind of a basin and, uh, seattle is on puget sound which is a inland waterway between two mountains. and, uh, there's been a lot, a lot of growth, population growth around here
3
  huh__<label>__NOUN .__<label>__. well__<label>__NOUN ,__<label>__. here__<label>__NOUN in__<label>__DET seattle__<label>__NOUN ,__<label>__. uh__<label>__NOUN ,__<label>__. it__<label>__PRON 's__<label>__VERB the__<label>__DET air__<label>__NOUN 's__<label>__VERB getting__<label>__VERB more__<label>__ADJ and__<label>__CONJ more__<label>__VERB polluted__<label>__VERB .__<label>__. we__<label>__PRON 're__<label>__VERB ,__<label>__. uh__<label>__NOUN ,__<label>__. we__<label>__PRON 're__<label>__VERB in__<label>__DET kind__<label>__NOUN of__<label>__ADP a__<label>__DET basin__<label>__NOUN and__<label>__CONJ ,__<label>__. uh__<label>__NOUN ,__<label>__. seattle__<label>__NOUN is__<label>__VERB on__<label>__ADP puget__<label>__PRON sound__<label>__NOUN which__<label>__PRON is__<label>__VERB a__<label>__DET inland__<label>__ADJ waterway__<label>__NOUN between__<label>__ADP two__<label>__NUM mountains__<label>__NOUN .__<label>__. and__<label>__CONJ ,__<label>__. uh__<label>__NOUN ,__<label>__. there__<label>__PRON 's__<label>__VERB been__<label>__VERB a__<label>__DET lot__<label>__NOUN ,__<label>__. a__<label>__DET lot__<label>__NOUN of__<label>__ADP growth__<label>__NOUN ,__<label>__. population__<label>__NOUN growth__<label>__NOUN around__<label>__ADP here__<label>__.
4
  and, uh, it's, uh, it's getting worse i think most of it is from cars. yeah. yeah. definitely.
tagged_gold/10M/aochildes.txt CHANGED
@@ -1,6 +1,6 @@
1
  aochildes.txt
2
  aboo.
3
- aboo__<label>__NOUN .__<label>__.
4
  kee. hey. smile? hm hm. smile.
5
  kee__<label>__NOUN .__<label>__. hey__<label>__NOUN .__<label>__. smile__<label>__NOUN ?__<label>__. hm__<label>__NOUN hm__<label>__NOUN .__<label>__. smile__<label>__NOUN .__<label>__.
6
  hi. aguh. mguh! mguh? abuabuabluabuh.
 
1
  aochildes.txt
2
  aboo.
3
+ .__<label>__.
4
  kee. hey. smile? hm hm. smile.
5
  kee__<label>__NOUN .__<label>__. hey__<label>__NOUN .__<label>__. smile__<label>__NOUN ?__<label>__. hm__<label>__NOUN hm__<label>__NOUN .__<label>__. smile__<label>__NOUN .__<label>__.
6
  hi. aguh. mguh! mguh? abuabuabluabuh.
tagged_gold/10M/gutenberg.txt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d7950cddea27874271968b42039312a0107fa4a51f9d13a308c299094dc30d20
3
- size 23461915
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c235931fa71429a33dde7ae09f0288a2fd4b1de5ac60b50825e38769cf4913e2
3
+ size 23461891
tagged_gold/10M/wikipedia.txt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:25e34611c9cce7451a78d5f0f7bdaf0bd13107b4da8f3fc89ad7056f030b4035
3
- size 28629899
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e74f6fd908f356a83d990565204f9b762cb3d90b2167f53701a30762432bb51b
3
+ size 28629878