nars.entity
Class Sentence

java.lang.Object
  extended by nars.entity.Sentence
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Judgment, Question

public abstract class Sentence
extends java.lang.Object
implements java.lang.Cloneable

A Sentence is an abstract class, mainly containing a Term, a TruthValue, and a Stamp.

It is used as the premises and conclusions of all inference rules.


Field Summary
protected  Judgment bestSolution
          For Question and Goal: best solution found so far
protected  Term content
          The content of a Sentence is a Term
protected  boolean input
          Whether it is an input sentence
protected  char punctuation
          The punctuation also indicates the type of the Sentence: Judgment, Question, or Goal
protected  Stamp stamp
          Partial record of the derivation path
protected  TemporalValue temporalOrder
          Temporal order between the components
protected  TruthValue truth
          The truth value of Judgment or desire value of Goal
 
Constructor Summary
Sentence()
           
 
Method Summary
 java.lang.Object clone()
          Clone the Sentence
 Term cloneContent()
          Clone the content of the sentence
 Judgment getBestSolution()
          Get the best-so-far solution for a Question or Goal
 Term getContent()
          Get the content of the sentence
 long getCreationTime()
          Get the creation time of the truth-value from the Stamp
 long getEventTime()
          Get the occurrence time of the event
 Stamp getStamp()
          Get the stamp of the sentence
 TemporalValue getTense()
          Get the tense of the Sentence
 TruthValue getTruth()
          Get the truth value of the sentence
 boolean isInput()
          Check input sentence
 boolean isJudgment()
          Distinguish Judgment from Goal ("instanceof Judgment" doesn't work)
static Sentence make(Sentence oldS, Term term, TruthValue truth, Stamp stamp, TemporalValue tense)
          Make a derived Sentence from a template and some initial values.
static Sentence make(Term term, char punc, TruthValue truth, Stamp stamp, TemporalValue tense)
          Make a Sentence from an input String.
 boolean noOverlapping(Sentence that)
          Check whether one sentence has stamp overlapping with another one, and change the system cash
 void setBestSolution(Judgment judg)
          Set the best-so-far solution for a Question or Goal
 void setContent(Term t)
          Set the content Term of the Sentence
 void setInput()
          The only place to change the default, called in StringParser
 java.lang.String tenseToString()
          Get a String representation of the tense of the sentence
 java.lang.String toKey()
          Get a stable String representation for a Sentece Different from toString: tense symbol is replaced by the actual value
 java.lang.String toString()
          Get a String representation of the sentence
 java.lang.String toString2()
          Get a String representation of the sentence, with 2-digit accuracy
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

content

protected Term content
The content of a Sentence is a Term


punctuation

protected char punctuation
The punctuation also indicates the type of the Sentence: Judgment, Question, or Goal


truth

protected TruthValue truth
The truth value of Judgment or desire value of Goal


stamp

protected Stamp stamp
Partial record of the derivation path


input

protected boolean input
Whether it is an input sentence


bestSolution

protected Judgment bestSolution
For Question and Goal: best solution found so far


temporalOrder

protected TemporalValue temporalOrder
Temporal order between the components

Constructor Detail

Sentence

public Sentence()
Method Detail

make

public static Sentence make(Term term,
                            char punc,
                            TruthValue truth,
                            Stamp stamp,
                            TemporalValue tense)
Make a Sentence from an input String. Called by StringParser.

Parameters:
term - The content of the sentence
punc - The puncuation (and therefore, type) of the sentence
tense - The tense of the sntense
truth - The truth value of the sentence, if it is a Judgment (or Goal)
stamp - The stamp of the truth value (for Judgment or Goal)
Returns:
the Sentence generated from the arguments

make

public static Sentence make(Sentence oldS,
                            Term term,
                            TruthValue truth,
                            Stamp stamp,
                            TemporalValue tense)
Make a derived Sentence from a template and some initial values. Called by Memory.

Parameters:
term - The content of the sentence
oldS - A sample sentence providing the type of the new sentence
tense - The tense of the sentence
truth - The truth value of the sentence, if it is a Judgment (or Goal)
stamp - The stamp of the truth value (for Judgment or Goal)
Returns:
the Sentence generated from the arguments

clone

public java.lang.Object clone()
Clone the Sentence

Overrides:
clone in class java.lang.Object
Returns:
The clone

getContent

public Term getContent()
Get the content of the sentence

Returns:
The content Term

cloneContent

public Term cloneContent()
Clone the content of the sentence

Returns:
A clone of the content Term

setContent

public void setContent(Term t)
Set the content Term of the Sentence

Parameters:
t - The new content

getTense

public TemporalValue getTense()
Get the tense of the Sentence

Returns:
The tense of the Sentence

getTruth

public TruthValue getTruth()
Get the truth value of the sentence

Returns:
Truth value, null for question

getStamp

public Stamp getStamp()
Get the stamp of the sentence

Returns:
The stamp

isJudgment

public boolean isJudgment()
Distinguish Judgment from Goal ("instanceof Judgment" doesn't work)

Returns:
Whether the object is a Judgment

isInput

public boolean isInput()
Check input sentence

Returns:
Whether the

setInput

public void setInput()
The only place to change the default, called in StringParser


getBestSolution

public Judgment getBestSolution()
Get the best-so-far solution for a Question or Goal

Returns:
The stored Judgment or null

setBestSolution

public void setBestSolution(Judgment judg)
Set the best-so-far solution for a Question or Goal

Parameters:
judg - The solution to be remembered

noOverlapping

public boolean noOverlapping(Sentence that)
Check whether one sentence has stamp overlapping with another one, and change the system cash

Parameters:
that - The sentence to be checked against
Returns:
Whether the two have overlapping stamps

toKey

public java.lang.String toKey()
Get a stable String representation for a Sentece Different from toString: tense symbol is replaced by the actual value

Returns:
String representation for a Sentece

toString

public java.lang.String toString()
Get a String representation of the sentence

Overrides:
toString in class java.lang.Object
Returns:
The String

toString2

public java.lang.String toString2()
Get a String representation of the sentence, with 2-digit accuracy

Returns:
The String

tenseToString

public java.lang.String tenseToString()
Get a String representation of the tense of the sentence

Returns:
The String

getCreationTime

public long getCreationTime()
Get the creation time of the truth-value from the Stamp

Returns:
The creation time of the truth-value

getEventTime

public long getEventTime()
Get the occurrence time of the event

Returns:
The occurrence time of the event