Example #1
0
    def P(self, word):
        "Probability of `word`."

        return wf(word, 'en')
Example #2
0
 def WORDS(self, word):
     if wf(word, 'en') >= 1.0e-07:  #len(wn.synsets(word))>0:
         return (True)
     else:
         return (False)
Example #3
0
from wordfreq import word_frequency as wf
print(wf("beef", "en"))
Example #4
0
 def candidateGen(self,textList):
     city=[]
     state=[]
     country=[]
     geo=self.geo
     for textItem in textList:
         for item in textItem:
             if item in geo.stateDeAbbr:
                 
                 state.append([item,float(1)])
                 country.append(['united states',float(0.5)])
             if item.lower() in geo.stateAbbr:
                 
                 state.append([geo.stateAbbr[item.lower()],float(0.5)])
                 country.append(['united states',float(0.5)])
             
             if item in geo.iso2DeAbbr:
                 cand=geo.iso2DeAbbr[item]
                   
                 country.append([cand,float(1)])
                 
             if item in geo.iso3DeAbbr:
                 cand=geo.iso3DeAbbr[item]
                   
                 country.append([cand,float(1)])
           #              
             if item in geo.fipDeAbbr:
                 country.append([geo.fipDeAbbr[item],float(1)])
                         
             if item.lower() in geo.fipAbbr:
                 
                 c = geo.fipAbbr[item.lower()]
                 country.append([geo.fipDeAbbr[c],float(1)])
             
                     
             if item.lower() in geo.MLCountry and geo.MLCountry[item.lower()] in geo.fipDeAbbr:
             
                 c=geo.fipDeAbbr[geo.MLCountry[item.lower()]]
                 country.append([c,float(1)])
                 
         
             if item.lower() in geo.cityInState:
                 city.append([item.lower(),float(1)])
                 s={}
                 t=0
                 for i in geo.cityInState[item.lower()]:
                     s[i]=float(geo.cityNState[i][item.lower()])
                     t=t+float(geo.cityNState[i][item.lower()])
                 for i in geo.cityInState[item.lower()]:
                     state.append([i,s[i]/t])
                 
                 country.append(['united states',float(0.5)])    
                     
                 #state.append([i,/float(geo.totalCityNState)])                        
                     
                     
             if item.lower() in geo.cityInFIP:
                 if wf(item.lower(),'en')>0:
                     city.append([item.lower(),float(1)])
                     c={}
                     t=0
                     for i in geo.cityInFIP[item.lower()]:
                         
                         if i in geo.fipDeAbbr and i in geo.cityNCountry and item.lower() in geo.cityNCountry[i]:
                             c[i]=math.log(1/wf(item.lower(),'en'))*float(geo.cityNCountry[i][item.lower()])
                             t=t+math.log(1/wf(item.lower(),'en'))*float(geo.cityNCountry[i][item.lower()])
                     
                     for i in geo.cityInFIP[item.lower()]:
                        if i in geo.fipDeAbbr and i in c:                            
                             country.append([geo.fipDeAbbr[i],c[i]/t])
     
     candidateCity={}
     candidateState={}
     candidateCountry={}
     
     for c in city:
         if c[0] not in candidateCity:
             candidateCity[c[0]]=0
         candidateCity[c[0]]=candidateCity[c[0]]+c[1]
         
     for s in state:    
         if s[0] not in candidateState:
             candidateState[s[0]]=0
         candidateState[s[0]]=candidateState[s[0]]+s[1]
     for c in country:
         if c[0] not in candidateCountry:
             candidateCountry[c[0]]=0
         candidateCountry[c[0]]=candidateCountry[c[0]]+c[1]
     #print(candidateCity,candidateState,candidateCountry)    
     return(self.candidateResolution(candidateCity,candidateState,candidateCountry))
Example #5
0
    password=""
)

done=dict()
startTime=t.time()
while True:
    for submission in reddit.subreddit("india").new(limit=300):
        string=submission.title
        if string not in done:
            done[string]=True
            arr=[i for i in string.split(' ')]
            arr=sorted(arr, key=len, reverse=True)
            print(arr)
            comment=""
            for i in arr:
                print(i)
                usage=wf(i,"en")
                if (usage<0.00003 and usage!=0) or len(i)>7:
                    x=findMeaning(i)
                    if x!=None:
                        comment+=x+"\n"
            if comment!="":
                print("reply sent")
                submission.reply("[A Real user's application that autogenerates synonyms of some words] \n\n"+comment)
            print("[A Real user's application that autogenerates synonyms of some words] \n\n" +comment)

    if t.time-startTime>86400:
        done=dict()
        startTime=t.time()

print(findMeaning("Inadvertently"))