cognitum-octopus / cognipy Goto Github PK
View Code? Open in Web Editor NEWIn-memory Graph Database and Knowledge Graph with Natural Language Interface, compatible with Pandas
Home Page: https://cognitum-octopus.github.io/cognipy/
License: Other
In-memory Graph Database and Knowledge Graph with Natural Language Interface, compatible with Pandas
Home Page: https://cognitum-octopus.github.io/cognipy/
License: Other
Fluent Editor is using 'utf-8-sig' encoding and it needs to be used when opening these files e.g.:
'''onto=Ontology("cnl/string",'\n'.join(open(fn,"rt",encoding='utf-8-sig').read() for fn in ["data/sample-data.encnl"]))'''
Please update documentation and examples
I tried the examples in a cognipy installation under Ubuntu. At first it seemed that everything works as expected, but suddenly I started to receive the following error:
Traceback (most recent call last):
File "check_consistency.py", line 28, in <module>
printReasoningInfo(onto)
File "check_consistency.py", line 15, in printReasoningInfo
info=onto.reasoningInfo()
File "/usr/local/lib/python3.7/dist-packages/cognipy/ontology.py", line 299, in reasoningInfo
self.super_concepts_of("a thing")
File "/usr/local/lib/python3.7/dist-packages/cognipy/ontology.py", line 179, in super_concepts_of
return cognipy_call(self._uid, "GetSuperConceptsOf", cnl, direct)
File "/usr/local/lib/python3.7/dist-packages/cognipy/interop.py", line 71, in cognipy_call
raise translate_exception(json.loads(js))
Exception: [
"InvalidOperationException",
{
"ClassName": "System.InvalidOperationException",
"Message": "The reasoner is not initialized. You need to call Load... before calling this method.",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at CogniPy.CogniPySvr.get_reasoner () [0x00008] in <f8783c48f78341ba843524fd57b41eb3>:0 \n at CogniPy.CogniPySvr.Materialize () [0x0001b] in <f8783c48f78341ba843524fd57b41eb3>:0 \n at CogniPy.CogniPySvr.GetSuperConceptsOf (System.String cnlName, System.Boolean direct) [0x00000] in <f8783c48f78341ba843524fd57b41eb3>:0 \n at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)\n at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <533173d24dae460899d2b10975534bb0>:0 ",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": null,
"HResult": -2146233079,
"Source": "CogniPyLib"
}
]
My python version is 3.7.12 and mono version is 6.12.0.122.
I will submit a Dockerfile which will allow to reproduce the error.
Update:
example.tar.gz
Sometimes we need to use n-ary relations e.g.:
Prime is a number with a specific-property.
Chart-101 presents information about Cat from 2001 until 2012.
Currently modalities are not exported to OWL
https://www.isibang.ac.in/~bisu/ontology/mod-ontology-09092016.owl
Providing path to non-existing encnl file the error is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "venv/lib/python3.6/site-packages/cognipy/ontology.py", line 104, in __init__
modalCheck, passParamsAsCnl, stop_on_error)
File "venv/lib/python3.6/site-packages/cognipy/interop.py", line 71, in cognipy_call
raise translate_exception(json.loads(js))
Exception: [
"IllegalArgumentException",
{
"ClassName": "java.lang.IllegalArgumentException",
"Message": "URI is not absolute",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at CogniPy.CogniPySvr.Load (CogniPy.ReferenceManager+WhatToLoad whatToLoad, System.String contentToLoad, CogniPy.CNL.DL.Paragraph impliAst, System.Boolean throwOnException, System.Boolean loadAnns, System.Boolean materialize, System.Boolean modalChecker) [0x00057] in <f8783c48f78341ba843524fd57b41eb3>:0 \n at CogniPy.CogniPySvr.LoadCnl (System.String filename, CogniPy.CNL.DL.Paragraph impliAst, System.Boolean throwOnException, System.Boolean loadAnns, System.Boolean materialize, System.Boolean modalChecker) [0x00000] in <f8783c48f78341ba843524fd57b41eb3>:0 \n at CogniPy.CogniPySvr.LoadCnl (System.String filename, System.Boolean loadAnnotations, System.Boolean materialize, System.Boolean modalChecker, System.Boolean throwOnError) [0x00000] in <f8783c48f78341ba843524fd57b41eb3>:0 \n at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)\n at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <8f2c484307284b51944a1a13a14c0266>:0 ",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": null,
"HResult": -2146233088,
"Source": "CogniPyLib",
"$0": {
"$0": {
"type": "java.lang.IllegalArgumentException, IKVM.OpenJDK.Core, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58",
"sig": null
},
"$1": {
"$0": {
"type": "java.lang.RuntimeException, IKVM.OpenJDK.Core, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58",
"sig": null
},
"$1": {
"$0": {
"type": "java.lang.Exception, IKVM.OpenJDK.Core, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58",
"sig": null
},
"$1": {
"$0": {
"type": "java.lang.Throwable, IKVM.OpenJDK.Core, Version=8.1.5717.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58",
"sig": null
},
"$1": "Ljava/lang/Throwable;",
"$2": "Ljava/lang/String;",
"$3": "[Ljava/lang/StackTraceElement;",
"$4": "Ljava/util/List;",
"$5": null,
"$data": "FAFyASgAE2phdmEubGFuZy5UaHJvd2FibGXVxjUnOXe4ywMABEwABWNhdXNlARBMAA1kZXRhaWxNZXNzYWdlAQ1bAApzdGFja1RyYWNlARdMABRzdXBwcmVzc2VkRXhjZXB0aW9ucwIA"
},
"$data": "FAFyASAAE2phdmEubGFuZy5FeGNlcHRpb27Q/R8+GjscxAIAAAEA"
},
"$data": "FAFyAScAGmphdmEubGFuZy5SdW50aW1lRXhjZXB0aW9unl8GRwo0g+UCAAABAA=="
},
"$data": "FAFyAS8AImphdmEubGFuZy5JbGxlZ2FsQXJndW1lbnRFeGNlcHRpb261iXPTfWaPvAIAAAEA"
},
"$2": "URI is not absolute",
"$3": [],
"$4": [],
"$data": "CgUA"
}
]
To reproduce (on Ubuntu):
onto = Ontology("cnl/file","nonexisting.encnl")
Currently, CNL Edit uses ipywidgets. This has many limitations including problems with JupyterLab which is the future of the data-science. We need to investigate the best approach and start working on it.
Using
onto = Ontology("cnl/file","hello.encnl",stop_on_error=True)
Works with
%%writefile hello.encnl
Kas is something.
Errors with
%%writefile hello.encnl
K9s is something.
---------------------------------------------------------------------------
ParseException Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 onto = Ontology("cnl/file","hello.encnl",stop_on_error=True)
File /opt/conda/lib/python3.10/site-packages/cognipy/ontology.py:103, in Ontology.__init__(self, source, arg, verbose, evaluator, graph_attribute_formatter, stop_on_error)
101 self._uid = cognipy_create()
102 if source == "cnl/file":
--> 103 cognipy_call(self._uid, "LoadCnl", arg, loadAnnotations,
104 modalCheck, passParamsAsCnl, stop_on_error)
105 elif source == "cnl/string":
106 cognipy_call(self._uid, "LoadCnlFromString", arg,
107 loadAnnotations, modalCheck, passParamsAsCnl, stop_on_error)
File /opt/conda/lib/python3.10/site-packages/cognipy/interop.py:76, in cognipy_call(uid, cmd, *args)
74 js="\r\n".join(ja)
75 if fl.strip()=='@exception':
---> 76 raise translate_exception(json.loads(js))
77 return json.loads(js)
ParseException: {'Errors': [{'Line': 0, 'Column': 0, 'Pos': 0, 'Context': 'K9s is something.\n', 'Hint': 'K^9s is something.'}]}
(running in a jupyther/minimal image with mono added)
Please refer to below ontology:
Something is a human if-and-only-if-it-either is a child, is an old-man, is a middle-aged-man or is a young-man.
Jan is a child.
Jan is an old-man.
After loading it, reasoner doesn't catch the inconsistency - the reasoningInfo() function returns no problems.
Analyze code in CogniPySvr class in terms of unused/untested methods since it's most exposed class to a user
Error occures when following ontology is loaded https://www.cs.upc.edu/~loliva/OntoWAWO+.owl and trying to do draw_graph().
If X connects-to something that connects-to Y then Y follows X.
follows->followed
Nothing but workclass
instead of
nothing but workclasses
It seems there's an error with the disjointness operator in CogniPy.
The following assertions result with an inconsistency detected in the ontology:
Anything either
is a second-name,
is a first-name or
is a last-name
or-something-else.
First-Name-1 is a first-name.
First-Name-1 is a last-name.
While the following assertions does not:
Anything either
is a first-name or
is a last-name
or-something-else.
First-Name-1 is a first-name.
First-Name-1 is a last-name.
BTW there's a similar issue with assertions on relations.
Both these work:
No first-name is pesel-num.
Every first-name connects-with nothing-but thing that is a pesel-num.
First-Name-6 is a first-name.
First-Name-7 is a first-name.
First-Name-6 connects-with First-Name-7.
Causes error.
No first-name is last-name.
Every first-name connects-with nothing-but thing that is a last-name.
First-Name-6 is a first-name.
First-Name-7 is a first-name.
First-Name-6 connects-with First-Name-7.
Causes error too.
But:
No first-name is last-name.
No first-name is pesel-num.
Every first-name connects-with nothing-but thing that is a last-name and-or pesel-num.
First-Name-6 is a first-name.
First-Name-7 is a first-name.
First-Name-6 connects-with First-Name-7.
Does not cause an error.
Author
apohllo commented 4 days ago
The RDF/OWL conversions are as follows, for the first type of assertion:
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.cognitum.eu/onto#connectsWith" />
<owl:allValuesFrom rdf:resource="http://www.cognitum.eu/onto#lastName" />
</owl:Restriction>
</rdfs:subClassOf>
and for the second type:
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.cognitum.eu/onto#connectsWith" />
<owl:allValuesFrom>
<owl:Class>
<owl:unionOf rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.cognitum.eu/onto#lastName" />
<rdf:Description rdf:about="http://www.cognitum.eu/onto#peselNum" />
</owl:unionOf>
</owl:Class>
</owl:allValuesFrom>
</owl:Restriction>
</rdfs:subClassOf>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.