GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — nlp_preprocessing/refine.py at master · YoungKwonJo/nlp_preprocessing Expand file tree/ Copy pathrefine.pyMore file actions executable file ·35 lines (24 loc) · 823 Bytes / Copy pathrefine.pyFile metadata and controlsexecutable file ·35 lines (24 loc) · 823 Bytes 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 import sys, fileinput, re, codecs def read_regex(fn): regexs = [] f = open(fn, 'r') for line in f: if not line.startswith("#"): tokens = line.split('\t') if len(tokens) == 1: tokens += [' '] tokens[0] = tokens[0][:-1] if tokens[0].endswith('\n') else tokens[0] tokens[1] = tokens[1][:-1] if tokens[1].endswith('\n') else tokens[1] regexs += [(tokens[0], tokens[1])] f.close() return regexs if __name__ == "__main__": fn = sys.argv[1] regexs = read_regex(fn) for line in sys.stdin: if line.strip() != "": for r in regexs: line = re.sub(r'%s' % r[0], r[1], line.strip()) sys.stdout.write(line + "\n") else: sys.stdout.write('\n') |
| 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. |