当前位置: 首页>>代码示例>>Python>>正文


Python SpellChecker.check方法代码示例

本文整理汇总了Python中enchant.checker.SpellChecker.check方法的典型用法代码示例。如果您正苦于以下问题:Python SpellChecker.check方法的具体用法?Python SpellChecker.check怎么用?Python SpellChecker.check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在enchant.checker.SpellChecker的用法示例。


在下文中一共展示了SpellChecker.check方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: spellCheck

# 需要导入模块: from enchant.checker import SpellChecker [as 别名]
# 或者: from enchant.checker.SpellChecker import check [as 别名]
def spellCheck(argument): 

	words =  len(argument)
	abbr = abb1 + abb2 + abb3
	#print words

	errors = 0                             
	chkr = SpellChecker("en_GB", argument)

	for word in argument:
		if chkr.check(word) == False:
			errors+=1
			if (chkr.check(word.upper()) == True) or (chkr.check(word.capitalize()) == True) or (chkr.check(word + ".") == True or (word in abbr)):
				errors-=1                                   

	outcome = (float(errors) / words)

	return outcome
开发者ID:lisanka93,项目名称:individualProject,代码行数:20,代码来源:ind_arguments.py

示例2: very_rare_long_words

# 需要导入模块: from enchant.checker import SpellChecker [as 别名]
# 或者: from enchant.checker.SpellChecker import check [as 别名]
def very_rare_long_words(debate, longwords):             #takes lemmatised debate and the long words and checks which one has a frequency distribution of 1

	fdist = FreqDist(debate)
	chkr = SpellChecker("en_GB", debate)

	very_rare = []

	for w in longwords:
		if fdist[w] < 2 and chkr.check(w) == True:
			very_rare.append(w.encode('utf-8'))

	return very_rare
开发者ID:lisanka93,项目名称:individualProject,代码行数:14,代码来源:whole_debate_func_clean.py

示例3: long_words

# 需要导入模块: from enchant.checker import SpellChecker [as 别名]
# 或者: from enchant.checker.SpellChecker import check [as 别名]
def long_words(debate):                                   #long words in debate

	lemmatised_words = debate

	long_words = [w for w in lemmatised_words if len(w) > 9]
	long_words = set(long_words)

	long_words_correct = []
	chkr = SpellChecker("en_GB", debate)                   #spellchecking

	for word in long_words:
		if chkr.check(word) == True:
			long_words_correct.append(word.encode('utf-8'))

	return long_words_correct                              #returns list of long words
开发者ID:lisanka93,项目名称:individualProject,代码行数:17,代码来源:whole_debate_func_clean.py

示例4: average_freqdist

# 需要导入模块: from enchant.checker import SpellChecker [as 别名]
# 或者: from enchant.checker.SpellChecker import check [as 别名]
def average_freqdist(argument, debate):
	argument = set(argument)
	arg_length = len(argument)
	fdist = FreqDist(debate)
	chkr = SpellChecker("en_GB", debate)

	frequency = 0

	for w in argument:
		if chkr.check(w) == True:
			frequency = frequency + fdist[w]

	average_frequency = float(frequency) / arg_length

	return average_frequency
开发者ID:lisanka93,项目名称:individualProject,代码行数:17,代码来源:ind_arguments.py

示例5: unusual_words

# 需要导入模块: from enchant.checker import SpellChecker [as 别名]
# 或者: from enchant.checker.SpellChecker import check [as 别名]
def unusual_words(text, mcs, google):    
    text = text.split()


    spellC = SpellChecker("en_GB")
    correct_words = []

    for w in text:
    	if w.isalpha():
    		correct = spellC.check(w)
    		if correct == True:
    			correct_words.append(w.encode('utf-8'))

    snowball = SnowballStemmer("english")

    delete_list = mcs + google

    stemmed_words = [snowball.stem(w) for w in correct_words]
    unusual_words = [w.encode('utf-8') for w in stemmed_words if w not in delete_list]
    unusual_words = set(unusual_words)
    unusual_words = list(unusual_words)
    
    return unusual_words                 
开发者ID:lisanka93,项目名称:individualProject,代码行数:25,代码来源:whole_debate_func_clean.py

示例6: open

# 需要导入模块: from enchant.checker import SpellChecker [as 别名]
# 或者: from enchant.checker.SpellChecker import check [as 别名]
flag = 0
for filename in filenames:
    with open(workdir+filedir+filename) as f:
        text = f.read()
        words = text.split()
           
    newwordslist = []
    i = 0
    for word in words:
        if re.search('[a-zA-Z]',word,flags=0) and word.endswith('-') and i<len(words)-1:
            newword = word[:-1] + words[i+1]
           # print word
            #print newword
            newwordstripped = re.search('\s*[a-zA-Z0-9]+',newword,flags=0).group(0)
            if chkr.check(newwordstripped):
                newwordslist.append(newword)
                flag = 1
            else:
                newwordslist.append(word[:-1])
        elif flag: #this is to control that we address the correct words in each iteration
            flag = 0
            i += 1
            continue
        else:    
            newwordslist.append(word)
        i += 1
    newtext = " ".join(newwordslist)
    with open(workdir+writedir+filename, 'w') as f:
        f.write(newtext)
开发者ID:vhulden,项目名称:genericsripts,代码行数:31,代码来源:fix-hyphenation.py


注:本文中的enchant.checker.SpellChecker.check方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。