Labs/Ubiquity/Parser Documentation: Difference between revisions

Jump to navigation Jump to search
Line 52: Line 52:


=== Scoring the Quality of the Verb Match ===
=== Scoring the Quality of the Verb Match ===
([https://ubiquity.mozilla.com/hg/ubiquity-firefox/file/71b710040206/ubiquity/modules/parser/parser.js#l829|NLParser.Verb.match()] in parser.js)
The current heuristic is extremely ad-hoc, but produces the ordering we want... so far.
A perfect match between the input word and the verb name earns the maximum score, 1.0.
If the input word matches the beginning of the verb name, it gets a good score, between 0.75 and 1.0.  The more percentage of the verb name that is matched, the higher the score is within this range.  (All else being equal, this will rank short verb names before longer ones; I'm not sure this is really needed or correct.)
If the input word matches the verb name, but not at the beginning, (e.g.:  input is "cal", verb is "add-to-calendar") then it gets a score between 0.5 and 0.75, again scaled by the percentage of the verb name that is matched.
If the input word matches the beginning of a ''synonym'' of the verb name, it gets a score between 0.25 and 0.5.  (Note this means that any match to a synonym is ranked below any match to a primary name.)
If the input word matches a synonym of the verb name, but not at the beginning, it gets a score between 0 and 0.5.
No match at all gets a 0.
The algorithm doesn't currently recognize disjoint or out-of-order matches.  E.g. if the user typed "add cal", they might mean "add-to-calendar", and we might detect that fact if we did disjoint matches, but we don't so this will get a score of 0.  It might be worth experimenting with matches like this, but how to rank them?


=== Scoring the Frequency of the Verb Match ===
=== Scoring the Frequency of the Verb Match ===
1,007

edits

Navigation menu