Permalink
Browse files

Fixing exact matches even more

  • Loading branch information...
1 parent da4a42d commit dcaa5bc9d5819bfe7ef8c52591359e76b8c9cc60 Cameron Dutro committed Feb 12, 2013
@@ -17,8 +17,8 @@ def find_closest(goal_pattern)
nil
else
cache_key = TwitterCldr::Utils.compute_cache_key(goal_pattern)
- pattern_cache[cache_key] ||= if @pattern_hash.include?(goal_pattern)
- @pattern_hash[goal_pattern]
+ pattern_cache[cache_key] ||= if @pattern_hash.include?(goal_pattern.to_sym)
+ @pattern_hash[goal_pattern.to_sym]
else
rank(goal_pattern).min do |(p1, score1), (p2, score2)|
score1 <=> score2
@@ -4,6 +4,8 @@
# http://www.apache.org/licenses/LICENSE-2.0
require 'spec_helper'
+require 'pry'
+require 'pry-nav'
include TwitterCldr::Tokenizers
@@ -90,10 +92,10 @@
describe "#find_closest" do
it "returns an exact match if it exists" do
- selector.find_closest("h").should == "h"
- selector.find_closest("MMMd").should == "MMMd"
- selector.find_closest("Hms").should == "Hms"
- selector.find_closest("yQQQQ").should == "yQQQQ"
+ selector.find_closest("h").should == "h a"
+ selector.find_closest("MMMd").should == "MMM d"
+ selector.find_closest("Hms").should == "HH:mm:ss"
+ selector.find_closest("yQQQQ").should == "QQQQ y"
end
it "returns the next closest match (lowest score) if an exact match can't be found" do

0 comments on commit dcaa5bc

Please sign in to comment.