-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmateparsing.py
34 lines (24 loc) · 1.13 KB
/
mateparsing.py
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
############################################################
# Script for running mate-tools on the data
# Pre-requisites: 1. Java installed on your machine.
# 2. Install the mate-tools python wrapper from 'https://github.com/bjut-hz/py-mate-tools'
# Usage : python mateparsing.py [input_file] [output_path]
# Note : The output path must be a directory to which results.out is written. DON'T SPECIFY A FILE PATH HERE!!!
############################################################
import sys, os, codecs
from PyMateTools import matetools
INPUT_FILE = sys.argv[1]
OUTPUT_PATH = sys.argv[2]
OUTPUT_PATH = os.path.abspath(OUTPUT_PATH) # get the absolute path of the output file you want to write to
# Make the mate_tools object for calling the Python wrapper
mate_tools = matetools.MateTools()
# Read the file
print ("Reading the file ...")
data = []
with codecs.open(INPUT_FILE, 'r', encoding='utf-8') as f: #resolved utf-8 encoding issue with mate-tools...
for line in f:
data.append(line.strip())
# Do the parsing using mate-tools
print ("Parsing ...")
mate_tools.SRL( data, verbose = True, result_file_path = OUTPUT_PATH)
print ("Done.")