2014-12-03 79 views
-2

我已經玩過Python中的一些語言識別軟件包,雖然他們非常成功地區分了一般語言,但他們無法區分英式英語和美式英語。有沒有人遇到過一種可以用來識別這種差異的技術(用Python)?語言識別(英國和美國英語)

+0

字符'D = { '色': '美國', '色':' Redcoat'}':) – CoryKramer 2014-12-03 15:11:57

+2

請嘗試http://pythonhosted.org/pyenchant/ – 2014-12-03 15:14:54

回答

0

你可以使用正則表達式來檢查輔音+實例 「或」/ 「我們」,是這樣的:

import re 

txt="honor" 

re_american = re.compile(".*?[bcdfghjklmnptv](o)(r)",re.IGNORECASE|re.DOTALL) 
re_british = re.compile(".*?[bcdfghjklmnptv](o)(u)(r)",re.IGNORECASE|re.DOTALL) 

b = re_british.search(txt) 
a = re_american.search(txt) 

if b: print "British" 
elif a: print "American" 
相關問題