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.
  • Field Details

  • Constructor Details

    • RpclCondensedProbabilityDistributionParser

      public RpclCondensedProbabilityDistributionParser()
      Cnnstructor
    • RpclCondensedProbabilityDistributionParser

      public RpclCondensedProbabilityDistributionParser(RpclSemantics semantics)
      Constructor
      Parameters:
      semantics - a semantics
    • RpclCondensedProbabilityDistributionParser

      public RpclCondensedProbabilityDistributionParser(RpclSemantics semantics, FolSignature signature)
      Constructor
      Parameters:
      semantics - a semantics
      signature - a signature
    • RpclCondensedProbabilityDistributionParser

      public RpclCondensedProbabilityDistributionParser(InputStream stream)
      Constructor for RpclCondensedProbabilityDistributionParser that takes an InputStream as input.
      Parameters:
      stream - The input stream to be parsed.
    • RpclCondensedProbabilityDistributionParser

      public RpclCondensedProbabilityDistributionParser(InputStream stream, String encoding)
      Constructs a new RpclCondensedProbabilityDistributionParser 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 JavaCC STATIC option is enabled.
    • RpclCondensedProbabilityDistributionParser

      public RpclCondensedProbabilityDistributionParser(Reader stream)
      Constructor.
      Parameters:
      stream - the reader
    • RpclCondensedProbabilityDistributionParser

      public RpclCondensedProbabilityDistributionParser(RpclCondensedProbabilityDistributionParserTokenManager tm)
      Constructor with generated Token Manager.
      Parameters:
      tm - the tokenmanager
  • Method Details

    • setSemantics

      public void setSemantics(RpclSemantics semantics)
      setter semantics
      Parameters:
      semantics - the semantics
    • setSignature

      public void setSignature(FolSignature signature)
      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 semantics
      signature - 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 parsed ReferenceWorld with the probability and returns them as a Pair.

      Parameters:
      signature - The FolSignature to which the constants in the ReferenceWorld belong. If a constant is not found in the signature, it is added to it.
      Returns:
      A Pair containing the parsed ReferenceWorld and its associated Probability.
      Throws:
      ParseException - If there is an error during the parsing process.
    • Interpretation

      public static final ReferenceWorld Interpretation(FolSignature signature) throws ParseException
      Parses an Interpretation (specifically, a ReferenceWorld) from the input stream
      Parameters:
      signature - The FolSignature 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 an InstanceAssignment from the input stream.

      This method processes the predicate, constants, and multiplicators, and constructs an InstanceAssignment. The predicate is either retrieved from the given FolSignature 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 the InstanceAssignment.

      Parameters:
      signature - The FolSignature 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

      public static final Set<Constant> ConstantSet(FolSignature signature) throws ParseException
      Parses a set of constants from the input and adds them to the specified FolSignature.
      Parameters:
      signature - The FolSignature to which the constants belong. If a constant is not found in the signature, it is added to it.
      Returns:
      A Set of Constant objects that were parsed from the input.
      Throws:
      ParseException - If there is an error during the parsing process.
    • ReInit

      public static void ReInit(InputStream stream)
      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

      public static void ReInit(InputStream stream, String encoding)
      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

      public static void ReInit(Reader stream)
      Reinitialise
      Parameters:
      stream - the reader
    • ReInit

      Reinitialise.
      Parameters:
      tm - the tokenmanager
    • getNextToken

      public static final Token getNextToken()
      Retrieves the next token from the input stream.
      Returns:
      the next Token in the input stream
    • getToken

      public static final Token getToken(int index)
      Get the specific Token.
      Parameters:
      index - the index
      Returns:
      the token
    • generateParseException

      public static ParseException 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.