Class: Semr::Dictionary
- Inherits:
-
Object
- Object
- Semr::Dictionary
- Defined in:
- lib/semr/dictionary.rb
Class Method Summary collapse
- .find_root(term) ⇒ Object
- .internal_dictionary ⇒ Object
- .lookup(term) ⇒ Object
- .register(term, root) ⇒ Object
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_dictionary ⇒ Object
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 |