Labs/Ubiquity/Parser Documentation: Difference between revisions

Jump to navigation Jump to search
Line 92: Line 92:
NLParser.PartiallyParsedSentence._suggestWithPronounSub() in parser.js
NLParser.PartiallyParsedSentence._suggestWithPronounSub() in parser.js


The algorithm used here is generic, so it's in the core parser; but the list of "magic pronouns" is language-specific, and therefore imported from the language plugin.  For instance, here's the list of English magic pronouns imported from ubiquity/modules/parser/locale_en.js:
EnParser.PRONOUNS = ["this", "that", "it", "selection", "him", "her", "them"];
If any of those words appear in the input, the PartiallyParsedSentence will attempt to substitute




Line 101: Line 106:


But we don't substitute the selection for the "it" that is part of the word "iterator", because we're using a regexp that only matches at word boundaries.
But we don't substitute the selection for the "it" that is part of the word "iterator", because we're using a regexp that only matches at word boundaries.
Because the substitution happens '''before''' the substring is passed to a noun_type for argument suggestion, it's possible to -- for instance -- select "ja", say "translate hello world to this", and get a suggestion of "translate hello world to japanese".


=== Filling missing arguments with the selection ===
=== Filling missing arguments with the selection ===
1,007

edits

Navigation menu