aminePlatform.util.parserGenerator
Class ObjectParsing

java.lang.Object
  extended byaminePlatform.util.parserGenerator.ObjectParsing
All Implemented Interfaces:
AmineConstants
Direct Known Subclasses:
CGIFParserGenerator, LFParserGenerator, OntologyTxtParser, PPCGParser

public class ObjectParsing
extends java.lang.Object
implements AmineConstants

Title : parserGenerator.ObjectParsing Class

Description : This class is concerned by Amine Object parsing.

Amine Object here means : an Integer, a Double, a Boolean, an Identifier, a String, a Variable, a Term, an AmineList, an AmineSet, a Concept or a CG.

This class offers methods that parse a String to recognize an Amine object (for instance, the method parseTerm() will fail if the String doesn't correspond to a term) and, optionnally, to produce and return the internal representation of the corresponding Amine Object.

Also, the class has methods to parse (and produce) Concept and CG from a Linear Form or from a CGIF form or from a textual formulation without any further specification about the used notation (Linear Form or CGIF). ObjectParsing is specialized into LFParserGenerator and CGIFParserGenerator subclasses to deal with CG Linear Notation and CG CGIF Notation respectively. ObjectParsing is specialized also by the Prolog+CG compiler.

NEW Amine 2.5, by Adil: In SYNERGY, a concept can play the role of a parameter;

an in or out parameter with a specific range. The two information are recorded in

the new attribute ParameterModes.

The syntax of a concept :

Old syntax of Concept

Concept ::= "[" Conc_Type [ParameterModes] [":" Designator]

["#" PseudoDesignator] [CoReferent] ["=" Descriptor] ["$" State] ["&" Point] "]"

New syntax of Concept, which integrates both the old syntax and recommandations of Standard CGIF

Concept ::= "[" [Comment] Conc_Type [ParameterModes (generate in EndComment)] [CoReferent]

[":"] [CoReferent] [Designator] [CoReferent] ["="] [Descriptor] [CoReferent]

["$" State (generate in EndComment)] ["&" Point (generate in EndComment)] [EndComment] "]"

Conc_Type ::= Type | Variable | ComposedType | Term

Designator ::= IndividualIdent | SetOfIndividualIdent | Variable

CoReferent ::= ("*" | "?") Variable

Descriptor ::= Amine_Object | Variable

ParameterModes ::= ("in" | "out") Integer.

State ::= A byte that represents the state of a concept, according to SYNERGY

Point ::= Integer Integer

Amine Structures Notation Grammar

Amine_Object_Var ::= Amine_Object | Variable .

Amine_Object ::= Elementary_Object | AmineList | AmineSet | Term | CG .

Elementary_Object ::= Integer | Double | Boolean | String | Identifier .

AmineList ::= "[" [ Amine_Object_Var ("," Amine_Object_Var)* [ "|" Variable] ] "]" .

AmineSet ::= "{" [ Elementary_Object ("," Elementary_Object)* ] "}" .

Term ::= Identifier "(" Amine_Object_Var ("," Amine_Object_Var)* ")" .

Identifier ::= Letter Letter (Character)* .

Variable ::= ( Letter [ (Digit | "_") (Character)* ] ) | ( "_" (Character)* ) .

Subclasses : LFParserGenerator, CGIFParserGenerator, prologPlusCG.ppcgCompiler.Compile

Copyright : Copyright (c) Adil KABBAJ 2004-2009


Field Summary
protected  boolean generateCode
          A boolean that indicates if the parsing should be completed by the production of the internal representation of the object parsed (value true) or not (i.e., do parsing only and in this case, generateCode is false).
protected  Variable genericCoref
           
protected  Lexicon lexicon
          The lexicon in use that will be consulted during the parsing.
protected  TextTokenizer txtTokenizer
          The text tokenizer that treats the text to parse
 
Fields inherited from interface aminePlatform.util.AmineConstants
ANALOGY, B_ASSIGN, B_DSPLY_WT_DELAY, B_DSPLY_WTT_DELAY, B_TRIGGER, B_WTT_DSPLY, BLOCK_BACKWARD_PROPAGATION, BLOCK_FORWARD_PROPAGATION, CANON, CGIF, CGRAPHIC, CHECK_PRECONDITIONS, COMPARE, COMPOSED_GOAL, CONCEPT_TYPE_IDENT, CONTEXT, COVERED_BY, CPLTE_CONTRACT, DEFINITION, EQ_OR_MORE_SPCFQ, EQUAL, EXPAND, FALSE_FOCUS_LIST, FUNCTIONAL, GENERALISE, GENERALIZE, HAVE_AN_INTERSECTION, ID_ADD, ID_DIV, ID_EQ, ID_INF, ID_IS, ID_MESSAGE, ID_MUL, ID_NOT, ID_NULL, ID_OPER_AND, ID_OPER_OR, ID_SUB, ID_SUP, IN_ACTIVATION, IN_MODE, IN_MODE2, INDIVIDUAL, INDIVIDUAL_IDENT, INTEGRATED, IS_CANONIC, KEY_GLOBAL_RULE, LC_ADD, LC_AMINE_BOOLEAN, LC_AMINE_DOUBLE, LC_AMINE_INTEGER, LC_AND, LC_BOOLEAN, LC_CG, LC_CLOSE_BRKT, LC_CLOSE_PARENT, LC_CLOSE_SET, LC_COMMA, LC_COMMA_SEMI, LC_CONCEPT, LC_CONSTRUCTOR, LC_CS, LC_CUT, LC_DIFF, LC_DIV, LC_DOUBLE, LC_DSBL_BKWRD_PRPGTN, LC_DSBL_FRWRD_PRPGTN, LC_EOF, LC_EQ, LC_FOUR_POINTS, LC_IDENTIFIER, LC_IF, LC_INF, LC_INTEGER, LC_INTEROG, LC_IS, LC_JAVA_OBJECT, LC_LEFT_ARROW, LC_LIST, LC_NULL, LC_OPEN_BRKT, LC_OPEN_PARENT, LC_OPEN_SET, LC_OPER_AND, LC_OPER_OR, LC_POINT, LC_RELATION, LC_RGHT_ARROW, LC_SEMI_COMMA, LC_SET, LC_STAR, LC_STATE, LC_STRING, LC_SUB, LC_SUP, LC_TERM, LC_TWO_POINTS, LC_VAR_LIST_CONSTRUCTOR, LC_VARIABLE, LF, MAXIMAL_JOIN, MORE_GENERAL, MORE_SPECIFIC, NOTHING_TO_INTEGRATE, OPERS_WITH_RSLT, OUT_MODE, OUT_MODE2, PARTIAL_CONTRACT, PARTIAL_SUBSUME, PRJCT_OPERS, PROJECT, READ, READ_SENTENCE, RELATION_TYPE_IDENT, S_AND, S_BOOLEAN, S_CG, S_CLOSE_BRKT, S_CLOSE_PARENT, S_CLOSE_SET, S_COMMA, S_CONCEPT, S_CONSTRUCTOR, S_CUT, S_DIFF, S_DOUBLE, S_EOF, S_EQUAL, S_EXPAND, S_FALSE, S_FOUR_POINTS, S_GENERALISE, S_GENERALIZE, S_IDENTIFIER, S_IF, S_INTEGER, S_INTEROG, S_IS, S_IS_CANONIC, S_LEFT_ARROW, S_LIST, S_MAXIMAL_JOIN, S_OPEN_BRKT, S_OPEN_PARENT, S_OPEN_SET, S_POINT, S_RGHT_ARROW, S_SEMI_COMMA, S_SOURCE, S_SPECIALIZE, S_STATE, S_STRING, S_SUBSUME, S_SUBSUME_WITH_RESULT, S_SUPER, S_TARGET, S_TERM, S_THIS, S_TRUE, S_TWO_POINTS, S_UNIFY, S_VARIABLE, SITUATION, SPECIALIZE, STEADY, SUBSUME, SUBSUME_WITH_RSLT, TRIGGER, UNCOMPARABLE, UNIFY, VAR_SUPER, WAIT_ASSIGNMENT, WAIT_END_OF_ASSIGNMENT, WAIT_PRECONDITIONS, WAIT_VALUE
 
Constructor Summary
ObjectParsing()
           
ObjectParsing(Lexicon lexicon)
          Construct an ObjectParsing object with the specified lexicon.
ObjectParsing(TextTokenizer txtTokenizer, Lexicon lexicon)
          Construct an ObjectParsing object with the specified lexicon for the parsing of a text that will be handled by the specified TextTokenizer.
 
Method Summary
protected  void addPseudoCorefs(CG cg, java.util.ArrayList concsWithPseudoCoref)
          To generate LF ou CGIF for the CG cg, addition of pseudo-coreferents, for some concepts, is required.
protected  int addPseudoCorefs(CG cg, java.util.ArrayList concsWithPseudoCoref, int indxSupCoref)
           
 java.lang.String conceptToString(BindingContext bindContext, Concept concept, java.lang.Object bindInf)
          Generate the textual formulation of a concept from its internal representation (the parameter concept).
 java.lang.String conceptToString(BindingContext bindContext, Concept concept, java.lang.Object bindInf, boolean complete, int indent)
          Generate the textual formulation of a concept from its internal representation (the parameter concept) taking ito account the variable binding.
(package private)  void deletePseudoCorefs(CG cg)
          Pseudo coreferents are coreferents that are used in LF or in CGIF to refeer to the same concept, in the same CG, from different locations/occurrences.
(package private)  void deletePseudoCorefs(CG cg, java.util.HashMap pseudoCorefConcepts)
           
protected  void deletePseudoDesignators(CG cg)
          delete pseudo-designators from any concept of the specified CG cg : replace the pseudo-designators by a null designator (null).
 byte determineCGForm()
          This method is the same as the method defined in this class with the same name except that this one assumes and operates on the current textTokenizer.
 byte determineCGForm(java.lang.String strgCG)
          Determine the nature of the CG form (Linear Form -LF- or CGIF) from the specified textual formulation (a String) of the CG strgCG.
 void finalize()
           
protected  void generateDesignator(BindingContext bindContext, java.lang.StringBuffer sConcept, java.lang.Object designator, java.lang.Object bindInf)
          Generate the textual formulation of the specified designator.
static java.lang.String getBlancsString(int nbrBlancs)
          Form a string of blanks, the number of blanks is specified by nbrBlancs
 boolean getGenerateCode()
          Get the value of the attribute generateCode associated to the current ObjectParsing
 Lexicon getLexicon()
          Get the lexicon associated to the current ObjectParsing
 TextTokenizer getTxtTokenizer()
          Get the TextTokenizer associated to the current ObjectParsing
 boolean getWithDrawingInf()
           
protected  boolean hasSeveralSuper(CG cg)
           
(package private)  boolean isAdditiveOper(byte tokenType)
           
(package private)  boolean isDescriptor(byte nxtTokenType)
           
 boolean isDesignator(byte nxtTokenType)
           
(package private)  boolean isInt(java.lang.String si)
           
(package private)  boolean isMultiplicativeOper(byte tokenType)
           
(package private)  boolean isNotOper(byte tokenType)
           
(package private)  boolean isParameterMode(java.lang.String s)
           
(package private)  boolean isRelationalOper(byte tokenType)
           
(package private)  java.lang.String parameterMode()
           
protected  AmineList parseAmineList()
          This method assumes that the textual formulation of the AmineList was already given to the textTokenizer of the current ObjectParsing and that lexical analysis was already done.
 AmineList parseAmineList(java.lang.String strgList)
          Parse the textual formulation of an Amine List (parameter strgList) and produce its internal representation.
protected  java.lang.Object parseAmineObject()
          This method is the protected version of the method parseAmineObject(String strgObj); it can be used by ObjectParsing's subclasses only since it assumes that some steps have been made and that the environment is already established.
 java.lang.Object parseAmineObject(java.lang.String strgObj)
          Parse the textual formulation of an Amine Object (parameter strgObj) and produce its internal representation.
protected  AmineSet parseAmineSet()
          This method assumes that the textual formulation of the AmineSet was already given to the textTokenizer of the current ObjectParsing and that lexical analysis was already done.
 AmineSet parseAmineSet(java.lang.String strgSet)
          Parse the textual formulation of an Amine Set (parameter strgSet) and produce its internal representation.
protected  CG parseCG()
          This method is overriden in LFParserGenerator and CGIFParserGenerator.
 CG parseCG(java.lang.String strgCG)
          Parse the textual formulation of a CG (parameter strgCG) and produce its internal representation.
 CG parseCG(java.lang.String strgCG, AmineList newTypes)
           
 CG parseCG(TextTokenizer textTokenizer)
          This method is similar to parseCG(String strgCG) except that its argument is a TextTokenizer that is already created for the treatment of strgCG; the textual formulation of a CG.
 CG parseCG(TextTokenizer textTokenizer, AmineList newTypes)
          This method is similar to parseCG(TextTokenizer) except that it considers the case where new concept types are encountered in the CG.
protected  java.lang.Object parseConcept()
          Parse the textual formulation of a concept and produce its corresponding internal representation if this step is intended (this is determined by the attribute generateCode : if true, the internal representation is produced, if false only the parsing is done).
protected  java.lang.Object parseConcept(CG cg)
          This method is a variant of the method parseConcept() defined in this class, except that the parsing is done in the context of a particular CG (the parameter cg).
 Concept parseConcept(java.lang.String strgConc)
          Parse the textual formulation of a Concept (parameter strgConc) and produce its internal representation.
(package private)  java.awt.Point parseConcPoint()
           
(package private)  Variable parseCoref(byte nxtTokenType)
           
 Variable parseCoreferent()
          Recognize a coreferent which should be a variable.
(package private)  byte parseCState()
           
 java.lang.Object parseDescriptor()
          Parse the descriptor of the current concept.
protected  java.lang.Object parseDesignator()
          Parse the concept designator that can be an individual identifier, a variable identifier or a set of individual identifiers.
protected  java.lang.Object parseExpression()
          Parsing of an Expression
(package private)  java.lang.Object parseExprTerm()
           
(package private)  java.lang.Object parseFactor()
           
protected  Term parseMessage()
           
(package private)  Identifier parseOperName(byte nxtTokenType)
           
protected  java.awt.Point parsePoint()
           
protected  java.lang.String parsePseudoDesignator()
          Recognize a pseudo-designator which could be an identifier or a number.
protected  java.lang.Object parseRelationType(java.lang.StringBuffer sBuffer)
          Parsing of a Relation Type
protected  void parseSegmentPoints(java.util.ArrayList segmentPoints)
           
static AmineList parseSentence(java.lang.String strgSentence)
          Parse the specified string that corresponds to a sentence and produce an AmineList with the words of the sentence as elements.
(package private)  java.lang.Object parseSimpleExpression()
           
protected  byte parseState()
          Recognize a state which is a byte.
(package private)  AmineSet parseStdSetDesignator(java.lang.Object designator)
           
protected  Term parseTerm()
          This method assumes that the textual formulation of the Term was already given to the textTokenizer of the current ObjectParsing and that lexical analysis was already done.
protected  Term parseTerm(boolean isMethod)
           
 Term parseTerm(java.lang.String strgTerm)
          Parse the textual formulation of a Term (parameter strgTerm) and produce its internal representation.
 void setGenerateCode(boolean generateCode)
          Set the specified generateCode as the associated generateCode for the current ObjectParsing.
 void setLexicon(Lexicon lexicon)
          Set the specified lexicon as the associated lexicon for the current ObjectParsing
 void setTxtTokenizer(TextTokenizer txtTokenizer)
          Set the specified txtTokenizer as the associated TextTokenizer for the current ObjectParsing
 void setWithDrawingInf(boolean withDrawInf)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

txtTokenizer

protected TextTokenizer txtTokenizer
The text tokenizer that treats the text to parse


lexicon

protected Lexicon lexicon
The lexicon in use that will be consulted during the parsing. It could be modified by getLexicon()/setLexicon() methods.


genericCoref

protected Variable genericCoref

generateCode

protected boolean generateCode
A boolean that indicates if the parsing should be completed by the production of the internal representation of the object parsed (value true) or not (i.e., do parsing only and in this case, generateCode is false).

Constructor Detail

ObjectParsing

public ObjectParsing()

ObjectParsing

public ObjectParsing(TextTokenizer txtTokenizer,
                     Lexicon lexicon)
              throws ParsingException
Construct an ObjectParsing object with the specified lexicon for the parsing of a text that will be handled by the specified TextTokenizer.

Parameters:
txtTokenizer - A TextTokenizer that will handle the text to parse
lexicon - The lexicon to use during the parsing
Throws:
ParsingException - if lexicon is null

ObjectParsing

public ObjectParsing(Lexicon lexicon)
              throws ParsingException
Construct an ObjectParsing object with the specified lexicon. Using this constructor for the creation of an ObjectParsing object, means that the text to parse will be provided as needed (in argument for a method of this class). A TextTokenizer will be created at this moment to treat the text.

Parameters:
lexicon - The lexicon to use during the parsing
Throws:
ParsingException - if lexicon is null
Method Detail

finalize

public void finalize()

getLexicon

public Lexicon getLexicon()
Get the lexicon associated to the current ObjectParsing

Returns:
the lexicon associated to the current ObjectParsing

setLexicon

public void setLexicon(Lexicon lexicon)
Set the specified lexicon as the associated lexicon for the current ObjectParsing

Parameters:
lexicon - A Lexicon

getTxtTokenizer

public TextTokenizer getTxtTokenizer()
Get the TextTokenizer associated to the current ObjectParsing

Returns:
the TextTokenizer associated to the current ObjectParsing

setTxtTokenizer

public void setTxtTokenizer(TextTokenizer txtTokenizer)
Set the specified txtTokenizer as the associated TextTokenizer for the current ObjectParsing


getGenerateCode

public boolean getGenerateCode()
Get the value of the attribute generateCode associated to the current ObjectParsing

Returns:
the value of the attribute generateCode associated to the current ObjectParsing

setGenerateCode

public void setGenerateCode(boolean generateCode)
Set the specified generateCode as the associated generateCode for the current ObjectParsing.

Parameters:
generateCode - : a boolean value for the attribute generateCode of the current ObjectParsing

getWithDrawingInf

public boolean getWithDrawingInf()

setWithDrawingInf

public void setWithDrawingInf(boolean withDrawInf)

parseAmineObject

public java.lang.Object parseAmineObject(java.lang.String strgObj)
                                  throws ParsingException
Parse the textual formulation of an Amine Object (parameter strgObj) and produce its internal representation. Recall that an Amine Object can be an Integer, a Double, a Boolean, an Identifier, a String, a Variable, a Term, an AmineList, an AmineSet, a Concept or a CG. This method is called in general on an ObjectParsing object that was created by the constructor ObjectParsing(Lexicon lexicon). Hence, the first step done by this method is to complete the setting of the ObjectParsing environment; it creates a TextTokenizer for strgObj and starts with a lexical analysis of the string, after that it performs a syntactic analysis and if both are successful, it performs the construction of the internal representation of the corresponding Amine Object. A 'stand alone' version of this method, called parse(), is defined in util.AmineObjects class.

Parameters:
strgObj - a textual formulation of an Amine Object
Returns:
the internal representation (Java Object) of the Amine Object. Returns null if strgObj is null or is empty
Throws:
throws - ParsingException if lexico-syntactic errors occurs during parsing
ParsingException

parseAmineObject

protected java.lang.Object parseAmineObject()
                                     throws ParsingException
This method is the protected version of the method parseAmineObject(String strgObj); it can be used by ObjectParsing's subclasses only since it assumes that some steps have been made and that the environment is already established. Since AmineList and Concept have the same delimiters; '[' and ']', some look ahead is in order. Even the first element after '[' can't desambiguite the situation in cases where the element can be a concept type. In such a case, the parser should look at the third element. One special case still remains : [Element] where Element can be a concept type. [Element] can be interpreted either as a list of one element or as a concept with concept type only. We adopt the first interpretation. To force the second interpretation, the user should specify a designator (a variable or a pseudo-designator).

Returns:
the internal representation (Java Object) of the Amine Object if generateCode is true and null otherwise.
Throws:
ParsingException - if errors occur during parsing

parseCG

public CG parseCG(java.lang.String strgCG)
           throws ParsingException
Parse the textual formulation of a CG (parameter strgCG) and produce its internal representation. This method is called in general on an ObjectParsing object that was created by the constructor ObjectParsing(Lexicon lexicon). Hence and like the method parseAmineObject(String strgObj), the first step done by this method is to complete the setting of the ObjectParsing environment; it creates a TextTokenizer for strgCG and starts with a lexical analysis of the string, after that it performs a syntactic analysis and if both are successful, it performs the construction of the internal representation of the corresponding CG. This method is common to LFParserGenerator and CGIFParserGenerator : after lexical analysis, syntactic analysis and production of the internal representation are done by a call to the method parseCG() which is overriden in LFParserGenerator and CGIFParserGenerator.

Parameters:
strgCG - a textual formulation of a CG
Returns:
the internal representation (Java Object) of the CG. Returns null if strgCG is null or is empty
Throws:
throws - ParsingException if lexico-syntaxic errors occurs during parsing
ParsingException

parseCG

public CG parseCG(java.lang.String strgCG,
                  AmineList newTypes)
           throws ParsingException
Throws:
ParsingException

parseCG

public CG parseCG(TextTokenizer textTokenizer)
           throws ParsingException
This method is similar to parseCG(String strgCG) except that its argument is a TextTokenizer that is already created for the treatment of strgCG; the textual formulation of a CG.

Parameters:
textTokenizer - a TextTokenizer to treat the parsing of a textual formulation of a CG
Returns:
the internal representation (Java Object) of the CG. Returns null if textTokenizer is null
Throws:
throws - ParsingException if lexico-syntaxic errors occurs during parsing
ParsingException

parseCG

public CG parseCG(TextTokenizer textTokenizer,
                  AmineList newTypes)
           throws ParsingException
This method is similar to parseCG(TextTokenizer) except that it considers the case where new concept types are encountered in the CG. New types nodes will be created for them and they will be added in newTypes.

Parameters:
textTokenizer - TextTokenizer
newTypes - AmineList
Returns:
CG
Throws:
ParsingException
Since:
20/01/06

parseCG

protected CG parseCG()
              throws ParsingException
This method is overriden in LFParserGenerator and CGIFParserGenerator. The present definition is relevant if the current ObjectParsing is neither a LFParserGenerator nor a CGIFParserGenerator. This method assumes that the textual formulation of the CG was already given to the textTokenizer of the current ObjectParsing and that lexical analysis was already done. It can be used by the ObjectParsing's subclasses only. This method parses the textual formulation of a CG and produce its corresponding internal representation (Java Object) if this step is intended (this is determined by the attribute generateCode : if true, the internal representation is produced, if false only the parsing is done). Since a CG could be expressed in a Linear form or in a CGIF form, the method will identify first the nature of the CG notation used and then call parseCG() of CGIFParserGenerator or parseCG() of LFParserGenerator according to the nature of the notation of the given CG. A 'stand alone' version of this method, called parse() is defined in cg.CG class, it receives the textual formulation of a CG as argument and produces its internal representation.

Returns:
the internal representation (Java Object) of the CG if generateCode is true and null otherwise
Throws:
ParsingException - if lexico-syntaxic errors occur during parsing

parseConcept

public Concept parseConcept(java.lang.String strgConc)
                     throws ParsingException
Parse the textual formulation of a Concept (parameter strgConc) and produce its internal representation. This method is called in general on a parseAmineObject object that was created by the constructor parseAmineObject(Lexicon lexicon). Hence, the first step done by this method is to complete the setting of the parseAmineObject environment; it creates a TextTokenizer for strgConc and starts with a lexical analysis of the string, after that it performs a syntaxic analysis and if both are successful, it performs the construction of the internal representation of the corresponding Concept. A 'stand alone' version of this method, called parse(), is defined in cg.Concept class.

Parameters:
strgConc - a textual formulation of a Concept
Returns:
the internal representation (Java Object) of the Concept. Returns null if strgConc is null or is empty
Throws:
throws - ParsingException if lexicon is null or if lexico-syntaxic errors occurs during parsing
ParsingException

parseConcept

protected java.lang.Object parseConcept()
                                 throws ParsingException
Parse the textual formulation of a concept and produce its corresponding internal representation if this step is intended (this is determined by the attribute generateCode : if true, the internal representation is produced, if false only the parsing is done). This method assumes that the textual formulation of the concept was already given to the textTokenizer of the current parseAmineObject. Indeed, this method assumes that some steps have been already made and that the environment is already established : the textual formulation of the concept was already associated to a TextTokenizer, lexical analysis was already done, etc. This method is called in general for a parseAmineObject object that was created by the constructor : parseAmineObject(TextTokenizer, Lexicon) and it is used in general by LFParserGenerator and CGIFParserGenerator classes.

Returns:
the internal representation (Java Object) of a Concept if generateCode is true and null otherwise.
Throws:
ParsingException - if txtTokenizer is null, if generateCode is true and lexicon is null and if errors occur during parsing

parseConcept

protected java.lang.Object parseConcept(CG cg)
                                 throws ParsingException
This method is a variant of the method parseConcept() defined in this class, except that the parsing is done in the context of a particular CG (the parameter cg). Hence, if the current concept to parse is a 'bound concept'; a reference to a concept already parsed in cg, then no new concept should be created, the refeered concept should be returned indeed. Also, the method considers the case where it is called from the context of a CGIF parsing, in this case the designator of the current concept should be returned.

Parameters:
cg - : a CG
Returns:
the internal representation (Java Object) of a Concept if generateCode is true and returns the designator of the recognized concept if generateCode is false.
Throws:
ParsingException - if txtTokenizer is null, if generateCode is true and lexicon is null and if errors occur during parsing

isParameterMode

boolean isParameterMode(java.lang.String s)

parameterMode

java.lang.String parameterMode()
                         throws ParsingException
Throws:
ParsingException

parseCoref

Variable parseCoref(byte nxtTokenType)
              throws ParsingException
Throws:
ParsingException

isDescriptor

boolean isDescriptor(byte nxtTokenType)

parseDesignator

protected java.lang.Object parseDesignator()
                                    throws ParsingException
Parse the concept designator that can be an individual identifier, a variable identifier or a set of individual identifiers. It can be also a ComposedDesignator. To satisfy CGIF parsing, parseDesignator will generate the internal form of a designator even if generateCode is false (only parsing is required without producing the internal representation).

Returns:
the internal representation of the concept designator
Throws:
ParsingException - if txtTokenizer is null, or lexicon is null or errors occur during parsing

parseStdSetDesignator

AmineSet parseStdSetDesignator(java.lang.Object designator)
                         throws ParsingException
Throws:
ParsingException

isDesignator

public boolean isDesignator(byte nxtTokenType)

parsePseudoDesignator

protected java.lang.String parsePseudoDesignator()
                                          throws ParsingException
Recognize a pseudo-designator which could be an identifier or a number.

Returns:
the recognized pseudo-designator
Throws:
ParsingException - if errors occur during parsing

parseCState

byte parseCState()
           throws ParsingException
Throws:
ParsingException

parseState

protected byte parseState()
                   throws ParsingException
Recognize a state which is a byte.

Returns:
the recognized state
Throws:
ParsingException - if errors occur during parsing

parseCoreferent

public Variable parseCoreferent()
                         throws ParsingException
Recognize a coreferent which should be a variable.

Returns:
the recognized coreferent if generateCode is true and null otherwise
Throws:
ParsingException - if errors occur during parsing

parseDescriptor

public java.lang.Object parseDescriptor()
                                 throws ParsingException
Parse the descriptor of the current concept. Since the descriptor is any Amine Object, this method corresponds to a call to the method parseAmineObject().

Returns:
the Object if generateCode is true and null otherwise
Throws:
ParsingException - if txtTokenizer is null, if generateCode is true and lexicon is null and if errors occur during parsing

parseConcPoint

java.awt.Point parseConcPoint()
                        throws ParsingException
Throws:
ParsingException

conceptToString

public java.lang.String conceptToString(BindingContext bindContext,
                                        Concept concept,
                                        java.lang.Object bindInf)
                                 throws ToStringException
Generate the textual formulation of a concept from its internal representation (the parameter concept). This method is called in general on an ObjectParsing object (or a subclass of it) that was created by the constructor ObjectParsing(lexicon). Two 'stand alone' versions of this method, called toCGIF() and toLF(), are defined in cg.Concept class.

Parameters:
bindContext - The Binding context
concept - A Concept
bindInf - The binding information related to the binding context and to concept
Returns:
the textual formulation of concept, or null if concept or lexicon is null.
Throws:
throws - ToStringException if no identifier is associated to a CS in the specified lexicon (and in the main language to, if mixed language is allowed).
ToStringException

conceptToString

public java.lang.String conceptToString(BindingContext bindContext,
                                        Concept concept,
                                        java.lang.Object bindInf,
                                        boolean complete,
                                        int indent)
                                 throws ToStringException
Generate the textual formulation of a concept from its internal representation (the parameter concept) taking ito account the variable binding. This method is common to (and used by) LFParserGenerator and CGIFParserGenerator subclasses of ObjectParsing. The method is called in general on an ObjectParsing object (especially, a subclass of it) that was created by the constructor ObjectParsing(lexicon). The method differentiate between a complete description of the concept (parameter complete is true) and partial description (the parameter complete is false); the second case concerns a 'bound' concept, i.e. a concept that is a reference to an already formulated concept. In partial description, coreference and descriptor of the concept are not specified. The method considers also the indentation of the textual formulation, to have a pretty-print effect.

Parameters:
bindContext - The Binding context
concept - A Concept
bindInf - The binding information related to the binding context and to concept
complete - a boolean : if true, the description will be complete, else it will be partial
indent - an integer that specifies the required indentation
Returns:
the textual formulation of concept, or null if concept, lexicon is null.
Throws:
ToStringException - if concept or lexicon is null or no identifier is associated to a CS in the current lexicon (and in the main language to, if mixed language is allowed).

generateDesignator

protected void generateDesignator(BindingContext bindContext,
                                  java.lang.StringBuffer sConcept,
                                  java.lang.Object designator,
                                  java.lang.Object bindInf)
                           throws ToStringException
Generate the textual formulation of the specified designator. The textual formulation is added to the specified StringBuffer sConcept. This method is used to generate the designator of the concept and it is used also by CGIFParserGenerator subclass to generate the argument of a relation.

Parameters:
bindContext - The Binding context
sConcept - a StringBuffer that will contain the textual formulation of the whole concept.
designator - a concept designator
bindInf - The binding information related to the binding context and to designator
Throws:
ToStringException - if no identifier is associated to an Individual in the current lexicon (and in the main language to, if mixed language is allowed).

parseRelationType

protected java.lang.Object parseRelationType(java.lang.StringBuffer sBuffer)
                                      throws ParsingException
Parsing of a Relation Type

Throws:
ParsingException

isInt

boolean isInt(java.lang.String si)

parsePoint

protected java.awt.Point parsePoint()
                             throws ParsingException
Throws:
ParsingException

parseSegmentPoints

protected void parseSegmentPoints(java.util.ArrayList segmentPoints)
                           throws ParsingException
Throws:
ParsingException

parseTerm

public Term parseTerm(java.lang.String strgTerm)
               throws ParsingException
Parse the textual formulation of a Term (parameter strgTerm) and produce its internal representation. This method corresponds to a call to the method parseAmineObject(String), both are called in general on an ObjectParsing object that was created by the constructor ObjectParsing(Lexicon lexicon). See comment on the method parseAmineObject(String) for more detail. A 'stand alone' version of this method, called parse(), is defined in cg.Term class.

Parameters:
strgTerm - a textual formulation of a Term
Returns:
the internal representation (Java Object) of the Term. Returns null if strgTerm is null or is empty
Throws:
throws - ParsingException if lexico-syntaxic errors occurs during parsing
ParsingException

parseTerm

protected Term parseTerm()
                  throws ParsingException
This method assumes that the textual formulation of the Term was already given to the textTokenizer of the current ObjectParsing and that lexical analysis was already done. It can be used by the ObjectParsing's subclasses only. This method parses the textual formulation of a Term and produces its corresponding internal representation (Java Object) if this step is intended (this is determined by the attribute generateCode : if true, the internal representation is produced, if false only the parsing is done). A 'stand alone' version of this method, called parse() is defined in cg.Term class, it receives the textual formulation of a Term as argument and produces its internal representation.

Returns:
the internal representation (Java Object) of the Term if generateCode is true and null otherwise
Throws:
ParsingException - if lexico-syntaxic errors occur during parsing

parseTerm

protected Term parseTerm(boolean isMethod)
                  throws ParsingException
Throws:
ParsingException

parseMessage

protected Term parseMessage()
                     throws ParsingException
Throws:
ParsingException

parseAmineList

public AmineList parseAmineList(java.lang.String strgList)
                         throws ParsingException
Parse the textual formulation of an Amine List (parameter strgList) and produce its internal representation. This method corresponds to a call to the method parseAmineObject(String), both are called in general on an ObjectParsing object that was created by the constructor ObjectParsing(Lexicon lexicon). See comment on the method parseAmineObject(String) for more detail.

A 'stand alone' version of this method, called parse(), is defined in cg.AmineList class.

Parameters:
strgList - a textual formulation of an Amine List
Returns:
the internal representation (Java Object) of the Amine List. Returns null if strgList is null or is empty
Throws:
throws - ParsingException if lexico-syntaxic errors occurs during parsing
ParsingException

parseAmineList

protected AmineList parseAmineList()
                            throws ParsingException
This method assumes that the textual formulation of the AmineList was already given to the textTokenizer of the current ObjectParsing and that lexical analysis was already done. It can be used by the ObjectParsing's subclasses only. This method parses the textual formulation of an AmineList and produces its corresponding internal representation (Java Object) if this step is intended (this is determined by the attribute generateCode : if true, the internal representation is produced, if false only the parsing is done).

A 'stand alone' version of this method, called parse() is defined in cg.AmineList class, it receives the textual formulation of an AmineList as argument and produces its internal representation.

Returns:
the internal representation (Java Object) of the AmineList if generateCode is true and null otherwise
Throws:
ParsingException - if lexico-syntaxic errors occur during parsing

parseAmineSet

public AmineSet parseAmineSet(java.lang.String strgSet)
                       throws ParsingException
Parse the textual formulation of an Amine Set (parameter strgSet) and produce its internal representation. This method corresponds to a call to the method parseAmineObject(String), both are called in general on an ObjectParsing object that was created by the constructor ObjectParsing(Lexicon lexicon). See comment on the method parseAmineObject(String) for more detail.

A 'stand alone' version of this method, called parse(), is defined in cg.AmineSet class.

Parameters:
strgSet - a textual formulation of an Amine Set
Returns:
the internal representation (Java Object) of the Amine Set. Returns null if strgSet is null or is empty
Throws:
throws - ParsingException if lexico-syntaxic errors occurs during parsing
ParsingException

parseAmineSet

protected AmineSet parseAmineSet()
                          throws ParsingException
This method assumes that the textual formulation of the AmineSet was already given to the textTokenizer of the current ObjectParsing and that lexical analysis was already done. It can be used by the ObjectParsing's subclasses only. This method parses the textual formulation of an AmineSet and produces its corresponding internal representation (Java Object) if this step is intended (this is determined by the attribute generateCode : if true, the internal representation is produced, if false only the parsing is done).

A 'stand alone' version of this method, called parse() is defined in cg.AmineSet class, it receives the textual formulation of an AmineSet as argument and produces its internal representation.

Returns:
the internal representation (Java Object) of the AmineSet if generateCode is true and null otherwise
Throws:
ParsingException - if lexico-syntaxic errors occur during parsing

parseExpression

protected java.lang.Object parseExpression()
                                    throws ParsingException
Parsing of an Expression

Throws:
ParsingException

parseSimpleExpression

java.lang.Object parseSimpleExpression()
                                 throws ParsingException
Throws:
ParsingException

parseExprTerm

java.lang.Object parseExprTerm()
                         throws ParsingException
Throws:
ParsingException

parseFactor

java.lang.Object parseFactor()
                       throws ParsingException
Throws:
ParsingException

parseOperName

Identifier parseOperName(byte nxtTokenType)

isRelationalOper

boolean isRelationalOper(byte tokenType)

isAdditiveOper

boolean isAdditiveOper(byte tokenType)

isMultiplicativeOper

boolean isMultiplicativeOper(byte tokenType)

isNotOper

boolean isNotOper(byte tokenType)

parseSentence

public static AmineList parseSentence(java.lang.String strgSentence)
                               throws ParsingException
Parse the specified string that corresponds to a sentence and produce an AmineList with the words of the sentence as elements. This method is useful in natural language processing applications

Parameters:
strgSentence - : a string that represents a sentence
Returns:
an AmineList with the words of the sentence strgSentence as elements
Throws:
ParsingException - if errors occur during parsing

determineCGForm

public byte determineCGForm(java.lang.String strgCG)
                     throws ParsingException
Determine the nature of the CG form (Linear Form -LF- or CGIF) from the specified textual formulation (a String) of the CG strgCG. A static version of this method is given in cg.CG class.

In more detail : If the current ObjectParsing is a LFParserGenerator or a CGIFParserGenerator, then the CG form is determined from the current ObjectParsing. Otherwise, we have to determine the form from the syntax of the textual representation of the CG. The ambiguity occurs when the CGIF begins with a concept, like the Linear form. In this case, we should look after the concept, except if the concept is a context (it contains a CG) in which case we can determine the form from the nested CG. Note first that the method is called after a look ahead of scope 3 (see the definition of the method parseAmineObject() and especially the case of 'lcOpBrkt' (open bracket '[') which could be the begining of a list or of a concept and hence a CG) and we are sure that we deal with a concept.

The problem is that a concept alone cannot tell if the notation is a linear form or a CGIF form except if it has a descriptor that contains a CG, the embedded CG will tell what is the notation of the outer context. The treatment of the descriptor will be complex because it could be a list or a term that contains other lists or terms or CG !

Our solution is to use a counter for open bracket '[' (because brackets are used for concepts and also for lists !) that will enable us to know when the end of the current concept occurs (i.e. which ']' encounterd corresponds to the end of the current concept and not to the end of a list). So the counter will allow us to determine the scope of our search. The treatment is as follows : we will use the counter, set to 1 for the first '[' and advance in the look ahead of the end of the concept ']'. During this advance, we increment the counter for each '[' encountered and decremente for each ']', the counter is equal to 0 is one condition to stop the advance, and we check for the pattern '] [' or '] (' which is a sign of a CGIF CG or the pattern ']-' or ']<-' which is a sign of a linear CG. If one of the two patterns occurs then the advance will stop (the second condition) because the notation has been determined !! Otherwise, we will reach the end of the current concept and we will look at the next token to determine the notation.

Since we perform a double pass (the first lexical and the second generation of the internal representation of the CG), we determine the nature of the CG form (when the case occur) at the first pass and we record the result in a HashMap with key=CurrElemInString and value=cgFormInString. At the second pass, we read only the recorded result from the HashMap.

Parameters:
strgCG - A textual formulation of a CG
Returns:
the nature of the CG form : return the constant LF if the CG is in a Linear Form and return the constant CGIF if the CG is in a CGIF form (see utilitiesAmine.AmineConstant interface for the values of thes constants).
Throws:
ParsingException - exception if strgCG is null or empty or if errors occur during the parsing

determineCGForm

public byte determineCGForm()
                     throws ParsingException
This method is the same as the method defined in this class with the same name except that this one assumes and operates on the current textTokenizer. See the comment on the other method for more detail.

Returns:
the nature of the CG form : return the constant LF if the CG is in a Linear Form and return the constant CGIF if the CG is in a CGIF form (see utilitiesAmine.AmineConstant interface for the values of thes constants).
Throws:
ParsingException - exception if errors occur during the parsing

getBlancsString

public static java.lang.String getBlancsString(int nbrBlancs)
Form a string of blanks, the number of blanks is specified by nbrBlancs

Parameters:
nbrBlancs - : the number of blanks to put in the string
Returns:
a String of blanks

deletePseudoCorefs

void deletePseudoCorefs(CG cg)
                  throws ParsingException
Pseudo coreferents are coreferents that are used in LF or in CGIF to refeer to the same concept, in the same CG, from different locations/occurrences. A true coreferent relates two concepts of two differents CG; to specify that the two concepts have the same reference. Thus, even if at the syntactical level, pseudo coreferent and true coreferent are the same, at the semantical level, they are different. Pseudo coreferents should be deleted from the CG at the end of the parsing. The problem is how to differentiate between pseudo coreferent and true coreferent; how to identify that such a coreferent is a pseudo-coreferent. To do such an identification, we should wait until the whole (simple/composed) CG is parsed. Then, by scanning the whole CG we can make such a difference. Here is our method in doing the elimination of pseudo-coreferents: We perform a scan of the whole CG, taking into account the embeeded CG, and we keep a HashMap of ; each time we encounter a concept C with a definitional coreferent DC, we add a couple to the HashMap. And if we encounter a concept with a bound coreferent, we try to locate an entry in the HashMap with an associated definitional coreferent. If no such entry is located, we throw an exception/error message (each bound coreference should have an associated definitional coreferent). If the entry is located, we remove the entry from the HashMap since the definitional coreferent has a corresponding bound coreferent and represents in this case a true coreferent. Once the scanning of the CG is terminated, we consider all concepts that remain in the HashMap; they correspond to concepts with definitional coreferents but without corresponding bound coreferents. For these concepts, their coreferent should be set to null; in order to eliminate the pseudo-coreferent.

Parameters:
cg - CG
Throws:
ParsingException

deletePseudoCorefs

void deletePseudoCorefs(CG cg,
                        java.util.HashMap pseudoCorefConcepts)
                  throws ParsingException
Throws:
ParsingException

addPseudoCorefs

protected void addPseudoCorefs(CG cg,
                               java.util.ArrayList concsWithPseudoCoref)
To generate LF ou CGIF for the CG cg, addition of pseudo-coreferents, for some concepts, is required. This addition concerns the whole CG, including embeeded CGs. Of course, after the generation, the added pseudo-coreferents should be eliminated. Method addPseudoCorefs() performs this treatment. It starts with a special case: the CG cg may contain several concepts with "super" as designator and they have nothing else to differentiate between them (no coreferent, no descriptor). In this case, we should add pseudo-coreferents to these concepts. Then, for the general case, method addPseudoCorefs() scan the concepts of cg to locate any concept that has no coreferent, no designator, no descriptor, and it is the target of at least two relations. The method will assign a pseudo-coreferent to such a concept. This concept is memorized in the ArrayList concsWithPseudoCoref. This treatment is done recursively for any embeeded CG.

Parameters:
cg - CG
concsWithPseudoCoref - ArrayList

addPseudoCorefs

protected int addPseudoCorefs(CG cg,
                              java.util.ArrayList concsWithPseudoCoref,
                              int indxSupCoref)

hasSeveralSuper

protected boolean hasSeveralSuper(CG cg)

deletePseudoDesignators

protected void deletePseudoDesignators(CG cg)
delete pseudo-designators from any concept of the specified CG cg : replace the pseudo-designators by a null designator (null). A special case is treated in this method : the presence of designators of the form "super#Nbr". Such a designator is replaced by "super". This method is used by CGIFParserGenerator and LFParserGenerator subclasses.

Parameters:
cg - : a CG