Add initial ontology support
This commit is contained in:
parent
b59505fc25
commit
71e843801f
184
ontology.owl
Normal file
184
ontology.owl
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<Ontology xmlns="http://www.w3.org/2002/07/owl#"
|
||||||
|
xml:base="http://www.semanticweb.org/alalf/ontologies/2022/0/untitled-ontology-5"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:xml="http://www.w3.org/XML/1998/namespace"
|
||||||
|
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
|
||||||
|
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
|
||||||
|
ontologyIRI="http://www.semanticweb.org/alalf/ontologies/2022/0/untitled-ontology-5">
|
||||||
|
<Prefix name="owl" IRI="http://www.w3.org/2002/07/owl#"/>
|
||||||
|
<Prefix name="rdf" IRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>
|
||||||
|
<Prefix name="xml" IRI="http://www.w3.org/XML/1998/namespace"/>
|
||||||
|
<Prefix name="xsd" IRI="http://www.w3.org/2001/XMLSchema#"/>
|
||||||
|
<Prefix name="rdfs" IRI="http://www.w3.org/2000/01/rdf-schema#"/>
|
||||||
|
<Declaration>
|
||||||
|
<Class IRI="#Concept"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<Class IRI="#Event"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<Class IRI="#Term"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<ObjectProperty IRI="#hasEvent"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<ObjectProperty IRI="#hasTerm"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<DataProperty IRI="#hasDescription"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<DataProperty IRI="#hasPriority"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<NamedIndividual IRI="#Баланс_карты"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<NamedIndividual IRI="#Вывести_баланс_карты"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<NamedIndividual IRI="#Лимит_карты"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<NamedIndividual IRI="#Сообщить_про_ограничения_карты"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<NamedIndividual IRI="#баланс"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<NamedIndividual IRI="#карта"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<NamedIndividual IRI="#лимит"/>
|
||||||
|
</Declaration>
|
||||||
|
<Declaration>
|
||||||
|
<NamedIndividual IRI="#ограничение"/>
|
||||||
|
</Declaration>
|
||||||
|
<DisjointClasses>
|
||||||
|
<Class IRI="#Concept"/>
|
||||||
|
<Class IRI="#Event"/>
|
||||||
|
<Class IRI="#Term"/>
|
||||||
|
</DisjointClasses>
|
||||||
|
<ClassAssertion>
|
||||||
|
<Class IRI="#Concept"/>
|
||||||
|
<NamedIndividual IRI="#Баланс_карты"/>
|
||||||
|
</ClassAssertion>
|
||||||
|
<ClassAssertion>
|
||||||
|
<Class IRI="#Event"/>
|
||||||
|
<NamedIndividual IRI="#Вывести_баланс_карты"/>
|
||||||
|
</ClassAssertion>
|
||||||
|
<ClassAssertion>
|
||||||
|
<Class IRI="#Concept"/>
|
||||||
|
<NamedIndividual IRI="#Лимит_карты"/>
|
||||||
|
</ClassAssertion>
|
||||||
|
<ClassAssertion>
|
||||||
|
<Class IRI="#Term"/>
|
||||||
|
<NamedIndividual IRI="#баланс"/>
|
||||||
|
</ClassAssertion>
|
||||||
|
<ClassAssertion>
|
||||||
|
<Class IRI="#Term"/>
|
||||||
|
<NamedIndividual IRI="#карта"/>
|
||||||
|
</ClassAssertion>
|
||||||
|
<ClassAssertion>
|
||||||
|
<Class IRI="#Term"/>
|
||||||
|
<NamedIndividual IRI="#лимит"/>
|
||||||
|
</ClassAssertion>
|
||||||
|
<ClassAssertion>
|
||||||
|
<Class IRI="#Term"/>
|
||||||
|
<NamedIndividual IRI="#ограничение"/>
|
||||||
|
</ClassAssertion>
|
||||||
|
<ObjectPropertyAssertion>
|
||||||
|
<ObjectProperty IRI="#hasEvent"/>
|
||||||
|
<NamedIndividual IRI="#Баланс_карты"/>
|
||||||
|
<NamedIndividual IRI="#Вывести_баланс_карты"/>
|
||||||
|
</ObjectPropertyAssertion>
|
||||||
|
<ObjectPropertyAssertion>
|
||||||
|
<ObjectProperty IRI="#hasTerm"/>
|
||||||
|
<NamedIndividual IRI="#Баланс_карты"/>
|
||||||
|
<NamedIndividual IRI="#баланс"/>
|
||||||
|
</ObjectPropertyAssertion>
|
||||||
|
<ObjectPropertyAssertion>
|
||||||
|
<ObjectProperty IRI="#hasTerm"/>
|
||||||
|
<NamedIndividual IRI="#Баланс_карты"/>
|
||||||
|
<NamedIndividual IRI="#карта"/>
|
||||||
|
</ObjectPropertyAssertion>
|
||||||
|
<ObjectPropertyAssertion>
|
||||||
|
<ObjectProperty IRI="#hasEvent"/>
|
||||||
|
<NamedIndividual IRI="#Лимит_карты"/>
|
||||||
|
<NamedIndividual IRI="#Сообщить_про_ограничения_карты"/>
|
||||||
|
</ObjectPropertyAssertion>
|
||||||
|
<ObjectPropertyAssertion>
|
||||||
|
<ObjectProperty IRI="#hasTerm"/>
|
||||||
|
<NamedIndividual IRI="#Лимит_карты"/>
|
||||||
|
<NamedIndividual IRI="#карта"/>
|
||||||
|
</ObjectPropertyAssertion>
|
||||||
|
<ObjectPropertyAssertion>
|
||||||
|
<ObjectProperty IRI="#hasTerm"/>
|
||||||
|
<NamedIndividual IRI="#Лимит_карты"/>
|
||||||
|
<NamedIndividual IRI="#лимит"/>
|
||||||
|
</ObjectPropertyAssertion>
|
||||||
|
<ObjectPropertyAssertion>
|
||||||
|
<ObjectProperty IRI="#hasTerm"/>
|
||||||
|
<NamedIndividual IRI="#Лимит_карты"/>
|
||||||
|
<NamedIndividual IRI="#ограничение"/>
|
||||||
|
</ObjectPropertyAssertion>
|
||||||
|
<DataPropertyAssertion>
|
||||||
|
<DataProperty IRI="#hasDescription"/>
|
||||||
|
<NamedIndividual IRI="#Вывести_баланс_карты"/>
|
||||||
|
<Literal>Вывожу баланс карты</Literal>
|
||||||
|
</DataPropertyAssertion>
|
||||||
|
<DataPropertyAssertion>
|
||||||
|
<DataProperty IRI="#hasPriority"/>
|
||||||
|
<NamedIndividual IRI="#Вывести_баланс_карты"/>
|
||||||
|
<Literal datatypeIRI="http://www.w3.org/2001/XMLSchema#int">1</Literal>
|
||||||
|
</DataPropertyAssertion>
|
||||||
|
<DataPropertyAssertion>
|
||||||
|
<DataProperty IRI="#hasDescription"/>
|
||||||
|
<NamedIndividual IRI="#Сообщить_про_ограничения_карты"/>
|
||||||
|
<Literal>Сообщить про ограничения карты</Literal>
|
||||||
|
</DataPropertyAssertion>
|
||||||
|
<DataPropertyAssertion>
|
||||||
|
<DataProperty IRI="#hasPriority"/>
|
||||||
|
<NamedIndividual IRI="#Сообщить_про_ограничения_карты"/>
|
||||||
|
<Literal datatypeIRI="http://www.w3.org/2001/XMLSchema#int">5</Literal>
|
||||||
|
</DataPropertyAssertion>
|
||||||
|
<ObjectPropertyDomain>
|
||||||
|
<ObjectProperty IRI="#hasEvent"/>
|
||||||
|
<Class IRI="#Concept"/>
|
||||||
|
</ObjectPropertyDomain>
|
||||||
|
<ObjectPropertyDomain>
|
||||||
|
<ObjectProperty IRI="#hasTerm"/>
|
||||||
|
<Class IRI="#Concept"/>
|
||||||
|
</ObjectPropertyDomain>
|
||||||
|
<ObjectPropertyRange>
|
||||||
|
<ObjectProperty IRI="#hasEvent"/>
|
||||||
|
<Class IRI="#Event"/>
|
||||||
|
</ObjectPropertyRange>
|
||||||
|
<ObjectPropertyRange>
|
||||||
|
<ObjectProperty IRI="#hasTerm"/>
|
||||||
|
<Class IRI="#Term"/>
|
||||||
|
</ObjectPropertyRange>
|
||||||
|
<DataPropertyDomain>
|
||||||
|
<DataProperty IRI="#hasDescription"/>
|
||||||
|
<Class IRI="#Event"/>
|
||||||
|
</DataPropertyDomain>
|
||||||
|
<DataPropertyDomain>
|
||||||
|
<DataProperty IRI="#hasPriority"/>
|
||||||
|
<Class IRI="#Event"/>
|
||||||
|
</DataPropertyDomain>
|
||||||
|
<DataPropertyRange>
|
||||||
|
<DataProperty IRI="#hasDescription"/>
|
||||||
|
<Datatype abbreviatedIRI="xsd:string"/>
|
||||||
|
</DataPropertyRange>
|
||||||
|
<DataPropertyRange>
|
||||||
|
<DataProperty IRI="#hasPriority"/>
|
||||||
|
<Datatype abbreviatedIRI="xsd:int"/>
|
||||||
|
</DataPropertyRange>
|
||||||
|
</Ontology>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi -->
|
||||||
|
|
@ -2,4 +2,5 @@ scipy==1.7.3
|
|||||||
requests==2.27.1
|
requests==2.27.1
|
||||||
anytree==2.8.0
|
anytree==2.8.0
|
||||||
spacy==3.2.1
|
spacy==3.2.1
|
||||||
https://github.com/explosion/spacy-models/releases/download/ru_core_news_sm-3.2.0/ru_core_news_sm-3.2.0.tar.gz
|
https://github.com/explosion/spacy-models/releases/download/ru_core_news_sm-3.2.0/ru_core_news_sm-3.2.0.tar.gz
|
||||||
|
Owlready2==0.36
|
@ -4,6 +4,7 @@ import sys
|
|||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from src.nlp import NLP
|
from src.nlp import NLP
|
||||||
|
from src.ontology import Ontology
|
||||||
from syntax import Syntax
|
from syntax import Syntax
|
||||||
|
|
||||||
if not sys.warnoptions:
|
if not sys.warnoptions:
|
||||||
@ -24,6 +25,8 @@ def _main():
|
|||||||
print(f'Parse tree:\n{parse_tree}')
|
print(f'Parse tree:\n{parse_tree}')
|
||||||
nouns = NLP().run(parse_tree)
|
nouns = NLP().run(parse_tree)
|
||||||
print(f'Nouns:\n{nouns}')
|
print(f'Nouns:\n{nouns}')
|
||||||
|
onto = Ontology()
|
||||||
|
print(f'Test: {onto.run()}')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
9
src/ontology.py
Normal file
9
src/ontology.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from owlready2 import get_ontology
|
||||||
|
|
||||||
|
|
||||||
|
class Ontology:
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self._onto = get_ontology("file://./ontology.owl").load()
|
||||||
|
|
||||||
|
def run(self) -> str:
|
||||||
|
return self._onto.Concept
|
Loading…
Reference in New Issue
Block a user