Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.96 KB | None | 0 0
  1. myDict = split_dict(d)
  2. countWID, wordNotInDict = wordInDict(text, myDict)
  3. print('diffrient wordform from text in dictionary = ' , countWID)
  4. print('wordform in text on dictionary = ' , len(wordNotInDict)
  5.       def split_dict(d) :
  6.       myDict = {}
  7.       for line in d:
  8.       value = line.split()
  9.       myDict[value[0]] = int(value[1])
  10.       return myDict
  11.  
  12.  
  13.       def wordInDict(setText, myDict) :
  14.       count = 0
  15.       wordNotInDict = []
  16.       for word in setText:
  17.       if word in myDict:
  18.       count += 1
  19.       else:
  20.       wordNOTInDict.append(word)
  21.       return (count, wordNotInDict)
  22.  
  23.  
  24.       def search_erroe(wordNotInDict, myDict , text):
  25.       lastFQ = 0
  26.       correctedWords = ['' for i in range(len(wordNotIndict))]
  27.       ind = 0
  28.       for wNID in wordNotInDict:
  29.       for wID in myDict:
  30.       dist = distance(wNID, wID)
  31.       if(dist == 1 or dist =2):
  32.       if(not ind):
  33.       lastFQ = myDict[wID]
  34.       correctedWords[ind] = wID
  35.       elif (dist <= distance(wNID, correctedWords[ind]) and myDict[wID] > lastFQ):
  36.       lastFQ = myDict[wID]
  37.       correctedWordss[ind] = wID
  38.       if not lastFQ :
  39.       correctedWords[ind] = 'not found'
  40.       ind += 1
  41.       lastFQ = 0
  42.       for word in text :
  43.       if word in wordNotInDict :
  44.       text[text.index(word)]= correctedWords[wordNotInDict.index(word)]
  45.       return (text, correctedWords)
  46.  
  47.  
  48.       ## no4
  49.       ##we will check
  50.       countWIT = len(text)
  51.       setText = mySet(text)
  52.       countWIST = len(setText)
  53.       ## work 2.1 and 2.2
  54.       print("="*20, ' after checking ', '='*20)
  55.       print('wordform in the text = ' countWIT)
  56.       print('different wordform in the text =', countWIST)
  57.       #countWID - count words in dict
  58.       countWID, wordNotInDict = wordInDict(setText, myDict)
  59.       ## work for 3.1 and 3.2
  60.       print(' different wordform from text in dictionary =',ArithmeticError countWID)
  61.       print('wordform from text , donot xixt in dictionay =', len(wordNotInDict))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement