src.ergoai package
Submodules
src.ergoai.ergoai module
ErgoAI module interface – contains convenience functions.
Converts a JSON file to an ERGO file. |
|
Queries an ERGO knowledge base/graph using ErgoAI. |
- src.ergoai.ergoai.json_to_ergo(json_file, output_file=None)[source]
Converts a JSON file to an ERGO file.
Note
If a JSON file needs to be converted to an ERGO file, this function MUST be called first before calling
query_ergoai().If a
KnowledgeBaseorKnowledgeGraphobject is passed, then the object is updated with the ERGO file path.
Danger
This function can only be called/used once per python session. If you need to convert multiple JSON files to ERGO files, you must start a new session each time, otherwise subsequent calls to
json_to_ergo()will cause the current python session to crash.
- Usage example:
>>> from src.ergoai.ergoai import json_to_ergo >>> ergo_file = json_to_ergo(json_file="cse_courses.json") >>> print(ergo_file) cse_courses.ergo
- Parameters:
json_file (
Union[KnowledgeBase,KnowledgeGraph,str]) – Input JSON file (KnowledgeBaseorKnowledgeGraphobject) to be converted to ERGO file.output_file (
Optional[str]) – Output filename. If not specified, then a new file of the same name is created, with a ‘.ergo’ file extension. Defaults to None.
- Return type:
- Returns:
Path to the output ERGO file.
- src.ergoai.ergoai.query_ergoai(knowledge, query)[source]
Queries an ERGO knowledge base/graph using ErgoAI.
Warning
This function is still a work in progress.
- Parameters:
knowledge (
Union[KnowledgeBase,KnowledgeGraph]) – Input knowledge base/graph ERGO file (orKnowledgeBaseorKnowledgeGraphobject) to be queried.query (
str) – Query to be passed to ErgoAI.
- Return type:
- Returns:
Results of the query.