proper.imp
Class Parser

java.lang.Object
  extended by proper.core.ProperObject
      extended by proper.imp.Parser
All Implemented Interfaces:
ProperInterface, ParserInterface
Direct Known Subclasses:
CSVParser, PrologParser

public abstract class Parser
extends ProperObject
implements ParserInterface

This abstract is the ancestor for several Parsers that use predicates. Handwritten parser was necessary, since JLex/CUP had problems with big files...

Version:
$Revision: 1.2 $
Author:
FracPete

Field Summary
static boolean RELAGGS_FIX
          fixes the problem of RELAGGS with "+" and "-", by changing it to "pos" and "neg"
 
Fields inherited from interface proper.imp.ParserInterface
CLASS_NEGATIVE, CLASS_POSITIVE
 
Fields inherited from interface proper.core.ProperInterface
VERSION
 
Constructor Summary
Parser()
          initializes the parser
 
Method Summary
 void clear()
          clears the currently stored predicates
 boolean getAddClassLabel()
          returns the current status of the flag for adding class labels ('+' or '-') to the facts
 java.lang.String getClassLabel()
          the current label for the class
 java.lang.String getFilename()
          returns the current filename
 boolean getOnlyForSingles()
          returns the flag, whether the class label is added only to predicates with one argument
 java.util.Vector getPredicates()
          returns the currently stored predicates
 void parse(java.io.Reader reader)
          uses the given reader to parse the file
 void parse(java.lang.String filename)
          parses the given file
 void setAddClassLabel(boolean addClassLabel)
          if this flag is set, the file is considered as without class labels and therefore facts with ":-" are labeled with '-' otherwise with '+'
 void setClassLabel(java.lang.String classLabel)
          sets the class label to use
 void setFilename(java.lang.String filename)
          sets the name of the file being parsed right now
 void setID(ID id)
          sets the ID-generator
 void setOnlyForSingles(boolean onlyForSingles)
          sets the flag, whether the class label is added only to predicates with one argument
 java.lang.String toString()
          returns the currently stored predicates in string representation
 
Methods inherited from class proper.core.ProperObject
addListener, addOutput, classInVerbose, debugprint, debugprint, debugprint, debugprint, debugprintln, debugprintln, debugprintln, debugprintln, debugprintln, getListeners, getRuntime, getVerbose, getVerboseLevel, getVerboseLevelForClass, getVerboseString, getVerboseStringForClass, notifyListener, notifyListeners, print, print, print, print, println, println, println, println, println, printMemory, removeListener, setOutput, setVerbose, setVerboseLevel, setVerboseString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface proper.imp.ParserInterface
getVerbose, setVerbose
 

Field Detail

RELAGGS_FIX

public static final boolean RELAGGS_FIX
fixes the problem of RELAGGS with "+" and "-", by changing it to "pos" and "neg"

See Also:
Constant Field Values
Constructor Detail

Parser

public Parser()
initializes the parser

Method Detail

setID

public void setID(ID id)
sets the ID-generator

Specified by:
setID in interface ParserInterface

getPredicates

public java.util.Vector getPredicates()
returns the currently stored predicates

Specified by:
getPredicates in interface ParserInterface

setAddClassLabel

public void setAddClassLabel(boolean addClassLabel)
if this flag is set, the file is considered as without class labels and therefore facts with ":-" are labeled with '-' otherwise with '+'

Specified by:
setAddClassLabel in interface ParserInterface

getAddClassLabel

public boolean getAddClassLabel()
returns the current status of the flag for adding class labels ('+' or '-') to the facts

Specified by:
getAddClassLabel in interface ParserInterface

setOnlyForSingles

public void setOnlyForSingles(boolean onlyForSingles)
sets the flag, whether the class label is added only to predicates with one argument

Specified by:
setOnlyForSingles in interface ParserInterface

getOnlyForSingles

public boolean getOnlyForSingles()
returns the flag, whether the class label is added only to predicates with one argument

Specified by:
getOnlyForSingles in interface ParserInterface

setClassLabel

public void setClassLabel(java.lang.String classLabel)
sets the class label to use

Specified by:
setClassLabel in interface ParserInterface
See Also:
ParserInterface.setOnlyForSingles(boolean)

getClassLabel

public java.lang.String getClassLabel()
the current label for the class

Specified by:
getClassLabel in interface ParserInterface

setFilename

public void setFilename(java.lang.String filename)
sets the name of the file being parsed right now

Specified by:
setFilename in interface ParserInterface

getFilename

public java.lang.String getFilename()
returns the current filename

Specified by:
getFilename in interface ParserInterface

clear

public void clear()
clears the currently stored predicates

Specified by:
clear in interface ParserInterface

parse

public void parse(java.lang.String filename)
           throws java.lang.Exception
parses the given file

Specified by:
parse in interface ParserInterface
Throws:
java.lang.Exception

parse

public void parse(java.io.Reader reader)
           throws java.lang.Exception
uses the given reader to parse the file

Specified by:
parse in interface ParserInterface
Throws:
java.lang.Exception

toString

public java.lang.String toString()
returns the currently stored predicates in string representation

Overrides:
toString in class ProperObject