aminePlatform.util.parserGenerator
Class LFParserGenerator

java.lang.Object
  extended byaminePlatform.util.parserGenerator.ObjectParsing
      extended byaminePlatform.util.parserGenerator.LFParserGenerator
All Implemented Interfaces:
AmineConstants

public class LFParserGenerator
extends ObjectParsing
implements AmineConstants

Title : parserGenerator.LFParserGenerator Class

Description : This class is responsible of two tasks :

- to parse the LF notation of a CG and generate its internal representation,

- to generate a LF notation of a CG from its internal representation.

The first task, LF-To-CG, is done by the method parse() that parses the LF notation of a CG and produces the internal representation of the CG. The second task, LF-From-CG, is done by the method toLF() that generates a LF notation from the internal representation of a CG.

NEW : Amine 2.5, by Adil. In the previous version, we considered only LF of connected CG. Now, we consider the possibility of LF of disconnected CG. A disconnected CG is a sequence of CG without any separator except space(s).

NEW Amine 2.5, by Adil: In SYNERGY, there is four primitive relations:

in, out, grd, next. Relations in and out can have a range and all these relations

can have other attributes, like functional attribute, cut forward propagation, ...

according to the semantic of SYNERGY. These information are recorded in the attribute

suffix.

The syntax of LF notation :

CG ::= (Concept [Relation | Relations])*

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

[":"] [CoReferent] [Designator] [CoReferent] ["="] [Descriptor] [CoReferent] // Coreferent (defining/* | bound/? coreference label/Variable) can be specified before or after. Note also, a set of designator is not enclosed in {}

