com.senterre.lloyd
Class Lloyd

java.lang.Object
  extended bycom.senterre.lloyd.Lloyd
All Implemented Interfaces:
java.io.Serializable

public class Lloyd
extends java.lang.Object
implements java.io.Serializable

Lloyd is an object that can learn and an answer sentences. L.L.O.Y.D. (Learn Language Out Of Your Dialogs).

See Also:
Serialized Form

Constructor Summary
Lloyd()
          Class constructor.
Lloyd(int intelligibleLevel)
          Class constructor specifying the intelligble level.
 
Method Summary
 void addDocument(java.lang.String uri)
          Method to add a whole document to the Lloyd's brain.
 void addSentence(java.lang.String string)
          Method used to train Lloyd by feeding it with sentence(s).
 java.lang.String getSentence()
          This method returns a completly random sentence.
 java.lang.String getSentence(java.lang.String word)
          This method tries to return a sentence containing the "word"
 java.lang.String getSentence(java.lang.String[] words)
          Return a random sentence by determining which word may be the most significant from the given sentence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lloyd

public Lloyd()
Class constructor. It use a intelligible level of 3 by default.


Lloyd

public Lloyd(int intelligibleLevel)
Class constructor specifying the intelligble level. Level from 1 to 4 are the only possible values. Level 1 will generate sentences that will quickly have no senses. Level 2 will produce good results in short term. But as more text it'll learn, it'll lose it's good "sense". Level 3 seems to be a nice solution for medium-long term. But at the beginning it'll look like a parrot. Level 4 is extreme. I never really tried it, but in the (very?) long run maybe one of the most intelligible. But chances are it'll rarely generate random sentences. Only sentences it has learn before

Parameters:
intelligibleLevel - This is an integer value ranging from 1 to 4. 1 is the least intelligible, and 4 is the more intelligble.
Method Detail

getSentence

public java.lang.String getSentence()
This method returns a completly random sentence.

Returns:
a random sentence.

getSentence

public java.lang.String getSentence(java.lang.String word)
This method tries to return a sentence containing the "word"

Returns:
a random sentence containing "word" if it's possible.

getSentence

public java.lang.String getSentence(java.lang.String[] words)
Return a random sentence by determining which word may be the most significant from the given sentence. To determine which word is the most significant, Lloyd checks in it's memory to see the lengthy word that have the least links to other wordGroups

Parameters:
words - An array of words. Usually it's a sentence splitted in words.
Returns:
A sentence containing the most significant word from the given sentence.

addSentence

public void addSentence(java.lang.String string)
Method used to train Lloyd by feeding it with sentence(s). It takes the supplied sentence and simplified it as much as possible and split it in wordGroups and put them in memory

Parameters:
string - This is the string to feed LLoyd. It may contains more than one sentence it'll split it.

addDocument

public void addDocument(java.lang.String uri)
Method to add a whole document to the Lloyd's brain. It will take any text document and insert every sentences into his brain. Dialogs are good texts to put into memory. Novel may teach Lloyd some strange sentences to answer to people "talking" to it.

Parameters:
uri - Any URI to a readable document. Avoid HTML pages, only TEXT pages. You can also use local files like file:c:/toto.txt