Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Someone
Thursday, April 12th, 2012 at 12:59:09pm MDT 

  1.     words = urllib2.unquote(                                                                                                                                                                       
  2. 352             ' '.join(                                                                                                                                                                             
  3. 353                 open(os.path.join(base,'#asylum/out')).read().split('\n')[-20:])                                                                                                                   
  4. 354             ).replace('/',' ').replace('.',' ').split(' ')                                                                                                                                         
  5. 355     #drop common words, grabbed a list of 500 common english words                                                                                                                                 
  6. 356     words = filter(lambda ix: (len(ix) > 3) and (re.search(r"^[a-zA-Z]*$",ix)) and ix not in blacklist,words)                                                                                     
  7. 357     #user can supply optional term to add to the search list, add those in as if they were the most recent tokens                                                                                 
  8. 358     user_words = line[4:]                                                                                                                                                                         
  9. 359     words += user_words                                                                                                                                                                           
  10. 360     #if the user supplied terms they must be impoprtant. Let's add them in twice. Reverse the list to (nearly) equalize the bias for each.                                                         
  11. 361     user_words.reverse()                                                                                                                                                                           
  12. 362     words += user_words                                                                                                                                                                           
  13. 363     #score the tokens based on frequency and chronological order                                                                                                                                   
  14. 364     keys = {}                                                                                                                                                                                     
  15. 365     for ix in range(len(words)):                                                                                                                                                                   
  16. 366         word = words[ix]                                                                                                                                                                           
  17. 367         keys[word] = keys.get(word,0.0)+sqrt(log(ix+1))                                                                                                                                           
  18. 368

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
fantasy-obligation