Parsers¶
The fosf.parsers package provides high-level functions for parsing textual
representations of directed graphs, sort taxonomies, OSF terms, OSF clauses, and OSF theories.
Each function calls the corresponding parser class and returns an objcet from
fosf.syntax.
- fosf.parsers.parse_graph(string)[source]¶
Parse a textual representation of a (weighted) DAG.
- Parameters:
string (str) – The string representation of the (weighted) DAG.
- Returns:
The parsed weighted DAG.
- Return type:
Note
The accepted syntax is defined in Graph Grammar.
- fosf.parsers.parse_taxonomy(string)[source]¶
Parse a textual representation of a (fuzzy) sort taxonomy.
- Parameters:
string (str) – The string representation of the (fuzzy) sort taxonomy.
- Returns:
The parsed sort taxonomy
- Return type:
Note
The accepted syntax is defined in Taxonomy Grammar.
- fosf.parsers.parse_term(string, default_tag='X', create_using=None)[source]¶
Parse a textual representation of an OSF term.
- Parameters:
string (str) – The string representation of the OSF term.
default_tag (str, default="X") – The default base identifier for a tag, used when an explicit tag is missing. Defaults to
"X".create_using (type, optional) – Term class to construct the output. Should be one of
TermorNormalTerm. If None, defaults toTerm
- Returns:
The parsed OSF term.
- Return type:
Note
The accepted OSF term syntax is defined in OSF Term Grammar.
- fosf.parsers.parse_clause(string, create_using=None, root=None)[source]¶
Parse a textual representation of an OSF clause.
- Parameters:
string (str) – The string representation of the OSF clause.
create_using (type, optional) – Clause class to construct the output. Should be one of
Clause,RootedClause,SolvedClause, orRootedSolvedClause. If None, defaults toClauseroot (Tag, optional) – Root tag. Required if
create_usingisRootedClauseorRootedSolvedClause.
- Returns:
The parsed OSF clause.
- Return type:
Note
The accepted OSF clause syntax is defined in OSF Clause Grammar.
- fosf.parsers.parse_theory(string, ensure_closed=False)[source]¶
Parse a textual representation of an OSF theory.
- Parameters:
- Returns:
The parsed OSF theory.
- Return type:
Note
The accepted OSF theory syntax is defined in OSF Theory Grammar.
Base OSF Parser¶
(Fuzzy) Taxonomy Parser¶
OSF Clause Parser¶
- class fosf.parsers.clause.OsfConstraintParser[source]¶
Bases:
BaseOSFParser
- class fosf.parsers.clause.NormalizationParser[source]¶
Bases:
BaseOSFParser
OSF Term Parser¶
- class fosf.parsers.term.OsfTermParser[source]¶
Bases:
BaseOSFParser
- class fosf.parsers.term.UnificationParser[source]¶
Bases:
OsfTermParser- parse(expression: str, default_tag='X', term_constructor=NormalTerm) tuple[SortTaxonomy, NormalTerm, NormalTerm][source]¶
- parse(expression: str, default_tag='X', term_constructor=Term) tuple[SortTaxonomy, Term, Term]
- Parameters:
expression (str)
- Return type: