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


Python TextBlob.correct方法代码示例

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


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

示例1: tokenize

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
def tokenize(text, spell=False, stem=False, lemma=False, lower=False, stop=False):
    # lowercase, remove non-alphas and punctuation
    b = TextBlob(unicode(text, 'utf8'))

    if spell:
        b = b.correct()
    words = b.words
    if lower:
        words = words.lower()
    if lemma:
        words = words.lemmatize()
    if stem:
        words = [stemmer.stem(w) for w in words]
    if stop:
        tokens = [w.encode('utf-8') for w in words if w.isalpha() and w not in stopwords]
    else:
        tokens = [w.encode('utf-8') for w in words if w.isalpha()]
    # letters_only = re.sub("[^a-zA-Z]", " ", text)

    # # ngrams
    # temp_list = []
    # for i in range(1,ngram+1):
    #     temp = [list(i) for i in TextBlob(' '.join(tokens)).ngrams(i)]
    #     try:
    #         if len(temp[0]) == 1:
    #             temp_list.extend([i[0] for i in temp])
    #         else:
    #             for i in temp:
    #                 temp_list.append(tuple(i))
    #     except:
    #         pass
    # return temp_list
    return tokens
开发者ID:potatochip,项目名称:kojak,代码行数:35,代码来源:text_processors.py

示例2: correctSpelling

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
def correctSpelling(text):
    '''
    Correcting the spelling of the words
    :param text: the input text
    :return: corrected the spelling in the words
    '''
    textBlob = TextBlob(text)

    return textBlob.correct()
开发者ID:manishdwibedy,项目名称:Top-Dishes-Zomato,代码行数:11,代码来源:spellingCorrection.py

示例3: correction

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
def correction():
    """Simple handler that parses a query parameter and returns a best-guess
    spelling correction using the TextBlob library.

    urls should take the form '/correction?text=some%20textt%20to%20corect'

    data returned will be a JSON object that looks like:
        {text: "some text to correct"}
    """
    text = request.args.get('text', '')
    text = TextBlob(text)
    return jsonify(text=unicode(text.correct()))
开发者ID:paddycarey,项目名称:speelchecker,代码行数:14,代码来源:app.py

示例4: post_process_review

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
def post_process_review(review_id):
    review = database.Review.get_one_by(id=review_id)
    if not review:
        return
    original_review_body = review.body

    # check for profanity
    review.profanity = profanity.contains_profanity(original_review_body)
    if review.profanity:
        review.profanity_not_removed_body = original_review_body
        review.body = profanity.censor(original_review_body)

    # sentiment analysis
    text_blob = TextBlob(original_review_body)
    review.sentiment_polarity = text_blob.sentiment.polarity
    review.sentiment_subjectivity = text_blob.sentiment.subjectivity
    review.spell_checked_body = unicode(text_blob.correct())

    # store
    database.add(review)
    database.push()
开发者ID:danieltcv,项目名称:product_reviews,代码行数:23,代码来源:create_reviews.py

示例5: correct_spelling

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
def correct_spelling(string):
    nlp = TextBlob(unicode(string, 'utf-8'))
    return nlp.correct()
开发者ID:jwmueller,项目名称:SemanticTextDB,代码行数:5,代码来源:NLPfunctions.py

示例6: len

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
        text=pytesseract.image_to_string(Image.open('final.jpg'))
        #Getting the text from the image using pytesseract
        if len(text)!=0:
            print(text)
            token=nltk.word_tokenize(text)
            l=len(token)
            list_sugg=[]
            for i in range(0,l):    
                print("...................")
                t_line=TextBlob(token[i])
                w_line=Word(token[i])
                l=w_line.spellcheck()
                length=len(l)
                print("are you looking for")
                for i in range(0,length):
                    print(str(i+1)+"->"+str(l[i][0]))
                
                print("according to me   :"+str(t_line.correct()))
                list_sugg.append(str(t_line.correct()))
            print("according to me......")    
            print(" ".join(list_sugg))
        #'q' for exit
        if cv2.waitKey(1) &0xFF == ord('q'):
            break
    except:
        break

#Exiting
cam.release()
cv2.destroyAllWindows()
开发者ID:NishantBaheti,项目名称:Handwriting-Recognition,代码行数:32,代码来源:hand_recog_correction.py

示例7: correct_learn

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
#def correct_learn():
    #correcnt and learn here
    

polarity_corr["cant"] = -0.25
polarity_corr["crashes"] = -0.25
print "test\n", polarity_corr["cant"]
input=TextBlob(raw_input("Statement goes here:\n"))

print "tag start ***"
for tag in input.tags:
    tag_list.append(tag[0])
    print(tag[0])
print "*** tag end"
input=input.correct()
#print "corrected-> ", input, "\n"
for sentence in input.sentences:
    print(sentence.sentiment)
    pol=(sentence.sentiment.polarity)
    sub=sentence.sentiment.subjectivity
    if(sentence.sentiment.polarity<0.0):
        print "negative"
        for lst in tag_list:
            #print lst
            if((lst.lower()) in bag2):
                print "\nKey area : ",lst, "\n"
            #bag2.index(lst.lower())
            #return 'a' in bag2
    
