Mercurial > hip
changeset 9:d5699c104b48
Multiple word direct objects are now processed correctly, and the case where a preposition is treated as part of the direct object is now sorted to the end of the suggestion list.
author | jonathandicarlo@jonathan-dicarlos-macbook-pro.local |
---|---|
date | Wed, 14 May 2008 15:11:30 -0700 |
parents | 11a051a31077 |
children | 8f6b1c89d8de |
files | hip.js |
diffstat | 1 files changed, 14 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/hip.js Wed May 14 15:06:17 2008 -0700 +++ b/hip.js Wed May 14 15:11:30 2008 -0700 @@ -167,7 +167,7 @@ if ( this._DOType.match( directObject ) ) { // it's a valid direct object. Make a sentence for each // possible noun completion based on it; return them all. - suggestions = this._DOType.suggest( unusedWords[0] ); + suggestions = this._DOType.suggest( directObject ); for ( var x in suggestions ) { completions.push( new ParsedSentence( this, suggestions[x], filledMods ) ); @@ -197,20 +197,9 @@ } } } - - // If no match was found, all we'll return is one sentence formed by - // leaving that preposition blank. But even if a match was found, we - // still want to include this sentence as a possibility. - newFilledMods = dictDeepCopy( filledMods ); - newFilledMods[preposition] = ""; - directObject = unusedWords.join( " " ); - newCompletions = this.recursiveParse( unusedWords, - newFilledMods, - newUnfilledMods ); - completions = completions.concat( newCompletions ); - if ( matchIndices.length > 0 ) { - // Sentences that can be formed by using the match(es) for this + // Matches found for this preposition! Add to the completions list + // all sentences that can be formed using these matches for this // preposition. for ( x in matchIndices ) { var noun = unusedWords[ matchIndices[x]+1 ]; @@ -229,6 +218,17 @@ } } } + // If no match was found, all we'll return is one sentence formed by + // leaving that preposition blank. But even if a match was found, we + // still want to include this sentence as an additional possibility. + newFilledMods = dictDeepCopy( filledMods ); + newFilledMods[preposition] = ""; + directObject = unusedWords.join( " " ); + newCompletions = this.recursiveParse( unusedWords, + newFilledMods, + newUnfilledMods ); + completions = completions.concat( newCompletions ); + return completions; } }, @@ -544,6 +544,3 @@ ); }); -/* Minor problems: -2. multiple word direct objects are truncated to single word -*/