Class RpclCondensedProbabilityDistributionParser
java.lang.Object
org.tweetyproject.logics.rpcl.parser.rpclcondensedprobabilitydistributionparser.RpclCondensedProbabilityDistributionParser
- All Implemented Interfaces:
RpclCondensedProbabilityDistributionParserConstants
public class RpclCondensedProbabilityDistributionParser
extends Object
implements RpclCondensedProbabilityDistributionParserConstants
This class implements a parser for condensed relational probability distributions. The BNF for
condensed relational probability distributions is given by (start symbol is DISTRIBUTION)
DISTRIBUTION ::== (PROBABILITYASSIGNMENT)*
PROBABILITYASSIGNMENT ::== INTERPRETATION "=" PROBABILITY
INTERPRETATION ::== "{" (INSTANCEASSIGNMENT ("," INSTANCEASSIGNMENT)*)? "}"
INSTANCEASSIGNMENT ::== "<" PREDICATE "," "{" (CONSTANTSET "=" MULTIPLICATOR ("," CONSTANTSET "=" MULTIPLICATOR)*)? "}" ">"
CONSTANTSET ::== "{" CONSTANT ("," CONSTANT)* "}"
PREDICATE is a sequence of symbols from {a,...,z,A,...,Z,0,...,9} with a lowercase letter at the beginning.
CONSTANT is a sequence of symbols from {a,...,z,A,...,Z,0,...,9} with a lowercase letter at the beginning.
MULTIPLICATOR is a natural number.
DISTRIBUTION ::== (PROBABILITYASSIGNMENT)*
PROBABILITYASSIGNMENT ::== INTERPRETATION "=" PROBABILITY
INTERPRETATION ::== "{" (INSTANCEASSIGNMENT ("," INSTANCEASSIGNMENT)*)? "}"
INSTANCEASSIGNMENT ::== "<" PREDICATE "," "{" (CONSTANTSET "=" MULTIPLICATOR ("," CONSTANTSET "=" MULTIPLICATOR)*)? "}" ">"
CONSTANTSET ::== "{" CONSTANT ("," CONSTANT)* "}"
PREDICATE is a sequence of symbols from {a,...,z,A,...,Z,0,...,9} with a lowercase letter at the beginning.
CONSTANT is a sequence of symbols from {a,...,z,A,...,Z,0,...,9} with a lowercase letter at the beginning.
MULTIPLICATOR is a natural number.
-
Field Summary
Modifier and TypeFieldDescriptionstatic Token
Next token.static Token
Current token.Generated Token Manager.Fields inherited from interface org.tweetyproject.logics.rpcl.parser.rpclcondensedprobabilitydistributionparser.RpclCondensedProbabilityDistributionParserConstants
DEFAULT, EOF, MULTIPLICATOR, PROBABILITY, STRUCTURENAME, tokenImage
-
Constructor Summary
ConstructorDescriptionCnnstructorConstructor forRpclCondensedProbabilityDistributionParser
that takes anInputStream
as input.RpclCondensedProbabilityDistributionParser
(InputStream stream, String encoding) Constructs a newRpclCondensedProbabilityDistributionParser
using the specified input stream and character encoding.Constructor.RpclCondensedProbabilityDistributionParser
(RpclCondensedProbabilityDistributionParserTokenManager tm) Constructor with generated Token Manager.ConstructorRpclCondensedProbabilityDistributionParser
(RpclSemantics semantics, FolSignature signature) Constructor -
Method Summary
Modifier and TypeMethodDescriptionConstantSet
(FolSignature signature) Parses a set of constants from the input and adds them to the specifiedFolSignature
.static final void
Disable tracing.static final CondensedProbabilityDistribution
Distribution
(RpclSemantics semantics, FolSignature signature) Create a distributionstatic final void
Enable tracing.static ParseException
Generate ParseException.static final Token
Retrieves the next token from the input stream.static final Token
getToken
(int index) Get the specific Token.static final InstanceAssignment
InstanceAssignment
(FolSignature signature) Parses anInstanceAssignment
from the input stream.static final ReferenceWorld
Interpretation
(FolSignature signature) Parses anInterpretation
(specifically, aReferenceWorld
) from the input streamReturn parsed CondensedProbabilityDistributionstatic final Pair
<ReferenceWorld, Probability> ProbabilityAssignment
(FolSignature signature) Parses a probability assignment from the input stream.static void
ReInit
(InputStream stream) Reinitializes the parser with a new input stream using the default character encoding.static void
ReInit
(InputStream stream, String encoding) Reinitializes the parser with a new input stream and character encoding.static void
Reinitialisevoid
Reinitialise.void
setSemantics
(RpclSemantics semantics) setter semanticsvoid
setSignature
(FolSignature signature) setter signature
-
Field Details
-
token_source
Generated Token Manager. -
token
Current token. -
jj_nt
Next token.
-
-
Constructor Details
-
RpclCondensedProbabilityDistributionParser
public RpclCondensedProbabilityDistributionParser()Cnnstructor -
RpclCondensedProbabilityDistributionParser
Constructor- Parameters:
semantics
- a semantics
-
RpclCondensedProbabilityDistributionParser
Constructor- Parameters:
semantics
- a semanticssignature
- a signature
-
RpclCondensedProbabilityDistributionParser
Constructor forRpclCondensedProbabilityDistributionParser
that takes anInputStream
as input.- Parameters:
stream
- The input stream to be parsed.
-
RpclCondensedProbabilityDistributionParser
Constructs a newRpclCondensedProbabilityDistributionParser
using the specified input stream and character encoding.- Parameters:
stream
- The input stream to be parsed.encoding
- The character encoding to be used for reading the input stream.- Throws:
RuntimeException
- If the specified encoding is unsupported.Error
- If this constructor is called more than once when the JavaCCSTATIC
option is enabled.
-
RpclCondensedProbabilityDistributionParser
Constructor.- Parameters:
stream
- the reader
-
RpclCondensedProbabilityDistributionParser
public RpclCondensedProbabilityDistributionParser(RpclCondensedProbabilityDistributionParserTokenManager tm) Constructor with generated Token Manager.- Parameters:
tm
- the tokenmanager
-
-
Method Details
-
setSemantics
setter semantics- Parameters:
semantics
- the semantics
-
setSignature
setter signature- Parameters:
signature
- the signature
-
parseCondensedProbabilityDistribution
public CondensedProbabilityDistribution parseCondensedProbabilityDistribution(Reader reader) throws ParserException Return parsed CondensedProbabilityDistribution- Parameters:
reader
- the reader- Returns:
- parsed CondensedProbabilityDistribution
- Throws:
ParserException
- parse exception
-
Distribution
public static final CondensedProbabilityDistribution Distribution(RpclSemantics semantics, FolSignature signature) throws ParseException Create a distribution- Parameters:
semantics
- the semanticssignature
- the signiture- Returns:
- a distribution
- Throws:
ParseException
- error
-
ProbabilityAssignment
public static final Pair<ReferenceWorld,Probability> ProbabilityAssignment(FolSignature signature) throws ParseException Parses a probability assignment from the input stream.This method processes a
ReferenceWorld
followed by a probability value (which could either be a probability or a multiplicator). The method combines the parsedReferenceWorld
with the probability and returns them as aPair
.- Parameters:
signature
- TheFolSignature
to which the constants in theReferenceWorld
belong. If a constant is not found in the signature, it is added to it.- Returns:
- A
Pair
containing the parsedReferenceWorld
and its associatedProbability
. - Throws:
ParseException
- If there is an error during the parsing process.
-
Interpretation
Parses anInterpretation
(specifically, aReferenceWorld
) from the input stream- Parameters:
signature
- TheFolSignature
to which the parsed constants and predicates belong. If a constant or predicate is not found in the signature, it is added to it.- Returns:
- A
ReferenceWorld
that contains the predicates and their instance assignments. - Throws:
ParseException
- If there is an error during the parsing process.
-
InstanceAssignment
public static final InstanceAssignment InstanceAssignment(FolSignature signature) throws ParseException Parses anInstanceAssignment
from the input stream.This method processes the predicate, constants, and multiplicators, and constructs an
InstanceAssignment
. The predicate is either retrieved from the givenFolSignature
if it exists, or a new one is created and added to the signature. The method then parses multiple sets of constants and their associated multiplicators, adding them to theInstanceAssignment
.- Parameters:
signature
- TheFolSignature
to which the constants and predicates belong. If a constant or predicate is not found in the signature, it is added to it.- Returns:
- An
InstanceAssignment
containing the parsed predicate and associated constants with their multiplicators. - Throws:
ParseException
- If there is an error during the parsing process.
-
ConstantSet
Parses a set of constants from the input and adds them to the specifiedFolSignature
.- Parameters:
signature
- TheFolSignature
to which the constants belong. If a constant is not found in the signature, it is added to it.- Returns:
- A
Set
ofConstant
objects that were parsed from the input. - Throws:
ParseException
- If there is an error during the parsing process.
-
ReInit
Reinitializes the parser with a new input stream using the default character encoding.- Parameters:
stream
- The new input stream for the parser.- See Also:
-
ReInit
Reinitializes the parser with a new input stream and character encoding.- Parameters:
stream
- The new input stream for the parser.encoding
- The character encoding of the input stream.- Throws:
RuntimeException
- If the specified encoding is not supported.
-
ReInit
-
ReInit
Reinitialise.- Parameters:
tm
- the tokenmanager
-
getNextToken
-
getToken
Get the specific Token.- Parameters:
index
- the index- Returns:
- the token
-
generateParseException
Generate ParseException.- Returns:
- a ParseException
-
enable_tracing
public static final void enable_tracing()Enable tracing. -
disable_tracing
public static final void disable_tracing()Disable tracing.
-