["$" 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

Relation ::= ("-" RelTypeIdentifier "->" CG) | ("<-" RelTypeIdentifier "-" CG)

Relations ::= "-" Relation {"," Relation}* [";"]

RelTypeIdentifier ::= Identifier [Suffix] {Rel_Point}*

Suffix ::= [Integer] ["," "f"] ["," "|<"] ["," ">|"]

Rel_Point ::= "(" Integer Integer ")"

Copyright : Copyright (c) Adil KABBAJ 2004-2009


Field Summary
 
Fields inherited from class aminePlatform.util.parserGenerator.ObjectParsing
generateCode, genericCoref, lexicon, txtTokenizer
 
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
LFParserGenerator(Lexicon lexicon)
          This constructor calls the corresponding constructor of the super-class
LFParserGenerator(TextTokenizer txtTokenizer, Lexicon lexicon)
          This constructor calls the corresponding constructor of the super-class
 
Method Summary
 CG parse()
          This method parses the LF formulation of a CG 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).
 CG parse(java.lang.String strgCG)
          Parse a LF form of a CG to produce the internal representation of the CG.
 CG parse(java.lang.String strgCG, AmineList newTypes)
           
 CG parse(TextTokenizer textTokenizer)
          This method is similar to parse(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 parse(TextTokenizer textTokenizer, AmineList newTypes)
           
protected  CG parseCG()
          Parse the LF of a CG.
(package private)  Concept selectHead(java.util.ArrayList notVisitedConcs)
          From the given ArrayList of concepts, choose the one with the high connections, the concept that have the high number of income & outcome relations.
protected  java.lang.String toCGLFBis(BindingContext bindContext, CG cg, java.lang.Object bindInf, int indent)
          This method corresponds basically to toLF().
 java.lang.String toLF(BindingContext bindContext, CG cg, java.lang.Object bindInf, int indent)
          Generate the LF formulation from the internal representation of the specified CG (parameter cg).
 
Methods inherited from class aminePlatform.util.parserGenerator.ObjectParsing
addPseudoCorefs, addPseudoCorefs, conceptToString, conceptToString, deletePseudoCorefs, deletePseudoCorefs, deletePseudoDesignators, determineCGForm, determineCGForm, finalize, generateDesignator, getBlancsString, getGenerateCode, getLexicon, getTxtTokenizer, getWithDrawingInf, hasSeveralSuper, isAdditiveOper, isDescriptor, isDesignator, isInt, isMultiplicativeOper, isNotOper, isParameterMode, isRelationalOper, parameterMode, parseAmineList, parseAmineList, parseAmineObject, parseAmineObject, parseAmineSet, parseAmineSet, parseCG, parseCG, parseCG, parseCG, parseConcept, parseConcept, parseConcept, parseConcPoint, parseCoref, parseCoreferent, parseCState, parseDescriptor, parseDesignator, parseExpression, parseExprTerm, parseFactor, parseMessage, parseOperName, parsePoint, parsePseudoDesignator, parseRelationType, parseSegmentPoints, parseSentence, parseSimpleExpression, parseState, parseStdSetDesignator, parseTerm, parseTerm, parseTerm, setGenerateCode, setLexicon, setTxtTokenizer, setWithDrawingInf
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LFParserGenerator

public LFParserGenerator(TextTokenizer txtTokenizer,
                         Lexicon lexicon)
                  throws ParsingException
This constructor calls the corresponding constructor of the super-class


LFParserGenerator

public LFParserGenerator(Lexicon lexicon)
                  throws ParsingException
This constructor calls the corresponding constructor of the super-class

Method Detail

parse

public CG parse(java.lang.String strgCG)
         throws ParsingException
Parse a LF form of a CG to produce the internal representation of the CG. This method corresponds to a call to the method parseCG(strgCG) defined in the super-class ObjectParsing. See comment on this method for more detail.

Parameters:
strgCG - a LF 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

parse

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

parse

public CG parse(TextTokenizer textTokenizer)
         throws ParsingException
This method is similar to parse(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

parse

public CG parse(TextTokenizer textTokenizer,
                AmineList newTypes)
         throws ParsingException
Throws:
ParsingException

parse

public CG parse()
         throws ParsingException
This method parses the LF formulation of a CG 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). This method assumes that the LF formulation of the CG was already given to the textTokenizer of the current ObjectParsing and that lexical analysis was already done. This method is called in general for a LFParserGenerator object that was created by the constructor : LFParserGenerator(TextTokenizer, Lexicon). A 'stand alone' version of this method, called parseLF() is defined in cg.CG class, it receives the LF 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

parseCG

protected CG parseCG()
              throws ParsingException
Parse the LF of a CG. Redefine the method parseCG() of the super-class ObjectParsing.

Overrides:
parseCG in class ObjectParsing
Returns:
a CG
Throws:
ParsingException - if an error occurs during parsing

toLF

public java.lang.String toLF(BindingContext bindContext,
                             CG cg,
                             java.lang.Object bindInf,
                             int indent)
                      throws ToStringException
Generate the LF formulation from the internal representation of the specified CG (parameter cg). The method is called in general on a LFParserGenerator object that was created by the constructor LFParserGenerator(lexicon). A 'stand alone' version of this method, called toLF(), is defined in cg.CG class.

Parameters:
bindContext - The Binding context
cg - is the CG for which a LF formulation (production) is required
bindInf - The binding information related to the binding context and to cg
indent - is an integer that allows for a correct treatment of the indentation
Returns:
the String that represents the cg in the LF
Throws:
ToStringException - if no identifier is associated to a CS in the specified lexicon (and in the main language if mixed language is allowed).

toCGLFBis

protected java.lang.String toCGLFBis(BindingContext bindContext,
                                     CG cg,
                                     java.lang.Object bindInf,
                                     int indent)
                              throws ToStringException
This method corresponds basically to toLF().

Parameters:
bindContext - The Binding context
cg - is the CG for which a LF formulation (production) is required
bindInf - The binding information related to the binding context and to cg
indent - is an integer that allows for a correct treatment of the indentation
Returns:
the String that represents the cg in the LF
Throws:
ToStringException - if no identifier is associated to a CS in the specified lexicon (and in the main language if mixed language is allowed).

selectHead

Concept selectHead(java.util.ArrayList notVisitedConcs)
From the given ArrayList of concepts, choose the one with the high connections, the concept that have the high number of income & outcome relations.

Parameters:
notVisitedConcs -
Returns: