update
Browse files- data/base/train.txt +2 -2
- generate_dataset.py +3 -55
data/base/train.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f9ad73eff3b05dd4715289e8fd12e7c60d67e3512591ec0d6497d66b3f9f5071
|
| 3 |
+
size 13398894
|
generate_dataset.py
CHANGED
|
@@ -1,55 +1,3 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
random.seed(10)
|
| 6 |
-
text_file = join(DATASETS_FOLDER, "VNESES", "VNESEScorpus.txt")
|
| 7 |
-
with open(text_file) as f:
|
| 8 |
-
lines = f.read().splitlines()
|
| 9 |
-
NUM_LONG_TOKENS = 50
|
| 10 |
-
NUM_SHORT_TOKENS = 20
|
| 11 |
-
NUM_MAX_TOKENS = 200
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
def longline_conditions(line):
|
| 15 |
-
if len(line) < NUM_LONG_TOKENS or len(line) > NUM_MAX_TOKENS:
|
| 16 |
-
return False
|
| 17 |
-
if not (line[0].isupper() and line[-1] == "."):
|
| 18 |
-
return False
|
| 19 |
-
return True
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
long_lines = [line for line in lines if longline_conditions(line)]
|
| 23 |
-
print("Short lines", len(long_lines))
|
| 24 |
-
|
| 25 |
-
def shortline_conditions(line):
|
| 26 |
-
if len(line) < NUM_SHORT_TOKENS:
|
| 27 |
-
return False
|
| 28 |
-
if len(line) > NUM_LONG_TOKENS:
|
| 29 |
-
return False
|
| 30 |
-
if not line[0].isupper():
|
| 31 |
-
return False
|
| 32 |
-
return True
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
short_lines = [line for line in lines if shortline_conditions(line)]
|
| 36 |
-
print("Short lines", len(short_lines))
|
| 37 |
-
|
| 38 |
-
print("Long lines", len(long_lines))
|
| 39 |
-
print("Short lines", len(short_lines))
|
| 40 |
-
|
| 41 |
-
pwd = dirname(__file__)
|
| 42 |
-
tmp = join(pwd, "data")
|
| 43 |
-
corpus_file = join(tmp, "UTS_Text_v1.txt")
|
| 44 |
-
|
| 45 |
-
with open(corpus_file, "w") as f:
|
| 46 |
-
lines = long_lines + short_lines
|
| 47 |
-
lines = lines[:1000]
|
| 48 |
-
content = "\n".join(lines)
|
| 49 |
-
f.write(content)
|
| 50 |
-
|
| 51 |
-
with open(join(tmp, "large", "train.txt"), "w") as f:
|
| 52 |
-
lines = long_lines + short_lines
|
| 53 |
-
lines = lines[:100000]
|
| 54 |
-
content = "\n".join(lines)
|
| 55 |
-
f.write(content)
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e081afb113d54028c79750db168e7aae9b7693a69452aff6d9bc3a84166c3d01
|
| 3 |
+
size 1434
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|