inpro.nlu
Class AVMComposer

java.lang.Object
  extended by inpro.nlu.AVMComposer

public class AVMComposer
extends java.lang.Object

AVM Composer - Reads AVPairs. Attempts composition of new AVMs and unification of existing ones.

Author:
okko

Field Summary
private  java.util.ArrayList<AVM> avmList
           
private static java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.lang.String>> avmStructures
           
private  java.util.ArrayList<AVM> keepList
           
private  org.apache.log4j.Logger logger
           
private  java.util.ArrayList<AVM> resolvedList
           
private static java.util.ArrayList<AVM> worldList
           
 
Constructor Summary
AVMComposer()
          Creates AVMComposer with a list of prototypes (avmStructures) of different typed AVMs and a local list of composed AVMs (avmList).
AVMComposer(AVMComposer c)
           
AVMComposer(java.lang.String worldFile)
          Creates AVMComposer with a list of prototypes (avmStructures) of different typed AVMs and a local list of composed AVMs (avmList).
AVMComposer(java.lang.String structureFile, java.lang.String worldFile)
          Creates AVMComposer with a list of prototypes (avmStructures) of different typed AVMs and a local list of composed AVMs (avmList).
 
Method Summary
 java.util.ArrayList<AVM> compose(AVPair avp)
          Method to call when a new AVPair becomes known.
 void composeAll(java.util.List<AVPair> avPairs)
          Calls compose() for the list of AVPairs
 java.util.ArrayList<AVM> getAllAVMs()
          Returns list of AVMs known from AVM structures.
 java.util.ArrayList<AVM> getAvmList()
           
 java.util.ArrayList<AVM> getResolvedList()
          Returns list of resolved AVMs (ones with which input AVPairs could be unified.)
(package private) static void interactiveTest()
           
static void main(java.lang.String[] args)
          Main method mostly for local testing.
private  void printAVMs()
          Prints out all known AVMs.
 java.util.ArrayList<AVM> resolve()
          Method to resolve composed AVMs in avmList with known AVMs in worldList.
 void setAllAVMs()
          Sets prototype AVMs to be used for matching against (e.g. from new AVPairs).
 void setAvmList(java.util.ArrayList<AVM> avmList)
           
 void setAVMs(java.lang.String type)
          Sets only one type of AVM by creating a compose list of only that type.
 AVPair uniquelyResolve()
          Resolves AVMs, returns only a single AVPair of one AVM if one was resolved (else null).
 void unsetAVMs(java.lang.String type)
          Unsets AVM of a given type by removing them from avmList list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

avmStructures

private static java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.lang.String>> avmStructures

worldList

private static java.util.ArrayList<AVM> worldList

avmList

private java.util.ArrayList<AVM> avmList

resolvedList

private java.util.ArrayList<AVM> resolvedList

keepList

private java.util.ArrayList<AVM> keepList

logger

private org.apache.log4j.Logger logger
Constructor Detail

AVMComposer

public AVMComposer()
            throws java.net.MalformedURLException
Creates AVMComposer with a list of prototypes (avmStructures) of different typed AVMs and a local list of composed AVMs (avmList).

Throws:
java.net.MalformedURLException

AVMComposer

public AVMComposer(java.lang.String worldFile)
            throws java.net.MalformedURLException
Creates AVMComposer with a list of prototypes (avmStructures) of different typed AVMs and a local list of composed AVMs (avmList). Defaults to res/PentoAVMStructures for structure file.

Parameters:
worldFile - with list of AVMs in the world.
Throws:
java.net.MalformedURLException

AVMComposer

public AVMComposer(java.lang.String structureFile,
                   java.lang.String worldFile)
            throws java.net.MalformedURLException
Creates AVMComposer with a list of prototypes (avmStructures) of different typed AVMs and a local list of composed AVMs (avmList).

Parameters:
structureFile - with list of AVMstucture
worldFile - with list of AVMs in the world
Throws:
java.net.MalformedURLException

AVMComposer

public AVMComposer(AVMComposer c)
Method Detail

compose

public java.util.ArrayList<AVM> compose(AVPair avp)
Method to call when a new AVPair becomes known. Attempt unification with known AVM prototypes (from avmStructures) which incrementally grow with more input.

Parameters:
avp -

composeAll

public void composeAll(java.util.List<AVPair> avPairs)
Calls compose() for the list of AVPairs

Parameters:
avPairs - list of AVPairs to be composed

resolve

public java.util.ArrayList<AVM> resolve()
Method to resolve composed AVMs in avmList with known AVMs in worldList. Loops through both and attempts unification.

Returns:
resolveList the new list of resolved AVMs

uniquelyResolve

public AVPair uniquelyResolve()
Resolves AVMs, returns only a single AVPair of one AVM if one was resolved (else null).

Returns:
AVPair of AVM that resolved

getResolvedList

public java.util.ArrayList<AVM> getResolvedList()
Returns list of resolved AVMs (ones with which input AVPairs could be unified.)

Returns:
list of resolved AVMs

getAllAVMs

public java.util.ArrayList<AVM> getAllAVMs()
Returns list of AVMs known from AVM structures.


setAllAVMs

public void setAllAVMs()
Sets prototype AVMs to be used for matching against (e.g. from new AVPairs). getAllAVMs() sets these from known structures.


setAVMs

public void setAVMs(java.lang.String type)
Sets only one type of AVM by creating a compose list of only that type.

Parameters:
type -

unsetAVMs

public void unsetAVMs(java.lang.String type)
Unsets AVM of a given type by removing them from avmList list.

Parameters:
type -

printAVMs

private void printAVMs()
Prints out all known AVMs.


getAvmList

public java.util.ArrayList<AVM> getAvmList()
Returns:
the avmList

setAvmList

public void setAvmList(java.util.ArrayList<AVM> avmList)
Parameters:
avmList - the avmList to set

interactiveTest

static void interactiveTest()
                     throws java.io.IOException
Throws:
java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Main method mostly for local testing.

Parameters:
args -
Throws:
java.io.IOException