Guest User

Untitled

a guest
May 26th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment