Simple parser

This commit is contained in:
Yohann D'ANELLO 2021-10-08 15:13:52 +02:00
parent ad5f1fa58b
commit ba7170e91c
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 28 additions and 1 deletions

View File

@ -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(): def main():
print("Hello world!") ns = parse_args()
parse(ns.input, ns.similarity)