Solving of the arguments

时间:2019-01-07 13:46:12

标签: python nlp

After running the code, the error is as follows:

usage: text-summarizer.py [-h] [-l LENGTH] filepath
text-summarizer.py: error: the following arguments are required: filepath

I want to solve this issue by knowing how to input the file name to this piece of code mentioned :

def parse_arguments():
    parser = argparse.ArgumentParser()

    parser.add_argument("filepath", help="File name of text to summarize")
    parser.add_argument(
        "-l", "--length", default=4, help="Number of sentences to return"
    )
    args = parser.parse_args()
    return args

1 个答案:

答案 0 :(得分:0)

从控制台运行代码时,只需编写

python text-summarizer.py 'path/to/file' 

或者如果您使用python3:

python3 text-summarizer.py 'path/to/file'

其中“ path / to / file”实际上是您要汇总的路径(在计算机上)