Labs/Ubiquity/Parser Documentation: Difference between revisions

Jump to navigation Jump to search
No edit summary
Line 37: Line 37:
=== Looking for a Verb Match ===
=== Looking for a Verb Match ===


The parser maintains a list of every command that's installed in Ubiquity, and the next step in the parsing process is to take the input verb and compare it to the name of each command to figure out which ones are potential matches, rank them by match quality, and eliminate the rest.
[https://ubiquity.mozilla.com/hg/ubiquity-firefox/file/71b710040206/ubiquity/modules/parser/locale_en.js#l146 EnParser.parseSentence() in local_en.js]


The parser maintains a list of every command that's installed in Ubiquity.  When parsing input, the main parser passes this list to the language-specific plugin along with the input and the selection (if any).
The next step in the parsing process is to take the input verb (which we found in the last step) and compare it to the name of each command to figure out which ones are potential matches.  (Note: this part is actually '''not''' language-specific, but it's done in the language-specific plugin for reasons of keeping the code relatively simple. In the future we may factor it out to the main parser.)
Each verb is scored against the input string, using the metric described in [https://wiki.mozilla.org/Labs/Ubiquity/Parser_Documentation#Scoring_the_Quality_of_the_Verb_Match Scoring the Quality of the Verb Match].  These scores will be used later to sort the suggestions in order from best to worst, but for now we only care whether a verb gets a score greater than zero.  Verbs that get a match quality score of 0 are discarded at this point, while anything with a positive number -- meaning it matches at all, no matter how tenuously -- continues to the next step.


=== Meanwhile: Parsing the Arguments ===
=== Meanwhile: Parsing the Arguments ===
1,007

edits

Navigation menu