GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — nlp_preprocessing/run_all_joongang.py at master · YoungKwonJo/nlp_preprocessing

Expand file tree

/

run_all_joongang.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
37 lines (27 loc) · 1.41 KB
/

run_all_joongang.py

Copy path

File metadata and controls

executable file
·
37 lines (27 loc) · 1.41 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sys, os, fileinput
DIR_PATH = './tmp/'
TMP_SRC_FN = DIR_PATH + 'joongang-en'
TMP_TGT_FN = DIR_PATH + 'joongang-ko'
DICT_FN = './data/enko.dict'
OUTPUT_FN = './data/joongang_daily.aligned.txt'
if __name__ == "__main__":
if not os.path.exists(DIR_PATH):
os.mkdir(DIR_PATH)
for line in fileinput.input():
parts = line.strip().split('\t')
if len(parts) < 3:
continue
parts[1] = parts[1].split('JoongAng Ilbo')[0]
if parts[2].endswith("기자") or parts[2].endswith("위원"):
parts[2] = (parts[2].split('.')[0]) if '.' in parts[2] else ''
f = open(TMP_SRC_FN + ".txt", 'w')
f.write(parts[1].strip())
f.close()
f = open(TMP_TGT_FN + ".txt", 'w')
f.write(parts[2].strip())
f.close()
os.system("cat %s.txt | python ./line_separator.py > %s.sep.txt" % (TMP_SRC_FN, TMP_SRC_FN))
os.system("cat %s.txt | python ./line_separator.py > %s.sep.txt" % (TMP_TGT_FN, TMP_TGT_FN))
os.system("python ./tokenizer.py < %s.sep.txt > %s.sep.tok.txt" % (TMP_SRC_FN, TMP_SRC_FN))
os.system("mecab --input-buffer-size=30000 -O wakati < %s.sep.txt > %s.sep.tok.txt" % (TMP_TGT_FN, TMP_TGT_FN))
os.system("python align.py --src %s.sep.txt --tgt %s.sep.txt --src_ref %s.sep.tok.txt --tgt_ref %s.sep.tok.txt --dict %s >> %s" % (TMP_SRC_FN, TMP_TGT_FN, TMP_SRC_FN, TMP_TGT_FN, DICT_FN, OUTPUT_FN))
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.