加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 如何提高速度与斯坦福NLP Tagger和NLTK

发布时间:2020-12-16 23:04:22 所属栏目:Python 来源:网络整理
导读:有什么办法可以更有效地使用Standford Tagger吗? 每个调用NLTK的包装器都会为每个分析的字符串启动一个新的java实例,这非常非常慢,特别是当使用更大的外语模型时… http://www.nltk.org/api/nltk.tag.html#module-nltk.tag.stanford 解决方法 找到解决方案.
有什么办法可以更有效地使用Standford Tagger吗?

每个调用NLTK的包装器都会为每个分析的字符串启动一个新的java实例,这非常非常慢,特别是当使用更大的外语模型时…

http://www.nltk.org/api/nltk.tag.html#module-nltk.tag.stanford

解决方法

找到解决方案.可以在servlet模式下运行POS Tagger,然后通过HTTP连接.完善.

http://nlp.stanford.edu/software/pos-tagger-faq.shtml#d

在后台启动服务器

nohup java -mx1000m -cp /var/stanford-postagger-full-2014-01-04/stanford-postagger.jar edu.stanford.nlp.tagger.maxent.MaxentTaggerServer -model /var/stanford-postagger-full-2014-01-04/models/german-dewac.tagger -port 2020 >& /dev/null &

调整防火墙仅限于从localhost访问端口2020

iptables -A INPUT -p tcp -s localhost --dport 2020 -j ACCEPT
iptables -A INPUT -p tcp --dport 2020 -j DROP

用wget测试

wget http://localhost:2020/?die welt ist sch?n

关机服务器

pkill -f stanford

恢复iptable设置

iptables -D INPUT -p tcp -s localhost --dport 2020 -j ACCEPT
iptables -D INPUT -p tcp --dport 2020 -j DROP

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读