Ich möchte das Textfeld aus einem JSON Objcet eines Tweets extrahieren und es durch Syntaxnet ausführen. Ich mache alles in Python.Druckvariable in Shell-Befehl
Mein Code ist:
import os, sys
import subprocess
import json
def parse(text):
os.chdir("/var/www/html/alenza/hdfs/user/alenza/sree_account/sree_project/src/core/data_analysis/syntaxnet/models/syntaxnet")
#synnet_output = subprocess.check_output()
subprocess.call(["echo 'hello world' | syntaxet/demo.sh"], shell = True)
#print synnet_output
for line in sys.stdin:
line1 = json.loads(line)
text = line1['avl_lexicon_text']
print text
synnet_output = parse(text)
Statt nun echo 'hello world'
in parse
Funktion möchte ich text
dort ein Echo. Das heißt, ich möchte die text
Variable Datei zu füttern. Ich habe versucht, subprocess.call(["echo text | syntaxet/demo.sh"], shell = True)
zu tun, aber das hat nicht funktioniert. Wie kann ich das machen?
Arbeiten wie ein Charme. Vielen Dank! – kskp
Siehe auch http://StackOverflow.com/a/39619413/874188 – tripleee