Method: NGramPrefixDictionary#initialize
- Defined in:
- lib/rbbt/ner/ngram_prefix_dictionary.rb
#initialize(file, type = nil, case_insensitive = false) ⇒ NGramPrefixDictionary
Returns a new instance of NGramPrefixDictionary.
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/rbbt/ner/ngram_prefix_dictionary.rb', line 128 def initialize(file, type = nil, case_insensitive = false) @type = type @case_insensitive = case_insensitive case when (TSV === file or Hash === file) Log.debug("Ngram Prefix Dictionary. Loading of lexicon hash started.") @index = NGramPrefixDictionary.process_hash(file, case_insensitive) when Path === file Log.debug("Ngram Prefix Dictionary. Loading of lexicon file started: #{ file }.") @index = NGramPrefixDictionary.process_stream(file.open, case_insensitive) when Misc.is_filename?(file) Log.debug("Ngram Prefix Dictionary. Loading of lexicon file started: #{ file }.") @index = NGramPrefixDictionary.process_stream(Open.open(file)) when StreamIO === file Log.debug("Ngram Prefix Dictionary. Loading of lexicon stream started.") @index = NGramPrefixDictionary.process_stream(file, case_insensitive) else raise "Format of lexicon not understood: #{file.inspect}" end Log.debug("Ngram Prefix Dictionary. Loading done.") end |