相关疑难解决方法(0)

在给定URL的情况下自动确定网站页面的自然语言

我正在寻找一种方法来自动确定网站页面使用的自然语言,并给出其URL.

在Python中,函数如下:

def LanguageUsed (url):
    #stuff
Run Code Online (Sandbox Code Playgroud)

返回语言说明符(例如,英语为'en',日语为'jp'等)

结果摘要:我有一个合理的解决方案,使用PyPi for oice.langdet中的代码在Python中工作.它在区分英语和非英语方面做得不错,这是我目前所需要的.请注意,您必须使用Python urllib获取html.另外,oice.langdet是GPL许可证.

有关使用Python中的Trigrams的更一般的解决方案,请参阅其他人建议的,请参阅ActiveState的Python Cookbook配方.

Google自然语言检测API运行良好(如果不是我见过的最好的).但是,它是Javascript和他们的TOS禁止自动使用它.

python url nlp web

9
推荐指数
2
解决办法
3977
查看次数

如何使用python单独获取英文推文?

这是我目前的代码

from twitter import *

t = Twitter(auth=OAuth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, 
        ACCESS_TOKEN, ACCESS_TOKEN_SECRET))

t.statuses.home_timeline()
query=raw_input("enter the query \n")
data = t.search.tweets(q=query)

for i in range (0,1000):    
    print data['statuses'][i]['text']
    print '\n'
Run Code Online (Sandbox Code Playgroud)

在这里,我从所有语言中获取推文.有没有办法限制自己只用英语提取推文?

python twitter nltk

6
推荐指数
1
解决办法
3413
查看次数

标签 统计

python ×2

nlp ×1

nltk ×1

twitter ×1

url ×1

web ×1