daily pastebin goal
90%
SHARE
TWEET

Untitled

a guest May 26th, 2018 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Sentence < Object
  2.        
  3.         def initialize( words, entry )
  4.             super()
  5.            
  6.             #
  7.             # Adjust punctuation
  8.             #
  9.             words.gsub!(/(,)(?!")/,'\1 ')
  10.             #words.gsub!(/"(\s*([^"]*?)\s*)"/,'&#8220;\1&#8221;')
  11.             words.gsub!(/\(\s*([^\)]*?)\s*\)/,'(\1)')
  12.            
  13.             #
  14.             # Split everything up
  15.             #
  16.             @bits = words.split(/\s+/);
  17.             if @bits == nil
  18.                 @bits = []
  19.             end
  20.            
  21.             @word_count = @bits.length
  22.            
  23.             #
  24.             # Does it contain the entry?
  25.             #
  26.             @word_index = []
  27.             for i in 0...@word_count
  28.                 if /(^|(.*?[^a-z]+))(#{entry})(?![a-z0-9])/i.match(@bits[i])
  29.                     @word_index.push(i)
  30.                 end
  31.             end
  32.         end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top