PronounResolverPostProcessor.java
Go to the documentation of this file.
00001 package instruction.postprocessor;
00002 
00003 import instruction.semanticObjects.Instruction;
00004 import instruction.semanticObjects.ObjectX;
00005 import instruction.semanticObjects.Word;
00006 import java.util.List;
00007 
00008 public class PronounResolverPostProcessor implements PostProcessor {
00009 
00010         public void run( List<Instruction> instructions ) {
00011 
00012                 ObjectX lastObjectTalkedAbout = null;
00013                 for ( int i = 0; i < instructions.size(); i++ ) {
00014                         lastObjectTalkedAbout = resolvePronouns( instructions.get( i ), lastObjectTalkedAbout );
00015                 }
00016         }
00017 
00018         public ObjectX resolvePronouns( Instruction inst, ObjectX object ) {
00019 
00020                 ObjectX lastObjectTalkedAbout = object;
00021 
00022                 List<ObjectX> objects = inst.getObjects();
00023 
00024                 for ( int i = 0; i < objects.size(); i++ ) {
00025                         List<Word> objName = objects.get( i ).getName();
00026 
00031                         if ( objName.size() == 1 && objName.get( 0 ).getType() == Word.TYPE_PRONOUN ) {
00032                                 if ( lastObjectTalkedAbout == null ) {
00033                                         inst.getObjects().remove( i );
00034                                         i -= 1;
00035                                         continue;
00036                                 }
00037                                 else {
00038                                         inst.getObjects().remove( i );
00039                                         inst.getObjects().add( i, lastObjectTalkedAbout );
00040                                 }
00041                         }
00042                         else
00043                                 lastObjectTalkedAbout = objects.get( i );
00044 
00045                 }
00046 
00047                 return lastObjectTalkedAbout;
00048         }
00049 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


comp_ehow
Author(s): Moritz Tenorth, Daniel Nyga
autogenerated on Tue Apr 16 2013 00:18:03