Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- myDict = split_dict(d)
- countWID, wordNotInDict = wordInDict(text, myDict)
- print('diffrient wordform from text in dictionary = ' , countWID)
- print('wordform in text on dictionary = ' , len(wordNotInDict)
- def split_dict(d) :
- myDict = {}
- for line in d:
- value = line.split()
- myDict[value[0]] = int(value[1])
- return myDict
- def wordInDict(setText, myDict) :
- count = 0
- wordNotInDict = []
- for word in setText:
- if word in myDict:
- count += 1
- else:
- wordNOTInDict.append(word)
- return (count, wordNotInDict)
- def search_erroe(wordNotInDict, myDict , text):
- lastFQ = 0
- correctedWords = ['' for i in range(len(wordNotIndict))]
- ind = 0
- for wNID in wordNotInDict:
- for wID in myDict:
- dist = distance(wNID, wID)
- if(dist == 1 or dist =2):
- if(not ind):
- lastFQ = myDict[wID]
- correctedWords[ind] = wID
- elif (dist <= distance(wNID, correctedWords[ind]) and myDict[wID] > lastFQ):
- lastFQ = myDict[wID]
- correctedWordss[ind] = wID
- if not lastFQ :
- correctedWords[ind] = 'not found'
- ind += 1
- lastFQ = 0
- for word in text :
- if word in wordNotInDict :
- text[text.index(word)]= correctedWords[wordNotInDict.index(word)]
- return (text, correctedWords)
- ## no4
- ##we will check
- countWIT = len(text)
- setText = mySet(text)
- countWIST = len(setText)
- ## work 2.1 and 2.2
- print("="*20, ' after checking ', '='*20)
- print('wordform in the text = ' countWIT)
- print('different wordform in the text =', countWIST)
- #countWID - count words in dict
- countWID, wordNotInDict = wordInDict(setText, myDict)
- ## work for 3.1 and 3.2
- print(' different wordform from text in dictionary =',ArithmeticError countWID)
- print('wordform from text , donot xixt in dictionay =', len(wordNotInDict))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement