Commit 2f9c64e8 authored by csillag's avatar csillag

Fix #361 and #362

parent 64fe2c13
......@@ -6,7 +6,7 @@
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: 2013-03-19 03:37:56Z
** Built at: 2013-04-09 22:10:46Z
*/
(function() {
......@@ -963,7 +963,7 @@
};
result = this.domMatcher.searchFuzzyWithContext(prefix, suffix, quote, expectedStart, expectedEnd, false, null, options);
if (!result.matches.length) {
console.log("Fuzzy matching did not return any results. Giving up.");
console.log("Fuzzy matching did not return any results. Giving up on two-phase strategy.");
return null;
}
match = result.matches[0];
......@@ -994,7 +994,7 @@
};
result = this.domMatcher.searchFuzzy(quote, expectedStart, false, null, options);
if (!result.matches.length) {
console.log("Fuzzy matching did not return any results. Giving up.");
console.log("Fuzzy matching did not return any results. Giving up on one-phase strategy.");
return null;
}
match = result.matches[0];
......
......@@ -197,6 +197,8 @@ class window.DomTextMatcher
analysis.exact or # "Found text matches exactly to pattern"
(analysis.comparison.errorLevel <= matchThreshold) # still acceptable
mappings = @mapper.getMappingsForCharRange prefixEnd, suffixStart
# Collect the results
match = {}
for obj in [charRange, analysis, mappings]
for k, v of obj
......@@ -248,18 +250,22 @@ class window.DomTextMatcher
textMatches = matcher.search @mapper.corpus, pattern, pos, options
t2 = @timestamp()
# Collect the mappings
matches = []
for textMatch in textMatches
do (textMatch) =>
# See how good a match we have
analysis = @analyzeMatch pattern, textMatch, fuzzyComparison
# Collect the mappings
mappings = @mapper.getMappingsForCharRange textMatch.start,
textMatch.end
# Collect the results
match = {}
for obj in [charRange, analysis, mappings]
for obj in [textMatch, analysis, mappings]
for k, v of obj
match[k] = v
matches.push match
null
t3 = @timestamp()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment