Using argparse
This commit is contained in:
parent
3dc69158b9
commit
5b75d6e4fa
26
wani.py
26
wani.py
|
@ -4,6 +4,7 @@ from enum import Enum
|
|||
from collections import defaultdict
|
||||
import sys
|
||||
import logging
|
||||
import argparse
|
||||
|
||||
from msd_translate import MSD_TRANSLATE
|
||||
|
||||
|
@ -11,10 +12,6 @@ from msd_translate import MSD_TRANSLATE
|
|||
MAX_NUM_COMPONENTS = 5
|
||||
|
||||
|
||||
STAVKI = sys.argv[1]
|
||||
STRUKTURE = sys.argv[2]
|
||||
FILE_OUT = sys.argv[3]
|
||||
|
||||
CODES = {
|
||||
"Noun": "N",
|
||||
"Verb": "V",
|
||||
|
@ -787,11 +784,12 @@ def main():
|
|||
import time
|
||||
t = time.time()
|
||||
|
||||
structures = build_structures(STRUKTURE)
|
||||
structures = build_structures(structures_file)
|
||||
for s in structures:
|
||||
logging.debug(str(s))
|
||||
|
||||
words = load_corpus(STAVKI)
|
||||
logging.info("LOADING TEXT...")
|
||||
words = load_corpus(input_file)
|
||||
# import pickle
|
||||
# with open("words.p", "wb") as fp:
|
||||
# pickle.dump(words, fp)
|
||||
|
@ -872,10 +870,18 @@ def main():
|
|||
# print(s.id)
|
||||
# print(groups)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
main()
|
||||
parser = argparse.ArgumentParser(description='Extract structures from a parsed corpus.')
|
||||
parser.add_argument('input', help='input xml file in `ssj500k form`')
|
||||
parser.add_argument('structures', help='Structures definitions in xml file')
|
||||
parser.add_argument('--output', help='Output file (if none given, then output to stdout)')
|
||||
|
||||
parser.add_argument('--lemma_only', help='Will not write word ids, forms and msds in output', action='store_true')
|
||||
parser.add_argument('--without-rep', help='Will not write representtaions in output', action='store_true')
|
||||
parser.add_argument('--group', help='Group collocations with same collocation ID', action='store_true')
|
||||
parser.add_argument('--verbose', help='Enable verbose output to stderr', choices=["warning", "info", "debug"], default="info")
|
||||
|
||||
args = parser.parse_args()
|
||||
logging.basicConfig(stream=sys.stderr, level=args.verbose.upper())
|
||||
|
||||
# 6, 7 primeri laznih zadetkov?
|
||||
|
|
Loading…
Reference in New Issue
Block a user