owlapy.parser.DLSyntaxParser¶
-
class
owlapy.parser.
DLSyntaxParser
(namespace: Optional[Union[str, owlapy.namespaces.Namespaces]] = None, grammar=None)[source]¶ Bases:
parsimonious.nodes.NodeVisitor
,owlapy.io.OWLObjectParser
Description Logic Syntax parser to parse strings to OWLClassExpressions
- Create a new Description Logic Syntax parser. Names (entities) can be given as full IRIs enclosed in < and >
or as simple strings, in that case the namespace attribute of the parser has to be set to resolve them. Prefixes are currently not supported, except for datatypes.
- Parameters:
namespace – Namespace to resolve names that were given without one
grammar – Grammar (defaults to DL_GRAMMAR)
Methods
Default visitor method
Lift the sole child of
node
up to replace the node.Parse and visit some text with this Visitor’s default grammar, but don’t insist on parsing all the way to the end.
Parse some text with this Visitor’s default grammar and return the result of visiting it.
Parse a string to an OWL Object
Walk a parse tree, transforming it into another representation.
Attributes
the one recommended for use with this visitor.
Classes of exceptions you actually intend to raise during visitation and which should propagate out of the visitor.
-
generic_visit
(node, children)[source]¶ Default visitor method
- Parameters:
node – The node we’re visiting
visited_children – The results of visiting the children of that node, in a list
I’m not sure there’s an implementation of this that makes sense across all (or even most) use cases, so we leave it to subclasses to implement for now.
-
grammar
= None¶ the one recommended for use with this visitor. If you populate this, you will be able to call
NodeVisitor.parse()
as a shortcut.- Type:
The default grammar
-
lift_child
(node, children)¶ Lift the sole child of
node
up to replace the node.
-
match
(text, pos=0)¶ Parse and visit some text with this Visitor’s default grammar, but don’t insist on parsing all the way to the end.
SomeVisitor().match('some_string')
is a shortcut forSomeVisitor().visit(some_grammar.match('some_string'))
.
-
ns
: Optional[Union[str, owlapy.namespaces.Namespaces]]¶
-
parse
(text, pos=0)¶ Parse some text with this Visitor’s default grammar and return the result of visiting it.
SomeVisitor().parse('some_string')
is a shortcut forSomeVisitor().visit(some_grammar.parse('some_string'))
.
-
parse_expression
(expression_str: str) → owlapy.model.OWLClassExpression[source]¶ Parse a string to an OWL Object
- Parameters:
expression_str – string
- Returns:
The OWL Object which is represented by the string
-
slots
= ('ns', 'grammar')¶
-
unwrapped_exceptions
= ()¶ Classes of exceptions you actually intend to raise during visitation and which should propagate out of the visitor. These will not be wrapped in a VisitationError when they arise.
-
visit
(node)¶ Walk a parse tree, transforming it into another representation.
Recursively descend a parse tree, dispatching to the method named after the rule in the
Grammar
that produced each node. If, for example, a rule was…bold = '<b>'
…the
visit_bold()
method would be called. It is your responsibility to subclassNodeVisitor
and implement those methods.
-
visit_boolean_literal
(node, children) → owlapy.model.OWLLiteral[source]¶
-
visit_cardinality_res
(node, children) → owlapy.model.OWLObjectCardinalityRestriction[source]¶
-
visit_class_expression
(node, children) → owlapy.model.OWLClassExpression[source]¶
-
visit_class_iri
(node, children) → owlapy.model.OWLClass[source]¶
-
visit_data_cardinality_res
(node, children) → owlapy.model.OWLDataCardinalityRestriction[source]¶
-
visit_data_parentheses
(node, children) → owlapy.model.OWLDataRange[source]¶
-
visit_data_primary
(node, children) → owlapy.model.OWLDataRange[source]¶
-
visit_data_property_iri
(node, children) → owlapy.model.OWLDataProperty[source]¶
-
visit_data_some_only_res
(node, children) → owlapy.model.OWLQuantifiedDataRestriction[source]¶
-
visit_data_value_res
(node, children) → owlapy.model.OWLDataHasValue[source]¶
-
visit_datatype
(node, children) → owlapy.model.OWLDatatype[source]¶
-
visit_datatype_restriction
(node, children) → owlapy.model.OWLDatatypeRestriction[source]¶
-
visit_date_literal
(node, children) → owlapy.model.OWLLiteral[source]¶
-
visit_datetime_literal
(node, children) → owlapy.model.OWLLiteral[source]¶
-
visit_decimal_literal
(node, children) → owlapy.model.OWLLiteral[source]¶
-
visit_duration_literal
(node, children) → owlapy.model.OWLLiteral[source]¶
-
visit_facet
(node, children) → owlapy.vocab.OWLFacet[source]¶
-
visit_facet_restriction
(node, children) → owlapy.model.OWLFacetRestriction[source]¶
-
visit_float_literal
(node, children) → owlapy.model.OWLLiteral[source]¶
-
visit_full_iri
(node, children) → owlapy.model.IRI[source]¶
-
visit_has_self
(node, children) → owlapy.model.OWLObjectHasSelf[source]¶
-
visit_individual_iri
(node, children) → owlapy.model.OWLNamedIndividual[source]¶
-
visit_integer_literal
(node, children) → owlapy.model.OWLLiteral[source]¶
-
visit_iri
(node, children) → owlapy.model.IRI[source]¶
-
visit_literal
(node, children) → owlapy.model.OWLLiteral[source]¶
-
visit_object_property
(node, children) → owlapy.model.OWLObjectPropertyExpression[source]¶
-
visit_object_property_iri
(node, children) → owlapy.model.OWLObjectProperty[source]¶
-
visit_parentheses
(node, children) → owlapy.model.OWLClassExpression[source]¶
-
visit_primary
(node, children) → owlapy.model.OWLClassExpression[source]¶
-
visit_simple_iri
(node, children) → owlapy.model.IRI[source]¶
-
visit_some_only_res
(node, children) → owlapy.model.OWLQuantifiedObjectRestriction[source]¶
-
visit_string_literal_no_language
(node, children) → owlapy.model.OWLLiteral[source]¶
-
visit_typed_literal
(node, children) → owlapy.model.OWLLiteral[source]¶
-
visit_value_res
(node, children) → owlapy.model.OWLObjectHasValue[source]¶