infofilter
Class FilterAgent

java.lang.Object
  |
  +--ciagent.CIAgent
        |
        +--infofilter.FilterAgent

public class FilterAgent
extends CIAgent

The FilterAgent class implements an agent which scores news articles using a keyword list, maintains a user profile, and filters articles

See Also:
Serialized Form

Field Summary
protected  boolean buildClusterNet
           
protected  boolean buildRatingNet
           
protected  KMapNet clusterNet
           
protected  boolean clusterNetTrained
           
static java.lang.String fileName
           
(package private)  InfoFilterFrame infoFilter
           
static java.lang.String INTERESTING_RATING
           
protected  java.lang.String[] keywords
           
static java.lang.String MILDLY_RATING
           
static java.lang.String NEUTRAL_RATING
           
static java.lang.String NOTVERY_RATING
           
protected  BackProp ratingNet
           
protected  boolean ratingNetTrained
           
static int USE_CLUSTERS
           
static int USE_KEYWORDS
           
static int USE_PREDICTED_RATING
           
static java.lang.String USELESS_RATING
           
 
Fields inherited from class ciagent.CIAgent
agentPlatform, children, DEFAULT_ASYNCTIME, DEFAULT_SLEEPTIME, name, parent, traceLevel
 
Constructor Summary
FilterAgent()
          Creates a FilterAgent object.
FilterAgent(java.lang.String name)
          Creates a FilterAgent object with the given name.
 
Method Summary
(package private)  void addAllArticlesToProfile(java.util.Vector articles)
          Appends the given set of articles to the profile.
(package private)  void addArticleToProfile(NewsArticle currentArt)
          Appends the given article to the profile.
 void buildClusterNet()
          Triggers an autonomous build of Kohonen Map.
 void buildRatingNet()
          Triggers an autonomous build of a back prop network.
(package private)  void computeClusterAverages(java.util.Vector articles)
          Computes the average score for each cluster and sets the score of each article in each cluster to that average value.
(package private)  int[] countWordMultiKeys(java.lang.String[] keys, java.lang.String text)
          Count the number of occurrences of the specified keys in the text.
 java.lang.String[] getKeywords()
          Retrieves the list of keywords in the FilterAgent profile.
 java.lang.String getTaskDescription()
          Retrieves the task description used for display purposes.
 void initialize()
          Initializes this agent by setting the sleep timer.
 boolean isClusterNetTrained()
          Indicates whether the cluster net is trained.
 boolean isRatingNetTrained()
          Indicates whether the rating net is trained.
 void process()
          Does nothing.
 void processCIAgentEvent(CIAgentEvent e)
          Processes a CIAgentEvent.
 void processTimerPop()
          Processes a timer pop by performing neural net training, if requested.
static FilterAgent restoreFromFile(java.lang.String fileName)
          Reads a serialized FilterAgent from the specified file.
 void saveToFile(java.lang.String fileName)
          Writes a serialized version of this FilterAgent to the specified file.
(package private)  void score(NewsArticle article, int filterType)
          Scores a single article.
(package private)  void score(java.util.Vector articles, int filterType)
          Scores all loaded articles using the given filter type.
 void setKeywords(java.lang.String[] keywords)
          Sets the list of keywords used in the FilterAgent profile.
 void status(java.lang.String msg)
          Sends a status event to all registered listeners.
(package private)  void trainClusterNet()
          Trains the cluster network.
(package private)  void trainRatingNet()
          Trains the rating network.
(package private)  void writeProfileDataDefinition()
          Writes the infoFilter metadata file (infofilter.dfn) that is read by the neural networks for training.
 
Methods inherited from class ciagent.CIAgent
addAgent, addCIAgentEventListener, addPropertyChangeListener, getAgent, getAgentPlatform, getAgents, getAsyncTime, getChildren, getCustomizerClass, getDisplayName, getName, getParent, getSleepTime, getState, getTraceLevel, notifyCIAgentEventListeners, postCIAgentEvent, processAsynchronousEvents, removeAgent, removeCIAgentEventListener, removePropertyChangeListener, reset, resumeAgentProcessing, setAgentPlatform, setAsyncTime, setName, setParent, setSleepTime, setState, setTraceLevel, startAgentProcessing, stopAgentProcessing, suspendAgentProcessing, trace
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

infoFilter

transient InfoFilterFrame infoFilter

keywords

protected java.lang.String[] keywords

clusterNet

protected KMapNet clusterNet

ratingNet

protected BackProp ratingNet

buildClusterNet

protected boolean buildClusterNet

clusterNetTrained

protected boolean clusterNetTrained

buildRatingNet

protected boolean buildRatingNet

ratingNetTrained

protected boolean ratingNetTrained

fileName

public static final java.lang.String fileName

USE_KEYWORDS

public static final int USE_KEYWORDS

USE_CLUSTERS

public static final int USE_CLUSTERS

