From 71e843801f6506ca29d0127a79895912125cb65c Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Tue, 25 Jan 2022 09:53:33 +0400 Subject: [PATCH] Add initial ontology support --- ontology.owl | 184 +++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 3 +- src/main.py | 3 + src/ontology.py | 9 +++ 4 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 ontology.owl create mode 100644 src/ontology.py diff --git a/ontology.owl b/ontology.owl new file mode 100644 index 0000000..c3c9b97 --- /dev/null +++ b/ontology.owl @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Вывожу баланс карты + + + + + 1 + + + + + Сообщить про ограничения карты + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/requirements.txt b/requirements.txt index f471c42..7ae94a2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ scipy==1.7.3 requests==2.27.1 anytree==2.8.0 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 \ No newline at end of file +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 \ No newline at end of file diff --git a/src/main.py b/src/main.py index c7a7f0c..136747a 100644 --- a/src/main.py +++ b/src/main.py @@ -4,6 +4,7 @@ import sys import warnings from src.nlp import NLP +from src.ontology import Ontology from syntax import Syntax if not sys.warnoptions: @@ -24,6 +25,8 @@ def _main(): print(f'Parse tree:\n{parse_tree}') nouns = NLP().run(parse_tree) print(f'Nouns:\n{nouns}') + onto = Ontology() + print(f'Test: {onto.run()}') if __name__ == '__main__': diff --git a/src/ontology.py b/src/ontology.py new file mode 100644 index 0000000..9ff91f4 --- /dev/null +++ b/src/ontology.py @@ -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