inpro.nlu
Class AVMUtil

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

public class AVMUtil
extends java.lang.Object

General AVM Utility for composition and resolution via unification.

Author:
okko

Field Summary
private static java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.lang.String>> avmStructures
          Variable for storing AVM structures.
private  java.util.ArrayList<AVM> composeList
          List of underspecified AVMs representing possible input (available to composition).
private  org.apache.log4j.Logger logger
          Logger for AVMUtil
private  java.util.ArrayList<AVM> resolvedList
          List of AVMs that resolved (a subset of worldList).
private  java.util.ArrayList<AVM> worldList
          List of fully specified AVMs representing world objects (available to resolution).
 
Constructor Summary
AVMUtil()
          Creates AVMUtil with a list of prototypes (avmStructures) of different typed AVMs and a local list of composed AVMs (composeList).
AVMUtil(AVMUtil c)
           
AVMUtil(java.lang.String structureFile)
          Creates AVMUtil with a list of prototypes (avmStructures) of different typed AVMs and a local list of composed AVMs (composeList).
AVMUtil(java.lang.String worldFile, java.lang.String structureFile)
          Creates AVMUtil with a list of prototypes (avmStructures) of different typed AVMs and a local list of composed AVMs (composeList).
 
Method Summary
 void allowAVMsByType(java.lang.String type)
          Allows only one type of AVM during composition.
 java.util.ArrayList<AVM> compose(AVPair avp)
          Method to call when a new AVPair becomes known.
 java.util.ArrayList<AVM> composeAll(java.util.List<AVPair> avPairs)
          Calls compose() for the list of AVPairs.
 java.lang.String composeListToString()
          Builds and returns a readable string representation of this AVMUtil's compose list.
 java.util.ArrayList<AVM> getAVMStructures()
          Returns a list of known AVM structures.
(package private) static void interactiveTest()
          Command line test utility.
static void main(java.lang.String[] args)
          Main method mostly for local testing.
private  void printComposeList()
          Prints out all known AVM prototypes.
 void resetAVMs()
          Resets AVMs used during composition.
 java.util.ArrayList<AVM> resolve()
          Tries to unify composed AVMs in composeList with known AVMs in worldList.
 java.lang.String resolveListToString()
          Builds and returns a readable string representation of this AVMUtil's resolve list.
 void setComposeList(java.util.ArrayList<AVM> avmList)
          Sets the list of AVMs available for composition.
 void setWorldList(java.util.ArrayList<AVM> avmList)
          Sets the list of AVMs available for resolution.
 java.lang.String toString()
          Builds and returns a string representation of this AVMUtil.
 java.util.ArrayList<AVM> uniquelyResolve()
          Resolves AVMs, returns a list of AVMs that resolved uniquely (i.e. there were no others of the same type that resolved).
 void unsetAVMs(java.lang.String type)
          Disallows AVM of a given type during composition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

avmStructures

private static java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.lang.String>> avmStructures
Variable for storing AVM structures.


worldList

private java.util.ArrayList<AVM> worldList
List of fully specified AVMs representing world objects (available to resolution).


composeList

private java.util.ArrayList<AVM> composeList
List of underspecified AVMs representing possible input (available to composition).


resolvedList

private java.util.ArrayList<AVM> resolvedList
List of AVMs that resolved (a subset of worldList).


logger

private org.apache.log4j.Logger logger
Logger for AVMUtil

Constructor Detail

AVMUtil

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

Throws:
java.net.MalformedURLException

AVMUtil

public AVMUtil(java.lang.String structureFile)
        throws java.net.MalformedURLException
Creates AVMUtil with a list of prototypes (avmStructures) of different typed AVMs and a local list of composed AVMs (composeList). Defaults to res/PentoAVMWorldList for world file.

Parameters:
structureFile - with list of AVM structures.
Throws:
java.net.MalformedURLException

AVMUtil

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

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

AVMUtil

public AVMUtil(AVMUtil 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 into composeList.

Parameters:
avp - the AVPair to compose with
Returns:
delta List of AVM that changed during update.

composeAll

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

Parameters:
avPairs - list of AVPairs to be composed
Returns:
delta List of AVMs that have changed during update.

resolve

public java.util.ArrayList<AVM> resolve()
Tries to unify composed AVMs in composeList with known AVMs in worldList. Loops through both lists and attempts unification. Returns successful cases.

Returns:
resolveList the new list of resolved AVMs

uniquelyResolve

public java.util.ArrayList<AVM> uniquelyResolve()
Resolves AVMs, returns a list of AVMs that resolved uniquely (i.e. there were no others of the same type that resolved).

Returns:
uniques List of AVPairs of AVM that resolved

getAVMStructures

public java.util.ArrayList<AVM> getAVMStructures()
Returns a list of known AVM structures.


resetAVMs

public void resetAVMs()
Resets AVMs used during composition.


allowAVMsByType

public void allowAVMsByType(java.lang.String type)
Allows only one type of AVM during composition. Disallows all others.

Parameters:
type - The type of AVM to allow

unsetAVMs

public void unsetAVMs(java.lang.String type)
Disallows AVM of a given type during composition. Allows all others.

Parameters:
type - The type of AVM to disallow

setComposeList

public void setComposeList(java.util.ArrayList<AVM> avmList)
Sets the list of AVMs available for composition.

Parameters:
avmList - the avmList to set

setWorldList

public void setWorldList(java.util.ArrayList<AVM> avmList)
Sets the list of AVMs available for resolution.

Parameters:
avmList - the list of AVMs in the world to set to

printComposeList

private void printComposeList()
Prints out all known AVM prototypes.


toString

public java.lang.String toString()
Builds and returns a string representation of this AVMUtil.

Overrides:
toString in class java.lang.Object
Returns:
string representation of this AVMUtil.

composeListToString

public java.lang.String composeListToString()
Builds and returns a readable string representation of this AVMUtil's compose list.

Returns:
string representation of this AVMUtil's compose list.

resolveListToString

public java.lang.String resolveListToString()
Builds and returns a readable string representation of this AVMUtil's resolve list.

Returns:
string representation of this AVMUtil's resolve list.

interactiveTest

static void interactiveTest()
                     throws java.io.IOException
Command line test utility. Type in AVPairs "attribute:value" to test composition. Type 'exit' to quit and 'new' to restart.

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