Simple parser
This commit is contained in:
parent
ad5f1fa58b
commit
ba7170e91c
|
@ -1,2 +1,29 @@
|
|||
import argparse
|
||||
import sys
|
||||
|
||||
|
||||
def parse_args(argv: dict = None) -> argparse.Namespace:
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
|
||||
parser = argparse.ArgumentParser(description='Exercise 1')
|
||||
parser.add_argument('input', nargs='?', type=argparse.FileType('r'), help='Documents to read.', default=sys.stdin)
|
||||
parser.add_argument('similarity', nargs='?', type=float, help='Similarity threshold.', default=0.05)
|
||||
|
||||
return parser.parse_args(argv[1:])
|
||||
|
||||
|
||||
def parse(stream, similarity: float) -> None:
|
||||
with stream:
|
||||
for doc in stream:
|
||||
doc = doc.replace('\n', '')
|
||||
parse_doc(doc)
|
||||
|
||||
|
||||
def parse_doc(doc: str) -> None:
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
print("Hello world!")
|
||||
ns = parse_args()
|
||||
parse(ns.input, ns.similarity)
|
||||
|
|
Loading…
Reference in New Issue