diff options
Diffstat (limited to 'lib/nlp_ruby/stringutil.rb')
-rw-r--r-- | lib/nlp_ruby/stringutil.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/nlp_ruby/stringutil.rb b/lib/nlp_ruby/stringutil.rb index 4091994..d7381bb 100644 --- a/lib/nlp_ruby/stringutil.rb +++ b/lib/nlp_ruby/stringutil.rb @@ -48,3 +48,8 @@ def read_cfg fn return cfg end +def bag_of_words s, stopwords=[] + s.strip.split.uniq.sort.reject{ |w| stopwords.include? w } +end + + |