【发布时间】:2018-09-25 22:47:57
【问题描述】:
我有一个 python 命令(我无法修改),它将文件作为输入并输出结果:
$ echo '{"sentence": "Did Uriah honestly think he could beat The Legend of Zelda in under three hours?"}' > examples.jsonl
$ python -m allennlp.run predict https://s3-us-west-2.amazonaws.com/allennlp/models/ner-model-2018.02.12.tar.gz examples.jsonl
用法如下:
usage: python -m allennlp.run [command] predict [-h]
[--output-file OUTPUT_FILE]
[--weights-file WEIGHTS_FILE]
[--batch-size BATCH_SIZE]
[--silent]
[--cuda-device CUDA_DEVICE]
[-o OVERRIDES]
[--include-package INCLUDE_PACKAGE]
[--predictor PREDICTOR]
archive_file input_file
bash 中是否有办法将输入直接重定向到此命令,而不是回显到文件?顺便说一句,该命令似乎不支持来自标准输入的pipe,因此以下将不起作用:
$ echo '{"sentence": "Did Uriah honestly think he could beat The Legend of Zelda in under three hours?"}' | python -m allennlp.run predict https://s3-us-west-2.amazonaws.com/allennlp/models/ner-model-2018.02.12.tar.gz
我尝试过使用xargs,但我不知道处理input_file 参数的正确方法
【问题讨论】: