Created
February 8, 2012 23:17
-
-
Save huned/1775313 to your computer and use it in GitHub Desktop.
String#stopword?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class String | |
| # via https://github.com/endax/stopwords/blob/master/lib/stopwords.rb | |
| STOP_WORDS = [ | |
| 'a','cannot','into','our','thus','about','co','is','ours','to','above', | |
| 'could','it','ourselves','together','across','down','its','out','too', | |
| 'after','during','itself','over','toward','afterwards','each','last','own', | |
| 'towards','again','eg','latter','per','under','against','either','latterly', | |
| 'perhaps','until','all','else','least','rather','up','almost','elsewhere', | |
| 'less','same','upon','alone','enough','ltd','seem','us','along','etc', | |
| 'many','seemed','very','already','even','may','seeming','via','also','ever', | |
| 'me','seems','was','although','every','meanwhile','several','we','always', | |
| 'everyone','might','she','well','among','everything','more','should','were', | |
| 'amongst','everywhere','moreover','since','what','an','except','most','so', | |
| 'whatever','and','few','mostly','some','when','another','first','much', | |
| 'somehow','whence','any','for','must','someone','whenever','anyhow', | |
| 'former','my','something','where','anyone','formerly','myself','sometime', | |
| 'whereafter','anything','from','namely','sometimes','whereas','anywhere', | |
| 'further','neither','somewhere','whereby','are','had','never','still', | |
| 'wherein','around','has','nevertheless','such','whereupon','as','have', | |
| 'next','than','wherever','at','he','no','that','whether','be','hence', | |
| 'nobody','the','whither','became','her','none','their','which','because', | |
| 'here','noone','them','while','become','hereafter','nor','themselves','who', | |
| 'becomes','hereby','not','then','whoever','becoming','herein','nothing', | |
| 'thence','whole','been','hereupon','now','there','whom','before','hers', | |
| 'nowhere','thereafter','whose','beforehand','herself','of','thereby','why', | |
| 'behind','him','off','therefore','will','being','himself','often','therein', | |
| 'with','below','his','on','thereupon','within','beside','how','once', | |
| 'these','without','besides','however','one','they','would','between','i', | |
| 'only','this','yet','beyond','ie','onto','those','you','both','if','or', | |
| 'though','your','but','in','other','through','yours','by','inc','others', | |
| 'throughout','yourself','can','indeed','otherwise','thru','yourselves' | |
| ] | |
| def stopword? | |
| self.class.stopword? self | |
| end | |
| def self.stopword? s | |
| @@stop_words_set ||= STOP_WORDS.to_set | |
| @@stop_words_set.member? s | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment