Module: NGramDistance
- Extended by:
- FFI::Library
- Defined in:
- lib/ngramdistance.rb
Constant Summary collapse
- PROPOSITIONAL =
0
- BINARY =
1
- COMPLEX =
2
Class Method Summary collapse
- .distance(source, target, ngram = 3, mode = PROPOSITIONAL) ⇒ Object
- .token_set_distance(source, target, regex = ' ', ngram = 3, mode = PROPOSITIONAL) ⇒ Object
- .token_sort_distance(source, target, regex = ' ', ngram = 3, mode = PROPOSITIONAL) ⇒ Object
Class Method Details
.distance(source, target, ngram = 3, mode = PROPOSITIONAL) ⇒ Object
16 17 18 |
# File 'lib/ngramdistance.rb', line 16 def self.distance(source,target,ngram=3,mode=PROPOSITIONAL) distance_private(source,target,ngram,mode) end |
.token_set_distance(source, target, regex = ' ', ngram = 3, mode = PROPOSITIONAL) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/ngramdistance.rb', line 20 def self.token_set_distance(source,target,regex=' ',ngram=3,mode=PROPOSITIONAL) if source.nil? or target.nil? if(source == targer) return 1.0 end return 0.0 end return distance(token_set(source,regex),token_set(target,regex),ngram,mode) end |
.token_sort_distance(source, target, regex = ' ', ngram = 3, mode = PROPOSITIONAL) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/ngramdistance.rb', line 30 def self.token_sort_distance(source, target,regex=' ',ngram=3,mode=PROPOSITIONAL) if source.nil? or target.nil? if(source == targer) return 1.0 end return 0.0 end return distance(token_sort(source,regex),token_sort(target,regex),ngram,mode) end |