duanci5913 2017-05-01 13:28
浏览 53

Python程序没有从php执行

I developed a script to extract entities from the given text and script is executing fine.

python code:

   from nltk.tag import StanfordNERTagger
   from nltk.tokenize import word_tokenize
   with open('C:\\pythonScripts\\input.txt', 'r') as f:
       sample = f.read()
  import nltk
  def list_tokens(sampletext):
      nltk.internals.config_java("C:\\Program Files\\Java\\jdk1.8.0_131\\bin\\java.exe")

      classifier='C:\\Users\\gsrilakshmi.INDIA\\Desktop\\stanford\\stanford-ner-2016-10-31\\classifiers\\english.all.3class.distsim.crf.ser.gz'

      jar='C:\\Users\\gsrilakshmi.INDIA\\Desktop\\stanford\\stanford-ner-2016-10-31\\stanford-ner.jar'

      st = StanfordNERTagger(classifier,jar,encoding='utf-8')

     tokenized_text = word_tokenize(sampletext)
     classified_text = st.tag(tokenized_text)

     with open('C:\\pythonScripts\\output.txt', 'w') as fp:
        fp.write('
'.join('%s %s' % x for x in classified_text))

     return classified_text


tokens = list_tokens(sample)
print(tokens)

While calling the python script from php,the output file is not generated.

php code:

$pyscript = 'C:\\Python\Python36-32\python C:\pythonScripts\sample1.py';
$python = 'C:\Python\Python36-32\python.exe';

$p=exec($pyscript,$fulloutput);
exec("python  C:\\pythonScripts\\sample1.py > C:\\pythonScripts\\out.txt");

echo $p; I got the output: '[Found C:\Program Files\Java\jdk1.8.0_131\bin\java.exe: C:\Program Files\Java\jdk1.8.0_131\bin\java.exe]'

Please help me in solving this issue.

Thanks, Srilu

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 mars2d在vue3中的引入问题
    • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
    • ¥15 算法题:数的划分,用记忆化DFS做WA求调
    • ¥15 chatglm-6b应用到django项目中,模型加载失败
    • ¥15 CreateBitmapFromWicBitmap内存释放问题。
    • ¥30 win c++ socket
    • ¥15 C# datagridview 栏位进度
    • ¥15 vue3页面el-table页面数据过多
    • ¥100 vue3中融入gRPC-web
    • ¥15 kali环境运行volatility分析android内存文件,缺profile