Class: Semr::Dictionary

Inherits:
Object
  • Object
show all
Defined in:
lib/semr/dictionary.rb

Class Method Summary collapse

Class Method Details

.find_root(term) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/semr/dictionary.rb', line 12

def find_root(term)
  # TODO: Refactor
  # peoples => people
  # people => person
  # person => person DONE
  root = lookup(term)
  until root == term do
    term = root
    root = lookup(term)
  end
  root
end

.internal_dictionaryObject



4
5
6
# File 'lib/semr/dictionary.rb', line 4

def internal_dictionary
  @internal_dictionary ||= {}
end

.lookup(term) ⇒ Object



8
9
10
# File 'lib/semr/dictionary.rb', line 8

def lookup(term)
  internal_dictionary[term] || term
end

.register(term, root) ⇒ Object



25
26
27
28
# File 'lib/semr/dictionary.rb', line 25

def register(term, root)
  # puts "TERM: #{term}     ROOT: #{root}" if term == 'event' || root == 'event'
  internal_dictionary[term] = root
end