Sha256: af5b7b6d011b87f3088345f9ac677d2d086e1cbfd5d9bbace60d1e1d09be97dd
Contents?: true
Size: 766 Bytes
Versions: 1
Compression:
Stored size: 766 Bytes
Contents
require 'sastrawi/stemmer/filter/text_normalizer' module Sastrawi module Stemmer class CachedStemmer attr_accessor :cache, :delegated_stemmer def initialize(cache, delegated_stemmer) @cache = cache @delegated_stemmer = delegated_stemmer end def stem(text) normalized_text = Sastrawi::Stemmer::Filter::TextNormalizer.normalize_text(text) words = normalized_text.split(' ') stems = [] words.each do |word| if @cache.has?(word) stems.push(@cache.get(word)) else stem = @delegated_stemmer.stem(word) @cache.set(word, stem) stems.push(stem) end end stems.join(' ') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sastrawi-0.1.0.pre | lib/sastrawi/stemmer/cached_stemmer.rb |