''''
开发者ID:shaktisuman,项目名称:Sentiment,代码行数:32,代码来源:sentyV2.py

示例8: clean_text

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
 def clean_text(self, text):
     blob = TextBlob(text.lower())
     return str(blob.correct())
开发者ID:half-adder,项目名称:politi-cli,代码行数:5,代码来源:politicalstream.py

示例9: TextBlob

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
from textblob import TextBlob
import sys

string_tocheck = TextBlob(sys.argv[1])
print string_tocheck.correct()
开发者ID:manglakaran,项目名称:TrafficKarmaSent,代码行数:7,代码来源:text_blob.py

示例10: translate

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
 def translate(english_word):
     english_blob = TextBlob(english_word)
     english_blob = english_blob.correct()
     return unicode(english_blob.translate('en', 'ar'))
开发者ID:HeshamElkhatib,项目名称:onthefly-dictionary,代码行数:6,代码来源:translator.py

示例11: input

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
Goolge = 'https://google.com'
Craigs = 'https://craigslist.org'
Cars = 'https://cars.com'

response = requests.get(Goolge)
response2 = requests.get(Craigs)

GoogleHtml = response.content
CraigsHtml = response2.content #dont really have a need for the raw html tho

BaseQuery = input("What exactly are you searching for ?")

NewBaseQuery = TextBlob(BaseQuery)#Have to make query a blob before we correct it
#BaseQuery.noun_phrases
print(NewBaseQuery.correct()) #attempts to correct any spelling errors
NewBaseQuery = NewBaseQuery.correct()
print("so you're looking for " + BaseQuery)


print(NewBaseQuery.words)
AutoGroup = ['auto', 'car', 'vehicle']
if any(word in AutoGroup for word in NewBaseQuery.words): #checks Autogroup against NewBaseQuery.words

    MakeQuery = input("Do you have a preference of Make?")
    #ModelQuery = input("Do you have a Model preference?")
    #CashValue = input("And exactly how much are you willing to spend?")
    Zip = input("And Lastly what is your zipcode?")

    Ibrowser = webdriver.Chrome()
    Ibrowser.get(Cars)
开发者ID:PrestonPerriott,项目名称:SimpleAutomation_TextBlob,代码行数:32,代码来源:InternetSearch.py

示例12: Word

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
# You can access the synsets for a Word via the synsets property or the get_synsets method, optionally passing in a part of speech.
word = Word("good")
print word.synsets
print Word("hack").get_synsets(pos=VERB)
print Word("octopus").definitions[1]
print Word("octopus").synsets

#word_dictinary('project')

# WordLists (A WordList is just a Python list with additional methods.)
animals = TextBlob("cat dog octopus")
print animals.words
print animals.words.pluralize()
# Spelling Correction (Use the correct() method to attempt spelling correction.)
b = TextBlob("I havv goood speling!")
print(b.correct())
w = Word('falibility')
print w.spellcheck()

# Get Word and Noun Phrase Frequencies
monty = TextBlob("We are no longer the Knights who say Ni. " "We are now the Knights who say Ekki ekki ekki PTANG.")
print monty.word_counts['ekki']
# The second way is to use the count() method.
print monty.words.count('ekki')
print monty.words.count('Ekki', case_sensitive=True)

# TextBlobs Are Like Python Strings
print zen.upper()

# You can make comparisons between TextBlobs and strings.
apple_blob = TextBlob('apples')
开发者ID:saimadhu-polamuri,项目名称:textblob_learn,代码行数:33,代码来源:textblob_basics.py

示例13: main

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
def main() : 
	sent = TextBlob("my name pras tean is")

	var = sent.correct()
	print var
开发者ID:prodicus,项目名称:srm_search_engine,代码行数:7,代码来源:var.py

示例14: spellcheck

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
def spellcheck(message):
	text = TextBlob(message)
	cc = ''+text.correct()
	response = {'crt' : cc}
	return jsonify(response)
开发者ID:vitthal10,项目名称:NLP,代码行数:7,代码来源:app.py

示例15: TextBlob

# 需要导入模块: from textblob import TextBlob [as 别名]
# 或者: from textblob.TextBlob import correct [as 别名]
blob.words
blob.noun_phrases

# sentiment analysis
blob = TextBlob('I hate this horrible movie. This movie is not very good.')
blob.sentences
blob.sentiment.polarity
[sent.sentiment.polarity for sent in blob.sentences]

# singularize and pluralize
blob = TextBlob('Put away the dishes.')
[word.singularize() for word in blob.words]
[word.pluralize() for word in blob.words]

# spelling correction
blob = TextBlob('15 minuets late')
blob.correct()

# spellcheck
Word('parot').spellcheck()

# definitions
Word('bank').define()
Word('bank').define('v')

# translation and language identification
blob = TextBlob('Welcome to the classroom.')
blob.translate(to='es')
blob = TextBlob('Hola amigos')
blob.detect_language()
开发者ID:AaronRanAn,项目名称:DAT3,代码行数:32,代码来源:14_nlp_class.py


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