USE_PREDICTED_RATING

public static final int USE_PREDICTED_RATING

USELESS_RATING

public static final java.lang.String USELESS_RATING

NOTVERY_RATING

public static final java.lang.String NOTVERY_RATING

NEUTRAL_RATING

public static final java.lang.String NEUTRAL_RATING

MILDLY_RATING

public static final java.lang.String MILDLY_RATING

INTERESTING_RATING

public static final java.lang.String INTERESTING_RATING
Constructor Detail

FilterAgent

public FilterAgent()
Creates a FilterAgent object.

FilterAgent

public FilterAgent(java.lang.String name)
Creates a FilterAgent object with the given name.
Parameters:
name - the String object that contains the name of this agent
Method Detail

getTaskDescription

public java.lang.String getTaskDescription()
Retrieves the task description used for display purposes.
Returns:
the String object that contains the task description
Overrides:
getTaskDescription in class CIAgent

initialize

public void initialize()
Initializes this agent by setting the sleep timer.
Overrides:
initialize in class CIAgent

process

public void process()
Does nothing.
Overrides:
process in class CIAgent

processTimerPop

public void processTimerPop()
Processes a timer pop by performing neural net training, if requested.
Overrides:
processTimerPop in class CIAgent

processCIAgentEvent

public void processCIAgentEvent(CIAgentEvent e)
Processes a CIAgentEvent.
Parameters:
e - the CIAgentEvent object to be processed
Overrides:
processCIAgentEvent in class CIAgent

getKeywords

public java.lang.String[] getKeywords()
Retrieves the list of keywords in the FilterAgent profile.
Returns:
a String[] of keywords

setKeywords

public void setKeywords(java.lang.String[] keywords)
Sets the list of keywords used in the FilterAgent profile.
Parameters:
keywords - a String[] that contains the list of keywords

buildClusterNet

public void buildClusterNet()
Triggers an autonomous build of Kohonen Map.

buildRatingNet

public void buildRatingNet()
Triggers an autonomous build of a back prop network.

isClusterNetTrained

public boolean isClusterNetTrained()
Indicates whether the cluster net is trained.
Returns:
true if the cluster net is trained and false if it is not

isRatingNetTrained

public boolean isRatingNetTrained()
Indicates whether the rating net is trained.
Returns:
true if the rating net is trained and false if it is not

score

void score(NewsArticle article,
           int filterType)
Scores a single article.
Parameters:
article - the NewsArticle object to be scored
filterType - the integer that indicates the type of filter (USE_KEYWORDS, USE_CLUSTERS, USE_PREDICTED_RATING)

score

void score(java.util.Vector articles,
           int filterType)
Scores all loaded articles using the given filter type.
Parameters:
articles - the vector of NewsArticles object to be scored
filterType - the integer that indicates the type of filter (USE_KEYWORDS, USE_CLUSTERS, USE_PREDICTED_RATING)

computeClusterAverages

void computeClusterAverages(java.util.Vector articles)
Computes the average score for each cluster and sets the score of each article in each cluster to that average value.
Parameters:
articles - the Vector object that contains the articles for which the cluster score is set

countWordMultiKeys

int[] countWordMultiKeys(java.lang.String[] keys,
                         java.lang.String text)
Count the number of occurrences of the specified keys in the text.
Parameters:
keys - the String[] objects that contain the keys
text - the String object that contains the text
Returns:
the int[] that contains the counts

writeProfileDataDefinition

void writeProfileDataDefinition()
Writes the infoFilter metadata file (infofilter.dfn) that is read by the neural networks for training. The current keywords are used as field names

addArticleToProfile

void addArticleToProfile(NewsArticle currentArt)
Appends the given article to the profile.
Parameters:
currentArt - the NewsArticle object to be added

addAllArticlesToProfile

void addAllArticlesToProfile(java.util.Vector articles)
Appends the given set of articles to the profile.
Parameters:
articles - the Vector object that contains the articles to be added

trainClusterNet

void trainClusterNet()
Trains the cluster network.

trainRatingNet

void trainRatingNet()
Trains the rating network.

status

public void status(java.lang.String msg)
Sends a status event to all registered listeners.
Parameters:
msg - the String that is the message portion of the status event

restoreFromFile

public static FilterAgent restoreFromFile(java.lang.String fileName)
                                   throws java.lang.ClassNotFoundException,
                                          java.io.IOException
Reads a serialized FilterAgent from the specified file.
Parameters:
fileName - the String object that contains the name of the file containing the serialized FilterAgent
Returns:
the de-serialized FilterAgent bean
Throws:
java.lang.ClassNotFoundException - if any class file is not found
java.io.IOException - on any IO exception

saveToFile

public void saveToFile(java.lang.String fileName)
Writes a serialized version of this FilterAgent to the specified file.
Parameters:
fileName - the String that contains the name of the file to write