Labs/Ubiquity/Parser Documentation: Difference between revisions

Jump to navigation Jump to search
Line 29: Line 29:
Once inside the language-specific plugin, things might happen in a different order depending on the language, but we'll keep focusing on the English case for now.
Once inside the language-specific plugin, things might happen in a different order depending on the language, but we'll keep focusing on the English case for now.


The English parser starts by finding the verb. Currently it does this by [https://ubiquity.mozilla.com/hg/ubiquity-firefox/file/71b710040206/ubiquity/modules/parser/locale_en.js#l135 splitting the input string on spaces], and taking the first word (i.e. everything up to the first space) as the verb.  In our example, <tt>trans</tt> is our verb, and <tt>hello world to ja</tt> is the rest of our sentence.
The English parser starts by finding the verb. Currently it does this by [https://ubiquity.mozilla.com/hg/ubiquity-firefox/file/71b710040206/ubiquity/modules/parser/locale_en.js#l135 splitting the input string on spaces], and taking the first word (i.e. everything up to the first space) as the verb.  In our example, <tt>"trans"</tt> is our verb, and <tt>["hello", "world", "to", "ja"</tt> is the rest of our sentence.


(Note: this simplistic way of getting the verb currently limits us to having only single-word command names.  It needs to be changed to support multi-word commands.  We also need to consider whether we want to support the case of the user entering the object first and the verb afterward.)
(Note: this simplistic way of getting the verb currently limits us to having only single-word command names.  It needs to be changed to support multi-word commands.  We also need to consider whether we want to support the case of the user entering the object first and the verb afterward.)
1,007

edits

Navigation menu