From dd5a5c7ea85560e2698af162e9586809bc0b80c7 Mon Sep 17 00:00:00 2001 From: xubowen Date: Wed, 16 Feb 2022 10:28:55 +0800 Subject: [PATCH] v0.0.1 pre-alpha --- .gitignore | 2 +- .vscode/launch.json | 4 +- LICENSE | 22 ++++++++ MANIFEST.in | 5 ++ README.en.md | 38 ------------- README.md | 55 ++++++++++--------- README.zh-cn.md | 38 +++++++++++++ Tests/test_Bag.py | 6 +- Tests/test_Compound.py | 12 ++-- Tests/test_Concept.py | 8 +-- Tests/test_Copula.py | 10 ++-- Tests/test_EvidentialBase.py | 8 +-- Tests/test_Examples.py | 6 +- Tests/test_GetIndex.py | 8 +-- Tests/test_InferenceEngine.py | 8 +-- Tests/test_Link.py | 12 ++-- Tests/test_Memory.py | 8 +-- Tests/test_NAL/test_BUG_NAL4.py | 18 +++--- Tests/test_NAL/test_NAL1.py | 16 +++--- Tests/test_NAL/test_NAL2.py | 2 +- Tests/test_NAL/test_NAL3.py | 16 +++--- Tests/test_NAL/test_NAL4.py | 18 +++--- Tests/test_NAL/test_NAL5.py | 12 ++-- Tests/test_NAL/test_NAL6.py | 8 +-- Tests/test_NAL/test_NAL7.py | 6 +- Tests/test_NAL/test_NAL8.py | 4 +- Tests/test_NAL/test_NAL9.py | 6 +- Tests/test_ParseExamples.py | 6 +- Tests/test_Parser.py | 14 ++--- Tests/test_RuleMap/_trash/test_RuleLUT.py | 16 +++--- Tests/test_RuleMap/test_RuleMap.py | 8 +-- Tests/test_RuleMap/test_RuleMap_v2.py | 16 +++--- Tests/test_RuleMap/test_sparse_lut.py | 18 +++--- Tests/test_Table.py | 6 +- Tests/test_extract_feature.py | 8 +-- .../_trash/test_Substitution_v1.py | 8 +-- Tests/test_variable/test_Substitution.py | 10 ++-- Tests/test_variable/test_Term_Equal.py | 12 ++-- Tests/test_variable/test_Terms.py | 10 ++-- Tests/test_variable/test_Variable.py | 12 ++-- Tests/test_variable/test_Variable2.py | 12 ++-- Tests/utils_for_test.py | 18 +++--- Config.py => pynars/Config.py | 12 +++- Console.py => pynars/Console.py | 14 ++--- Global.py => pynars/Global.py | 0 .../NAL}/Functions/BudgetFunctions.py | 9 +-- .../NAL}/Functions/DesireValueFunctions.py | 2 +- .../Functions/ExtendedBooleanFunctions.py | 0 .../NAL}/Functions/StampFunctions.py | 6 +- .../NAL}/Functions/TemporalFunctions.py | 2 +- {NAL => pynars/NAL}/Functions/Tools.py | 18 +++--- .../NAL}/Functions/TruthValueFunctions.py | 2 +- .../Functions/UncertaintyMappingFunctions.py | 2 +- {NAL => pynars/NAL}/Functions/__init__.py | 0 .../NAL}/Inference/CompositionalRules.py | 4 +- .../Inference/ConditionalSyllogisticRules.py | 4 +- .../NAL}/Inference/ImmediateRules.py | 6 +- {NAL => pynars/NAL}/Inference/LocalRules.py | 20 +++---- .../NAL}/Inference/SyllogisticRules.py | 10 ++-- .../NAL}/Inference/TemporalRules.py | 12 ++-- {NAL => pynars/NAL}/Inference/__init__.py | 0 .../NAL}/MentalOperation/__init__.py | 0 {NAL => pynars/NAL}/MentalOperation/_aware.py | 26 ++++----- .../NAL}/MentalOperation/_execute.py | 20 +++---- .../NAL}/MentalOperation/_register.py | 2 +- .../NAL}/MetaLevelInference/GoalDerivation.py | 0 .../MetaLevelInference/QuestionDerivation.py | 0 .../MetaLevelInference/TemporalInference.py | 0 .../VariableSubstitution/Elimination.py | 4 +- .../VariableSubstitution/Introduction.py | 4 +- .../VariableSubstitution/Substitution.py | 4 +- .../VariableSubstitution/Unification.py | 8 +-- .../VariableSubstitution/__init__.py | 0 .../NAL/MetaLevelInference}/__init__.py | 0 .../_trash/VariableSubstitution_v1.py | 6 +- .../NAL}/Theorems/DecompositionalRules.py | 6 +- .../NAL}/Theorems/StructuralRules.py | 4 +- .../NAL}/Theorems/TransformRules.py | 6 +- {NAL => pynars/NAL}/Theorems/__init__.py | 0 {Narsese/Parser => pynars/NAL}/__init__.py | 0 {NAL => pynars/NAL}/_generate_init_file.py | 0 .../NARS}/Control/Reasoner_OpenNARS_3_0_4.py | 16 +++--- {NARS => pynars/NARS}/Control/__init__.py | 0 .../NARS}/DataStructures/__init__.py | 0 .../NARS}/DataStructures/_py/Bag.py | 6 +- .../NARS}/DataStructures/_py/Buffer.py | 4 +- .../NARS}/DataStructures/_py/Channel.py | 8 +-- .../NARS}/DataStructures/_py/Concept.py | 12 ++-- .../NARS}/DataStructures/_py/Link.py | 16 +++--- .../NARS}/DataStructures/_py/Memory.py | 20 +++---- .../NARS}/DataStructures/_py/Table.py | 2 +- pynars/NARS/DataStructures/_py/__init__.py | 0 .../NARS}/InferenceEngine/Engine.py | 10 ++-- .../NARS}/InferenceEngine/GeneralEngine.py | 12 ++-- .../NARS}/InferenceEngine/TemporalEngine.py | 25 ++++----- .../NARS}/InferenceEngine/__init__.py | 0 .../NARS}/MentalOperation/Execution.py | 26 ++++----- .../MentalOperation/Interface_Awareness.py | 8 +-- .../MentalOperation/Interface_Execution.py | 8 +-- .../NARS}/MentalOperation/Register.py | 2 +- .../NARS}/MentalOperation/__init__.py | 0 .../Interface/Interface_CompositionalRules.py | 10 ++-- .../Interface/Interface_ConditionalRules.py | 10 ++-- .../Interface_DecompositionalRules.py | 10 ++-- .../Interface/Interface_SyllogisticRules.py | 10 ++-- .../Interface/Interface_TemporalRules.py | 10 ++-- .../Interface/Interface_TransformRules.py | 10 ++-- pynars/NARS/RuleMap/Interface/__init__.py | 0 {NARS => pynars/NARS}/RuleMap/RuleMap_v2.py | 31 +++++++---- {NARS => pynars/NARS}/RuleMap/Rules/NAL1.py | 6 +- {NARS => pynars/NARS}/RuleMap/Rules/NAL2.py | 6 +- {NARS => pynars/NARS}/RuleMap/Rules/NAL3.py | 6 +- {NARS => pynars/NARS}/RuleMap/Rules/NAL4.py | 6 +- {NARS => pynars/NARS}/RuleMap/Rules/NAL5.py | 6 +- {NARS => pynars/NARS}/RuleMap/Rules/NAL6.py | 6 +- {NARS => pynars/NARS}/RuleMap/Rules/NAL7.py | 6 +- {NARS => pynars/NARS}/RuleMap/Rules/NAL8.py | 6 +- {NARS => pynars/NARS}/RuleMap/Rules/NAL9.py | 8 +-- .../NARS}/RuleMap/Rules/__init__.py | 0 .../NARS}/RuleMap/Rules/add_rule.py | 26 ++++----- {NARS => pynars/NARS}/RuleMap/__init__.py | 0 .../NARS}/RuleMap/_extract_feature.py | 6 +- .../NARS}/RuleMap/_trash/RuleMap_v1.py | 14 ++--- {NARS => pynars/NARS}/__init__.py | 0 pynars/Narsese/Parser/__init__.py | 0 {Narsese => pynars/Narsese}/Parser/_test.py | 0 .../Narsese}/Parser/_test_earley.py | 2 +- .../Narsese}/Parser/narsese.lark | 0 .../Narsese}/Parser/narsese_lark.py | 0 {Narsese => pynars/Narsese}/Parser/parser.py | 14 +---- {Narsese => pynars/Narsese}/__init__.py | 0 {Narsese => pynars/Narsese}/_py/Budget.py | 2 +- {Narsese => pynars/Narsese}/_py/Compound.py | 12 ++-- {Narsese => pynars/Narsese}/_py/Connector.py | 2 +- {Narsese => pynars/Narsese}/_py/Copula.py | 2 +- {Narsese => pynars/Narsese}/_py/Evidence.py | 6 +- {Narsese => pynars/Narsese}/_py/Interval.py | 0 {Narsese => pynars/Narsese}/_py/Item.py | 2 +- {Narsese => pynars/Narsese}/_py/Link.py | 0 {Narsese => pynars/Narsese}/_py/Operation.py | 0 {Narsese => pynars/Narsese}/_py/Sentence.py | 4 +- {Narsese => pynars/Narsese}/_py/Statement.py | 4 +- {Narsese => pynars/Narsese}/_py/Task.py | 0 {Narsese => pynars/Narsese}/_py/Tense.py | 0 {Narsese => pynars/Narsese}/_py/Term.py | 6 +- {Narsese => pynars/Narsese}/_py/Terms.py | 6 +- {Narsese => pynars/Narsese}/_py/Truth.py | 2 +- {Narsese => pynars/Narsese}/_py/Variable.py | 4 +- {Narsese => pynars/Narsese}/_py/__init__.py | 0 {Narsese => pynars/Narsese}/_pyx/Term.c | 0 {Narsese => pynars/Narsese}/_pyx/Term.pyx | 0 pynars/RL/Pong/__init__.py | 0 {RL => pynars/RL}/Pong/main.py | 0 pynars/RL/SuperMario/__init__.py | 0 pynars/RL/__init__.py | 0 pynars/__init__.py | 4 ++ config.json => pynars/config.json | 0 {utils => pynars/utils}/.vscode/launch.json | 0 {utils => pynars/utils}/IdEnum.py | 0 {utils => pynars/utils}/Index.py | 0 {utils => pynars/utils}/IndexVar.py | 0 {utils => pynars/utils}/Print.py | 0 pynars/utils/SparseLUT/__init__.py | 4 ++ pynars/utils/SparseLUT/branch_list.pyi | 49 +++++++++++++++++ pynars/utils/SparseLUT/sparse_lut.pyi | 20 +++++++ pynars/utils/__init__.py | 0 {utils => pynars/utils}/_trash/RuleLUT.py | 0 {utils => pynars/utils}/_trash/SparseLUT.py | 0 .../_trash/sparse_lut_v2/branch_list.py | 0 .../utils}/_trash/sparse_lut_v2/sparse_lut.py | 0 {utils => pynars/utils}/tools.py | 0 requirements.txt | 18 ++++++ setup.py | 50 +++++++++++++++++ utils/SparseLUT | 1 - 174 files changed, 748 insertions(+), 577 deletions(-) create mode 100644 LICENSE create mode 100644 MANIFEST.in delete mode 100644 README.en.md create mode 100644 README.zh-cn.md rename Config.py => pynars/Config.py (94%) rename Console.py => pynars/Console.py (94%) rename Global.py => pynars/Global.py (100%) rename {NAL => pynars/NAL}/Functions/BudgetFunctions.py (97%) rename {NAL => pynars/NAL}/Functions/DesireValueFunctions.py (95%) rename {NAL => pynars/NAL}/Functions/ExtendedBooleanFunctions.py (100%) rename {NAL => pynars/NAL}/Functions/StampFunctions.py (89%) rename {NAL => pynars/NAL}/Functions/TemporalFunctions.py (98%) rename {NAL => pynars/NAL}/Functions/Tools.py (95%) rename {NAL => pynars/NAL}/Functions/TruthValueFunctions.py (99%) rename {NAL => pynars/NAL}/Functions/UncertaintyMappingFunctions.py (94%) rename {NAL => pynars/NAL}/Functions/__init__.py (100%) rename {NAL => pynars/NAL}/Inference/CompositionalRules.py (98%) rename {NAL => pynars/NAL}/Inference/ConditionalSyllogisticRules.py (99%) rename {NAL => pynars/NAL}/Inference/ImmediateRules.py (95%) rename {NAL => pynars/NAL}/Inference/LocalRules.py (84%) rename {NAL => pynars/NAL}/Inference/SyllogisticRules.py (97%) rename {NAL => pynars/NAL}/Inference/TemporalRules.py (97%) rename {NAL => pynars/NAL}/Inference/__init__.py (100%) rename {NAL => pynars/NAL}/MentalOperation/__init__.py (100%) rename {NAL => pynars/NAL}/MentalOperation/_aware.py (75%) rename {NAL => pynars/NAL}/MentalOperation/_execute.py (82%) rename {NAL => pynars/NAL}/MentalOperation/_register.py (84%) rename {NAL => pynars/NAL}/MetaLevelInference/GoalDerivation.py (100%) rename {NAL => pynars/NAL}/MetaLevelInference/QuestionDerivation.py (100%) rename {NAL => pynars/NAL}/MetaLevelInference/TemporalInference.py (100%) rename {NAL => pynars/NAL}/MetaLevelInference/VariableSubstitution/Elimination.py (97%) rename {NAL => pynars/NAL}/MetaLevelInference/VariableSubstitution/Introduction.py (92%) rename {NAL => pynars/NAL}/MetaLevelInference/VariableSubstitution/Substitution.py (98%) rename {NAL => pynars/NAL}/MetaLevelInference/VariableSubstitution/Unification.py (95%) rename {NAL => pynars/NAL}/MetaLevelInference/VariableSubstitution/__init__.py (100%) rename {NARS/RuleMap/Interface => pynars/NAL/MetaLevelInference}/__init__.py (100%) rename {NAL => pynars/NAL}/MetaLevelInference/_trash/VariableSubstitution_v1.py (98%) rename {NAL => pynars/NAL}/Theorems/DecompositionalRules.py (98%) rename {NAL => pynars/NAL}/Theorems/StructuralRules.py (99%) rename {NAL => pynars/NAL}/Theorems/TransformRules.py (95%) rename {NAL => pynars/NAL}/Theorems/__init__.py (100%) rename {Narsese/Parser => pynars/NAL}/__init__.py (100%) rename {NAL => pynars/NAL}/_generate_init_file.py (100%) rename {NARS => pynars/NARS}/Control/Reasoner_OpenNARS_3_0_4.py (94%) rename {NARS => pynars/NARS}/Control/__init__.py (100%) rename {NARS => pynars/NARS}/DataStructures/__init__.py (100%) rename {NARS => pynars/NARS}/DataStructures/_py/Bag.py (98%) rename {NARS => pynars/NARS}/DataStructures/_py/Buffer.py (95%) rename {NARS => pynars/NARS}/DataStructures/_py/Channel.py (76%) rename {NARS => pynars/NARS}/DataStructures/_py/Concept.py (96%) rename {NARS => pynars/NARS}/DataStructures/_py/Link.py (96%) rename {NARS => pynars/NARS}/DataStructures/_py/Memory.py (95%) rename {NARS => pynars/NARS}/DataStructures/_py/Table.py (96%) create mode 100644 pynars/NARS/DataStructures/_py/__init__.py rename {NARS => pynars/NARS}/InferenceEngine/Engine.py (63%) rename {NARS => pynars/NARS}/InferenceEngine/GeneralEngine.py (95%) rename {NARS => pynars/NARS}/InferenceEngine/TemporalEngine.py (86%) rename {NARS => pynars/NARS}/InferenceEngine/__init__.py (100%) rename {NARS => pynars/NARS}/MentalOperation/Execution.py (63%) rename {NARS => pynars/NARS}/MentalOperation/Interface_Awareness.py (84%) rename {NARS => pynars/NARS}/MentalOperation/Interface_Execution.py (86%) rename {NARS => pynars/NARS}/MentalOperation/Register.py (84%) rename {NARS => pynars/NARS}/MentalOperation/__init__.py (100%) rename {NARS => pynars/NARS}/RuleMap/Interface/Interface_CompositionalRules.py (96%) rename {NARS => pynars/NARS}/RuleMap/Interface/Interface_ConditionalRules.py (98%) rename {NARS => pynars/NARS}/RuleMap/Interface/Interface_DecompositionalRules.py (93%) rename {NARS => pynars/NARS}/RuleMap/Interface/Interface_SyllogisticRules.py (97%) rename {NARS => pynars/NARS}/RuleMap/Interface/Interface_TemporalRules.py (92%) rename {NARS => pynars/NARS}/RuleMap/Interface/Interface_TransformRules.py (87%) create mode 100644 pynars/NARS/RuleMap/Interface/__init__.py rename {NARS => pynars/NARS}/RuleMap/RuleMap_v2.py (94%) rename {NARS => pynars/NARS}/RuleMap/Rules/NAL1.py (96%) rename {NARS => pynars/NARS}/RuleMap/Rules/NAL2.py (98%) rename {NARS => pynars/NARS}/RuleMap/Rules/NAL3.py (98%) rename {NARS => pynars/NARS}/RuleMap/Rules/NAL4.py (97%) rename {NARS => pynars/NARS}/RuleMap/Rules/NAL5.py (99%) rename {NARS => pynars/NARS}/RuleMap/Rules/NAL6.py (51%) rename {NARS => pynars/NARS}/RuleMap/Rules/NAL7.py (99%) rename {NARS => pynars/NARS}/RuleMap/Rules/NAL8.py (50%) rename {NARS => pynars/NARS}/RuleMap/Rules/NAL9.py (71%) rename {NARS => pynars/NARS}/RuleMap/Rules/__init__.py (100%) rename {NARS => pynars/NARS}/RuleMap/Rules/add_rule.py (83%) rename {NARS => pynars/NARS}/RuleMap/__init__.py (100%) rename {NARS => pynars/NARS}/RuleMap/_extract_feature.py (99%) rename {NARS => pynars/NARS}/RuleMap/_trash/RuleMap_v1.py (98%) rename {NARS => pynars/NARS}/__init__.py (100%) create mode 100644 pynars/Narsese/Parser/__init__.py rename {Narsese => pynars/Narsese}/Parser/_test.py (100%) rename {Narsese => pynars/Narsese}/Parser/_test_earley.py (87%) rename {Narsese => pynars/Narsese}/Parser/narsese.lark (100%) rename {Narsese => pynars/Narsese}/Parser/narsese_lark.py (100%) rename {Narsese => pynars/Narsese}/Parser/parser.py (96%) rename {Narsese => pynars/Narsese}/__init__.py (100%) rename {Narsese => pynars/Narsese}/_py/Budget.py (98%) rename {Narsese => pynars/Narsese}/_py/Compound.py (98%) rename {Narsese => pynars/Narsese}/_py/Connector.py (98%) rename {Narsese => pynars/Narsese}/_py/Copula.py (97%) rename {Narsese => pynars/Narsese}/_py/Evidence.py (96%) rename {Narsese => pynars/Narsese}/_py/Interval.py (100%) rename {Narsese => pynars/Narsese}/_py/Item.py (95%) rename {Narsese => pynars/Narsese}/_py/Link.py (100%) rename {Narsese => pynars/Narsese}/_py/Operation.py (100%) rename {Narsese => pynars/Narsese}/_py/Sentence.py (98%) rename {Narsese => pynars/Narsese}/_py/Statement.py (98%) rename {Narsese => pynars/Narsese}/_py/Task.py (100%) rename {Narsese => pynars/Narsese}/_py/Tense.py (100%) rename {Narsese => pynars/Narsese}/_py/Term.py (97%) rename {Narsese => pynars/Narsese}/_py/Terms.py (98%) rename {Narsese => pynars/Narsese}/_py/Truth.py (95%) rename {Narsese => pynars/Narsese}/_py/Variable.py (97%) rename {Narsese => pynars/Narsese}/_py/__init__.py (100%) rename {Narsese => pynars/Narsese}/_pyx/Term.c (100%) rename {Narsese => pynars/Narsese}/_pyx/Term.pyx (100%) create mode 100644 pynars/RL/Pong/__init__.py rename {RL => pynars/RL}/Pong/main.py (100%) create mode 100644 pynars/RL/SuperMario/__init__.py create mode 100644 pynars/RL/__init__.py create mode 100644 pynars/__init__.py rename config.json => pynars/config.json (100%) rename {utils => pynars/utils}/.vscode/launch.json (100%) rename {utils => pynars/utils}/IdEnum.py (100%) rename {utils => pynars/utils}/Index.py (100%) rename {utils => pynars/utils}/IndexVar.py (100%) rename {utils => pynars/utils}/Print.py (100%) create mode 100644 pynars/utils/SparseLUT/__init__.py create mode 100644 pynars/utils/SparseLUT/branch_list.pyi create mode 100644 pynars/utils/SparseLUT/sparse_lut.pyi create mode 100644 pynars/utils/__init__.py rename {utils => pynars/utils}/_trash/RuleLUT.py (100%) rename {utils => pynars/utils}/_trash/SparseLUT.py (100%) rename {utils => pynars/utils}/_trash/sparse_lut_v2/branch_list.py (100%) rename {utils => pynars/utils}/_trash/sparse_lut_v2/sparse_lut.py (100%) rename {utils => pynars/utils}/tools.py (100%) create mode 100644 requirements.txt create mode 100644 setup.py delete mode 160000 utils/SparseLUT diff --git a/.gitignore b/.gitignore index 28488d3..fd5fbd4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ __pycache__/ Tests/*.png *.pkl ./utils/SparseLUT - +temp/ # C extensions *.so diff --git a/.vscode/launch.json b/.vscode/launch.json index 95b4ea8..139a611 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -194,10 +194,10 @@ "name": "Python: console", "type": "python", "request": "launch", - "program": "Console.py", + "module": "pynars.Console", "console": "integratedTerminal", "args": [ - // "Tests/examples/single_step/nal7/nal7.7.nal" + "Tests/examples/single_step/nal7/nal7.7.nal" // "Tests/examples/single_step/nal5.query.nal" ] }, diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e8aef25 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License + +Copyright (c) 2022 PyNARS authors + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..cb928f0 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include requirements.txt +include pynars/*.json +include pynars/utils/SparseLUT/*.pyd +include pynars/utils/SparseLUT/*.pyi +include pynars/Narsese/Parser/*.lark \ No newline at end of file diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 18c12a7..0000000 --- a/README.en.md +++ /dev/null @@ -1,38 +0,0 @@ -# PyNARS - -#### Description -Python implementation of NARS (Non-Axiomatic-Reasoning-System) - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -Note: the version of the python package `tqdm` should be no higher than 3.1.4, otherwise the color display would be abnormal. This is because of a bug of `tqdm`, which leads to conflicts between `sty` and `tqdm` and cause unexpected color display of `sty`. - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index 9f6696c..f023bbd 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,41 @@ # PyNARS -#### 介绍 -Python implementation of NARS (Non-Axiomatic-Reasoning-System). -References: -OpenNARS 3.0.4, -Design Report of OpenNARS 3.1.0 +#### Description +Python implementation of NARS (Non-Axiomatic-Reasoning-System) -#### 软件架构 -软件架构说明 +Reference: + - OpenNARS 3.0.4, + - The Design Report of OpenNARS 3.1.0 -#### 安装教程 +#### Environments -1. xxxx -2. xxxx -3. xxxx + - Python version: 3.7.10. + - Only tested under this version, however, Python 3.7 and higher versions maybe acceptable. + - OS: Windows 10. + - Only tested under this OS, however, other OS might be ok. + - Packages Requirements: see `requirements.txt`. + - It is noted that the version of the python package `tqdm` should be no higher than 3.1.4, otherwise the color display would be abnormal. This is because of a bug of `tqdm`, which leads to conflicts between `sty` and `tqdm` and cause unexpected color display of `sty`. However, this constraints is not necessary, i.e., higher version of `tqdm` is ok if you don't mind abnormal display occuring. The abnormal case only occur when you first run the PyNARS when SparseLUT (Sparse Look-Up Table) is built. -#### 使用说明 +#### Installation -1. xxxx -2. xxxx -3. xxxx -#### 参与贡献 + pip install pynars -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +#### Instructions -#### 特技 +1. Copy the file `pynars/config.json` to your workspace-directory. *(Optional)* +2. In the workspace-directory, run cmd `python -m pynars.Console`. To execute an `*.nal` file, run cmd `python -m pynars.Console ` +3. Input Narsese in the console, input an positive integer to run a number of cycles, or input a comment which is a string with `'` as the beginning, e.g. `' your comment`. +4. Press `ctrl`+`C` to exit. -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +#### Contribution + +1. Fork the repository +2. Create Feat_xxx branch +3. Commit your code +4. Create Pull Request + + +**Note:** This document will be imporved in the future. \ No newline at end of file diff --git a/README.zh-cn.md b/README.zh-cn.md new file mode 100644 index 0000000..41387e9 --- /dev/null +++ b/README.zh-cn.md @@ -0,0 +1,38 @@ +# PyNARS + +#### 介绍 +Python implementation of NARS (Non-Axiomatic-Reasoning-System). + +Reference: + - OpenNARS 3.0.4, + - The Design Report of OpenNARS 3.1.0 + + +#### 运行环境 + + - Python版本: 3.7.10. + - 只有这个版本被测试过,但Python 3.7以及更高的版本应该都可以接受。 + - 操作系统: Windows 10. + - 仅在这个操作系统下做过测试,但其他的操作系统或许也可以。 + - 依赖包: 见`requirements.txt`. + - 请注意包`tqdm` 的版本不应超过3.1.4,否则颜色显示可能会异常。这是因为高版本`tqdm`中的BUG会导致包`sty`和`tqdm`之间的冲突,`sty`的颜色显示会出现错误。然而,这一约束不是必须的,即如果你不介意颜色显示异常则高版本的`tqdm`也可接受。异常显示只有在第一次运行PyNARS过程中构建稀疏查找表(SparseLUT)时出现。 + +#### 安装教程 + + + pip install pynars + + +#### 使用说明 + +1. 复制文件`pynars/config.json`到你的工作目录。 *(可选)* +2. 在工作目录下,运行命令`python -m pynars.Console`。若需要运行`*.nal`文件,则运行命令`python -m pynars.Console <文件名.nal>`。 +3. 在控制台中输入纳思语(Narsese),输入正整数运行一定的推理周期,或输入`'`开头的字符串作为i注释(例如`' 这是一条注释`)。 +4. 按下`ctrl`+`C`退出。 + +#### 参与贡献 + +1. Fork 本仓库 +2. 新建 Feat_xxx 分支 +3. 提交代码 +4. 新建 Pull Request diff --git a/Tests/test_Bag.py b/Tests/test_Bag.py index 1f49d0e..3bb90b1 100644 --- a/Tests/test_Bag.py +++ b/Tests/test_Bag.py @@ -1,8 +1,8 @@ -from Narsese import Budget +from pynars.Narsese import Budget import unittest -from NARS.DataStructures import Bag, Task, Concept -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth import matplotlib.pyplot as plt diff --git a/Tests/test_Compound.py b/Tests/test_Compound.py index bd1c810..24c1f92 100644 --- a/Tests/test_Compound.py +++ b/Tests/test_Compound.py @@ -1,15 +1,15 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector -from NAL.MetaLevelInference.VariableSubstitution import * -from Narsese._py.Variable import VarPrefix, Variable -from utils.IndexVar import IndexVar +from pynars.Narsese import Compound, Connector +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.Narsese._py.Variable import VarPrefix, Variable +from pynars.utils.IndexVar import IndexVar class TEST_Compound(unittest.TestCase): def test_0(self): diff --git a/Tests/test_Concept.py b/Tests/test_Concept.py index da233ee..7468166 100644 --- a/Tests/test_Concept.py +++ b/Tests/test_Concept.py @@ -1,10 +1,10 @@ -from Narsese import Budget +from pynars.Narsese import Budget import unittest -from NARS.DataStructures import Bag, Task -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth import Narsese -from NARS.DataStructures import Concept +from pynars.NARS.DataStructures import Concept class TEST_Concept(unittest.TestCase): def __init__(self, methodName: str = ...) -> None: diff --git a/Tests/test_Copula.py b/Tests/test_Copula.py index 133ff0a..48d2e39 100644 --- a/Tests/test_Copula.py +++ b/Tests/test_Copula.py @@ -1,11 +1,11 @@ -from Narsese import Budget +from pynars.Narsese import Budget import unittest -from NARS.DataStructures import Bag, Task -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth import Narsese -from NARS.DataStructures import Concept -from Narsese import Copula +from pynars.NARS.DataStructures import Concept +from pynars.Narsese import Copula class TEST_Concept(unittest.TestCase): def __init__(self, methodName: str = ...) -> None: diff --git a/Tests/test_EvidentialBase.py b/Tests/test_EvidentialBase.py index 18959a2..191e20b 100644 --- a/Tests/test_EvidentialBase.py +++ b/Tests/test_EvidentialBase.py @@ -1,10 +1,10 @@ -from Narsese import Budget +from pynars.Narsese import Budget import unittest -from NARS.DataStructures import Bag, Task, Concept -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth -from Narsese import Base, Task +from pynars.Narsese import Base, Task class TEST_Base(unittest.TestCase): def __init__(self, methodName: str = ...) -> None: diff --git a/Tests/test_Examples.py b/Tests/test_Examples.py index ffdaec7..77ab461 100644 --- a/Tests/test_Examples.py +++ b/Tests/test_Examples.py @@ -2,13 +2,13 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from utils.Print import out_print, PrintType, print_filename +from pynars.utils.Print import out_print, PrintType, print_filename examples_path = Path(__file__).parent/'examples' diff --git a/Tests/test_GetIndex.py b/Tests/test_GetIndex.py index 5424ab2..5ec9f2f 100644 --- a/Tests/test_GetIndex.py +++ b/Tests/test_GetIndex.py @@ -1,14 +1,14 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Link -from Narsese import Judgement, Term, Statement, Copula, Truth, Connector +from pynars.NARS.DataStructures import Bag, Task, Concept, Link +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth, Connector from pathlib import Path import Narsese -from Narsese._py.Compound import Compound +from pynars.Narsese._py.Compound import Compound -from utils.Print import out_print, PrintType, print_filename +from pynars.utils.Print import out_print, PrintType, print_filename class TEST_Get_Index(unittest.TestCase): '''Examples files in `application`.''' diff --git a/Tests/test_InferenceEngine.py b/Tests/test_InferenceEngine.py index 1288b5f..4736173 100644 --- a/Tests/test_InferenceEngine.py +++ b/Tests/test_InferenceEngine.py @@ -1,11 +1,11 @@ import NARS import unittest -from NARS.DataStructures import Bag -from NARS.DataStructures._py.Concept import Concept -from NARS.DataStructures._py.Memory import Memory +from pynars.NARS.DataStructures import Bag +from pynars.NARS.DataStructures._py.Concept import Concept +from pynars.NARS.DataStructures._py.Memory import Memory -from NARS.InferenceEngine import GeneralEngine +from pynars.NARS.InferenceEngine import GeneralEngine import Narsese diff --git a/Tests/test_Link.py b/Tests/test_Link.py index 69e1cbe..15bbd2c 100644 --- a/Tests/test_Link.py +++ b/Tests/test_Link.py @@ -2,16 +2,16 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Link -from NARS.DataStructures._py.Link import LinkType, TaskLink, TermLink -from NARS.DataStructures._py.Memory import Memory -from Narsese import Judgement, Term, Statement, Copula, Truth, Connector +from pynars.NARS.DataStructures import Bag, Task, Concept, Link +from pynars.NARS.DataStructures._py.Link import LinkType, TaskLink, TermLink +from pynars.NARS.DataStructures._py.Memory import Memory +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth, Connector from pathlib import Path import Narsese -from Narsese import Compound, Budget +from pynars.Narsese import Compound, Budget -from utils.Print import out_print, PrintType, print_filename +from pynars.utils.Print import out_print, PrintType, print_filename class TEST_Get_Index(unittest.TestCase): '''Examples files in `application`.''' diff --git a/Tests/test_Memory.py b/Tests/test_Memory.py index 7409745..b6c10bf 100644 --- a/Tests/test_Memory.py +++ b/Tests/test_Memory.py @@ -1,13 +1,13 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Memory, Concept -from NARS.DataStructures._py.Concept import Concept -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Memory, Concept +from pynars.NARS.DataStructures._py.Concept import Concept +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector +from pynars.Narsese import Compound, Connector def test_conceptualize(self): diff --git a/Tests/test_NAL/test_BUG_NAL4.py b/Tests/test_NAL/test_BUG_NAL4.py index e30c60d..761990e 100644 --- a/Tests/test_NAL/test_BUG_NAL4.py +++ b/Tests/test_NAL/test_BUG_NAL4.py @@ -1,21 +1,21 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from NARS.DataStructures._py.Link import TaskLink, TermLink -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.NARS.DataStructures._py.Link import TaskLink, TermLink +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector -from NAL.MetaLevelInference.VariableSubstitution import * -from Narsese import VarPrefix, Variable -from NARS.RuleMap import RuleMap_v2 -from NARS import Reasoner_3_0_4 as Reasoner +from pynars.Narsese import Compound, Connector +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.Narsese import VarPrefix, Variable +from pynars.NARS.RuleMap import RuleMap_v2 +from pynars.NARS import Reasoner_3_0_4 as Reasoner import Tests.utils_for_test as utils_for_test from Tests.utils_for_test import * -from NARS.RuleMap import Interface_TransformRules +from pynars.NARS.RuleMap import Interface_TransformRules # utils_for_test.rule_map = RuleMap_v2() diff --git a/Tests/test_NAL/test_NAL1.py b/Tests/test_NAL/test_NAL1.py index 98280ab..a656bb8 100644 --- a/Tests/test_NAL/test_NAL1.py +++ b/Tests/test_NAL/test_NAL1.py @@ -1,17 +1,17 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from NARS.DataStructures._py.Link import TaskLink, TermLink -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.NARS.DataStructures._py.Link import TaskLink, TermLink +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector -from NAL.MetaLevelInference.VariableSubstitution import * -from Narsese import VarPrefix, Variable -from NARS.RuleMap import RuleMap_v2 -from NARS import Reasoner_3_0_4 as Reasoner +from pynars.Narsese import Compound, Connector +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.Narsese import VarPrefix, Variable +from pynars.NARS.RuleMap import RuleMap_v2 +from pynars.NARS import Reasoner_3_0_4 as Reasoner import Tests.utils_for_test as utils_for_test from Tests.utils_for_test import * diff --git a/Tests/test_NAL/test_NAL2.py b/Tests/test_NAL/test_NAL2.py index 7addfdf..4af42c9 100644 --- a/Tests/test_NAL/test_NAL2.py +++ b/Tests/test_NAL/test_NAL2.py @@ -1,7 +1,7 @@ import unittest import Narsese -from NAL.MetaLevelInference.VariableSubstitution import * +from pynars.NAL.MetaLevelInference.VariableSubstitution import * from Tests.utils_for_test import * diff --git a/Tests/test_NAL/test_NAL3.py b/Tests/test_NAL/test_NAL3.py index 889691c..c848c0d 100644 --- a/Tests/test_NAL/test_NAL3.py +++ b/Tests/test_NAL/test_NAL3.py @@ -1,17 +1,17 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from NARS.DataStructures._py.Link import TaskLink, TermLink -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.NARS.DataStructures._py.Link import TaskLink, TermLink +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector -from NAL.MetaLevelInference.VariableSubstitution import * -from Narsese import VarPrefix, Variable -from NARS.RuleMap import RuleMap_v2 -from NARS import Reasoner_3_0_4 as Reasoner +from pynars.Narsese import Compound, Connector +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.Narsese import VarPrefix, Variable +from pynars.NARS.RuleMap import RuleMap_v2 +from pynars.NARS import Reasoner_3_0_4 as Reasoner import Tests.utils_for_test as utils_for_test from Tests.utils_for_test import * diff --git a/Tests/test_NAL/test_NAL4.py b/Tests/test_NAL/test_NAL4.py index 2940e7a..78994ff 100644 --- a/Tests/test_NAL/test_NAL4.py +++ b/Tests/test_NAL/test_NAL4.py @@ -1,21 +1,21 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from NARS.DataStructures._py.Link import TaskLink, TermLink -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.NARS.DataStructures._py.Link import TaskLink, TermLink +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector -from NAL.MetaLevelInference.VariableSubstitution import * -from Narsese import VarPrefix, Variable -from NARS.RuleMap import RuleMap_v2 -from NARS import Reasoner_3_0_4 as Reasoner +from pynars.Narsese import Compound, Connector +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.Narsese import VarPrefix, Variable +from pynars.NARS.RuleMap import RuleMap_v2 +from pynars.NARS import Reasoner_3_0_4 as Reasoner import Tests.utils_for_test as utils_for_test from Tests.utils_for_test import * -from NARS.RuleMap import Interface_TransformRules +from pynars.NARS.RuleMap import Interface_TransformRules # utils_for_test.rule_map = RuleMap_v2() diff --git a/Tests/test_NAL/test_NAL5.py b/Tests/test_NAL/test_NAL5.py index de752f0..950d2b0 100644 --- a/Tests/test_NAL/test_NAL5.py +++ b/Tests/test_NAL/test_NAL5.py @@ -7,12 +7,12 @@ import NARS import Narsese import Tests.utils_for_test as utils_for_test -from NAL.MetaLevelInference.VariableSubstitution import * -from NARS import Reasoner_3_0_4 as Reasoner -from NARS.DataStructures import Bag, Concept, Table, Task -from NARS.DataStructures._py.Link import TaskLink, TermLink -from NARS.RuleMap import RuleMap_v2 -from Narsese import (Compound, Connector, Copula, Judgement, Statement, Term, +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.NARS import Reasoner_3_0_4 as Reasoner +from pynars.NARS.DataStructures import Bag, Concept, Table, Task +from pynars.NARS.DataStructures._py.Link import TaskLink, TermLink +from pynars.NARS.RuleMap import RuleMap_v2 +from pynars.Narsese import (Compound, Connector, Copula, Judgement, Statement, Term, Truth, Variable, VarPrefix) from Tests.utils_for_test import * diff --git a/Tests/test_NAL/test_NAL6.py b/Tests/test_NAL/test_NAL6.py index 8a4b2fb..2ceeee5 100644 --- a/Tests/test_NAL/test_NAL6.py +++ b/Tests/test_NAL/test_NAL6.py @@ -1,12 +1,12 @@ import unittest -from NARS.DataStructures import Task -from NAL.MetaLevelInference.VariableSubstitution import * -from NARS.RuleMap import RuleMap_v2 +from pynars.NARS.DataStructures import Task +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.NARS.RuleMap import RuleMap_v2 import Tests.utils_for_test as utils_for_test from Tests.utils_for_test import * -from utils.Print import PrintType, out_print +from pynars.utils.Print import PrintType, out_print # utils_for_test.rule_map = RuleMap_v2() diff --git a/Tests/test_NAL/test_NAL7.py b/Tests/test_NAL/test_NAL7.py index 7b511bd..26bcaef 100644 --- a/Tests/test_NAL/test_NAL7.py +++ b/Tests/test_NAL/test_NAL7.py @@ -1,8 +1,8 @@ import unittest -from NAL.MetaLevelInference.VariableSubstitution import * -from NARS.InferenceEngine import GeneralEngine -from NARS.RuleMap import RuleMap_v2 +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.NARS.InferenceEngine import GeneralEngine +from pynars.NARS.RuleMap import RuleMap_v2 import Tests.utils_for_test as utils_for_test from Tests.utils_for_test import * diff --git a/Tests/test_NAL/test_NAL8.py b/Tests/test_NAL/test_NAL8.py index 59d46a9..8ed197c 100644 --- a/Tests/test_NAL/test_NAL8.py +++ b/Tests/test_NAL/test_NAL8.py @@ -1,7 +1,7 @@ import unittest -from NAL.MetaLevelInference.VariableSubstitution import * -from NARS.RuleMap import RuleMap_v2 +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.NARS.RuleMap import RuleMap_v2 import Tests.utils_for_test as utils_for_test from Tests.utils_for_test import * diff --git a/Tests/test_NAL/test_NAL9.py b/Tests/test_NAL/test_NAL9.py index fce6a01..393e07e 100644 --- a/Tests/test_NAL/test_NAL9.py +++ b/Tests/test_NAL/test_NAL9.py @@ -1,11 +1,11 @@ import unittest -from NAL.MetaLevelInference.VariableSubstitution import * -from NARS.RuleMap import RuleMap_v2 +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.NARS.RuleMap import RuleMap_v2 import Tests.utils_for_test as utils_for_test from Tests.utils_for_test import * -from NAL.MentalOperation import execute +from pynars.NAL.MentalOperation import execute nars = utils_for_test.nars diff --git a/Tests/test_ParseExamples.py b/Tests/test_ParseExamples.py index 461c392..9fac17a 100644 --- a/Tests/test_ParseExamples.py +++ b/Tests/test_ParseExamples.py @@ -1,13 +1,13 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from utils.Print import out_print, PrintType, print_filename +from pynars.utils.Print import out_print, PrintType, print_filename examples_path = Path(__file__).parent/'examples' single_step_path = examples_path/'single_step' diff --git a/Tests/test_Parser.py b/Tests/test_Parser.py index 787bfe8..e26bdb3 100644 --- a/Tests/test_Parser.py +++ b/Tests/test_Parser.py @@ -1,14 +1,14 @@ -from Narsese._py.Variable import VarPrefix, Variable -from Narsese._py.Sentence import Sentence, Tense +from pynars.Narsese._py.Variable import VarPrefix, Variable +from pynars.Narsese._py.Sentence import Sentence, Tense import Narsese -from Narsese import Budget -from Narsese import Compound, Connector +from pynars.Narsese import Budget +from pynars.Narsese import Compound, Connector import unittest -from Narsese import Question, Quest, Judgement, Goal +from pynars.Narsese import Question, Quest, Judgement, Goal -from NARS.DataStructures import Bag, Task, Concept -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth class TEST_Parser(unittest.TestCase): def __init__(self, methodName: str = ...) -> None: diff --git a/Tests/test_RuleMap/_trash/test_RuleLUT.py b/Tests/test_RuleMap/_trash/test_RuleLUT.py index 90eb189..5d54bd1 100644 --- a/Tests/test_RuleMap/_trash/test_RuleLUT.py +++ b/Tests/test_RuleMap/_trash/test_RuleLUT.py @@ -1,16 +1,16 @@ -from utils.RuleLUT import RuleLUT, Any +from pynars.utils.RuleLUT import RuleLUT, Any -from NARS.DataStructures._py.Link import LinkType -from NARS.RuleMap import Interface_SyllogisticRules, RuleMap_v2 -from Narsese import Budget +from pynars.NARS.DataStructures._py.Link import LinkType +from pynars.NARS.RuleMap import Interface_SyllogisticRules, RuleMap_v2 +from pynars.Narsese import Budget import unittest -from NARS.DataStructures import Bag, Task, Concept -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth -from utils.SparseLUT import SparseLUT +from pynars.utils.SparseLUT import SparseLUT -from NARS.RuleMap.RuleMap_v2 import CommonId +from pynars.NARS.RuleMap.RuleMap_v2 import CommonId class TEST_RuleLUT(unittest.TestCase): diff --git a/Tests/test_RuleMap/test_RuleMap.py b/Tests/test_RuleMap/test_RuleMap.py index e47e9de..778bcb3 100644 --- a/Tests/test_RuleMap/test_RuleMap.py +++ b/Tests/test_RuleMap/test_RuleMap.py @@ -1,10 +1,10 @@ -from Narsese import Budget +from pynars.Narsese import Budget import unittest -from NARS.DataStructures import Bag, Task, Concept -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth -from NARS.RuleMap import RuleMap_v1 +from pynars.NARS.RuleMap import RuleMap_v1 class TEST_RuleMap(unittest.TestCase): def __init__(self, methodName: str = ...) -> None: diff --git a/Tests/test_RuleMap/test_RuleMap_v2.py b/Tests/test_RuleMap/test_RuleMap_v2.py index f96176f..74e2e8b 100644 --- a/Tests/test_RuleMap/test_RuleMap_v2.py +++ b/Tests/test_RuleMap/test_RuleMap_v2.py @@ -1,14 +1,14 @@ -from Narsese import Budget +from pynars.Narsese import Budget import unittest -from NARS.DataStructures import Bag, Task -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth import Narsese -from NARS.DataStructures import Concept -from Narsese import Copula -from NARS.RuleMap import RuleMap_v2 -from NARS.RuleMap.RuleMap_v2 import CommonId -from NARS.DataStructures import LinkType +from pynars.NARS.DataStructures import Concept +from pynars.Narsese import Copula +from pynars.NARS.RuleMap import RuleMap_v2 +from pynars.NARS.RuleMap.RuleMap_v2 import CommonId +from pynars.NARS.DataStructures import LinkType class TEST_RuleMap_v2(unittest.TestCase): def __init__(self, methodName: str = ...) -> None: diff --git a/Tests/test_RuleMap/test_sparse_lut.py b/Tests/test_RuleMap/test_sparse_lut.py index 506deb5..3b7fcd7 100644 --- a/Tests/test_RuleMap/test_sparse_lut.py +++ b/Tests/test_RuleMap/test_sparse_lut.py @@ -1,16 +1,16 @@ from networkx.generators.random_graphs import fast_gnp_random_graph -from NARS.DataStructures._py.Link import LinkType -from NARS.RuleMap import Interface_SyllogisticRules, RuleMap_v2 -from Narsese import Budget +from pynars.NARS.DataStructures._py.Link import LinkType +from pynars.NARS.RuleMap import Interface_SyllogisticRules, RuleMap_v2 +from pynars.Narsese import Budget import unittest -from NARS.DataStructures import Bag, Task, Concept -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth -from utils.SparseLUT import SparseLUT, Any -from utils.tools import get_size -from NARS.RuleMap.RuleMap_v2 import CommonId -from utils.SparseLUT.sparse_lut_v3.branch_list import Node +from pynars.utils.SparseLUT import SparseLUT, Any +from pynars.utils.tools import get_size +from pynars.NARS.RuleMap.RuleMap_v2 import CommonId +from pynars.utils.SparseLUT.sparse_lut_v3.branch_list import Node class TEST_SparseLUT(unittest.TestCase): diff --git a/Tests/test_Table.py b/Tests/test_Table.py index ddc00c4..608f75b 100644 --- a/Tests/test_Table.py +++ b/Tests/test_Table.py @@ -1,12 +1,12 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector +from pynars.Narsese import Compound, Connector class TEST_Table(unittest.TestCase): diff --git a/Tests/test_extract_feature.py b/Tests/test_extract_feature.py index 60a8581..88d59d3 100644 --- a/Tests/test_extract_feature.py +++ b/Tests/test_extract_feature.py @@ -1,14 +1,14 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector +from pynars.Narsese import Compound, Connector -from NARS.RuleMap.RuleMap_v2 import extract_feature +from pynars.NARS.RuleMap.RuleMap_v2 import extract_feature class TEST_ExtractFeature(unittest.TestCase): diff --git a/Tests/test_variable/_trash/test_Substitution_v1.py b/Tests/test_variable/_trash/test_Substitution_v1.py index cb3d0c9..89ded8b 100644 --- a/Tests/test_variable/_trash/test_Substitution_v1.py +++ b/Tests/test_variable/_trash/test_Substitution_v1.py @@ -1,13 +1,13 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector -from NAL.MetaLevelInference.VariableSubstitution import * +from pynars.Narsese import Compound, Connector +from pynars.NAL.MetaLevelInference.VariableSubstitution import * class TEST_Substitution(unittest.TestCase): diff --git a/Tests/test_variable/test_Substitution.py b/Tests/test_variable/test_Substitution.py index 529003b..bbf42ec 100644 --- a/Tests/test_variable/test_Substitution.py +++ b/Tests/test_variable/test_Substitution.py @@ -1,14 +1,14 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector -from NAL.MetaLevelInference.VariableSubstitution import * -from Narsese import Terms +from pynars.Narsese import Compound, Connector +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.Narsese import Terms class TEST_Substitution(unittest.TestCase): diff --git a/Tests/test_variable/test_Term_Equal.py b/Tests/test_variable/test_Term_Equal.py index c62cdae..92f0e5f 100644 --- a/Tests/test_variable/test_Term_Equal.py +++ b/Tests/test_variable/test_Term_Equal.py @@ -1,15 +1,15 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector -from NAL.MetaLevelInference.VariableSubstitution import * -from Narsese._py.Variable import VarPrefix, Variable -from utils.IndexVar import IndexVar +from pynars.Narsese import Compound, Connector +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.Narsese._py.Variable import VarPrefix, Variable +from pynars.utils.IndexVar import IndexVar class TEST_Term_Equal(unittest.TestCase): diff --git a/Tests/test_variable/test_Terms.py b/Tests/test_variable/test_Terms.py index 6a16f90..ce973c2 100644 --- a/Tests/test_variable/test_Terms.py +++ b/Tests/test_variable/test_Terms.py @@ -1,14 +1,14 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector -from NAL.MetaLevelInference.VariableSubstitution import * -from Narsese import Terms +from pynars.Narsese import Compound, Connector +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.Narsese import Terms class TEST_Terms(unittest.TestCase): diff --git a/Tests/test_variable/test_Variable.py b/Tests/test_variable/test_Variable.py index 686b839..3e6b73a 100644 --- a/Tests/test_variable/test_Variable.py +++ b/Tests/test_variable/test_Variable.py @@ -1,15 +1,15 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector -from NAL.MetaLevelInference.VariableSubstitution import * -from Narsese._py.Variable import VarPrefix, Variable -from utils.IndexVar import IndexVar +from pynars.Narsese import Compound, Connector +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.Narsese._py.Variable import VarPrefix, Variable +from pynars.utils.IndexVar import IndexVar class TEST_Variable(unittest.TestCase): diff --git a/Tests/test_variable/test_Variable2.py b/Tests/test_variable/test_Variable2.py index 2821421..c323fd1 100644 --- a/Tests/test_variable/test_Variable2.py +++ b/Tests/test_variable/test_Variable2.py @@ -1,15 +1,15 @@ import NARS import unittest -from NARS.DataStructures import Bag, Task, Concept, Table -from Narsese import Judgement, Term, Statement, Copula, Truth +from pynars.NARS.DataStructures import Bag, Task, Concept, Table +from pynars.Narsese import Judgement, Term, Statement, Copula, Truth from pathlib import Path import Narsese -from Narsese import Compound, Connector -from NAL.MetaLevelInference.VariableSubstitution import * -from Narsese._py.Variable import VarPrefix, Variable -from utils.IndexVar import IndexVar +from pynars.Narsese import Compound, Connector +from pynars.NAL.MetaLevelInference.VariableSubstitution import * +from pynars.Narsese._py.Variable import VarPrefix, Variable +from pynars.utils.IndexVar import IndexVar class TEST_Variable(unittest.TestCase): diff --git a/Tests/utils_for_test.py b/Tests/utils_for_test.py index acbeb54..2d9c287 100644 --- a/Tests/utils_for_test.py +++ b/Tests/utils_for_test.py @@ -1,14 +1,14 @@ from typing import List, Tuple -from NARS.DataStructures._py.Concept import Concept -from NARS.DataStructures._py.Link import Link, TaskLink, TermLink -from Narsese import Task +from pynars.NARS.DataStructures._py.Concept import Concept +from pynars.NARS.DataStructures._py.Link import Link, TaskLink, TermLink +from pynars.Narsese import Task import Narsese -from NARS.RuleMap import RuleMap_v2, RuleCallable -from NARS import Reasoner_3_0_4 as Reasoner -from Narsese._py.Statement import Statement -from Narsese._py.Task import Belief -from Narsese._py.Term import Term -from NAL.MentalOperation import execute +from pynars.NARS.RuleMap import RuleMap_v2, RuleCallable +from pynars.NARS import Reasoner_3_0_4 as Reasoner +from pynars.Narsese._py.Statement import Statement +from pynars.Narsese._py.Task import Belief +from pynars.Narsese._py.Term import Term +from pynars.NAL.MentalOperation import execute nars = Reasoner(100, 100) rule_map = nars.inference.rule_map diff --git a/Config.py b/pynars/Config.py similarity index 94% rename from Config.py rename to pynars/Config.py index 370fb0c..a5f7bab 100644 --- a/Config.py +++ b/pynars/Config.py @@ -82,7 +82,7 @@ def check(cls): @classmethod def apply(cls): '''Apply setting values of hyper-parameters''' - # from NARS import DataStructures + # from pynars.NARS import DataStructures # # Budget # DataStructures.Budget.priority = cls.priority # DataStructures.Budget.durability = cls.durability @@ -93,10 +93,16 @@ def load(file_path: str): file_path: Path = Path(file_path) + valid = True if not file_path.exists(): - raise f"The file `{file_path}`` does not exist." + print(f"The file `{file_path}` does not exist.") + valid = False if file_path.suffix != '.json': - raise f"The file `{file_path}` should be `*.json`." + print(f"The file `{file_path}` should be `*.json`.") + valid = False + if not valid: + file_path = Path(__file__).parent/'config.json' + print(f'config file: {file_path}') try: with open(file_path, 'r') as f: content = json.load(f) diff --git a/Console.py b/pynars/Console.py similarity index 94% rename from Console.py rename to pynars/Console.py index da50183..601d5aa 100644 --- a/Console.py +++ b/pynars/Console.py @@ -1,18 +1,18 @@ from copy import deepcopy from typing import Tuple, Union from pathlib import Path -import Narsese, NAL, NARS +from pynars import Narsese, NAL, NARS from time import sleep from multiprocessing import Process import os -from Narsese.Parser.parser import TreeToNarsese -from Narsese import Sentence +from pynars.Narsese.Parser.parser import TreeToNarsese +from pynars.Narsese import Sentence import random -from NARS import Reasoner_3_0_4 as Reasoner -from utils.Print import out_print, PrintType -from Narsese import Task +from pynars.NARS import Reasoner_3_0_4 as Reasoner +from pynars.utils.Print import out_print, PrintType +from pynars.Narsese import Task from typing import List -from utils.tools import rand_seed +from pynars.utils.tools import rand_seed import argparse def info(title): diff --git a/Global.py b/pynars/Global.py similarity index 100% rename from Global.py rename to pynars/Global.py diff --git a/NAL/Functions/BudgetFunctions.py b/pynars/NAL/Functions/BudgetFunctions.py similarity index 97% rename from NAL/Functions/BudgetFunctions.py rename to pynars/NAL/Functions/BudgetFunctions.py index ac89953..dcf584c 100644 --- a/NAL/Functions/BudgetFunctions.py +++ b/pynars/NAL/Functions/BudgetFunctions.py @@ -1,9 +1,6 @@ -# from NARS.DataStructures._py.Link import TermLink -from Narsese import Budget, Truth -from Config import Config -from Narsese._py.Task import Belief -from Narsese._py.Term import Term -from Narsese._py.Truth import Truth +# from pynars.NARS.DataStructures._py.Link import TermLink +from pynars.Narsese import Budget, Truth, Term +from pynars.Config import Config from .ExtendedBooleanFunctions import * from copy import deepcopy from .UncertaintyMappingFunctions import w_to_c diff --git a/NAL/Functions/DesireValueFunctions.py b/pynars/NAL/Functions/DesireValueFunctions.py similarity index 95% rename from NAL/Functions/DesireValueFunctions.py rename to pynars/NAL/Functions/DesireValueFunctions.py index 42407f3..f4c3707 100644 --- a/NAL/Functions/DesireValueFunctions.py +++ b/pynars/NAL/Functions/DesireValueFunctions.py @@ -1,5 +1,5 @@ from typing import Callable -from Narsese import Truth +from pynars.Narsese import Truth from .ExtendedBooleanFunctions import * from .UncertaintyMappingFunctions import w_to_c diff --git a/NAL/Functions/ExtendedBooleanFunctions.py b/pynars/NAL/Functions/ExtendedBooleanFunctions.py similarity index 100% rename from NAL/Functions/ExtendedBooleanFunctions.py rename to pynars/NAL/Functions/ExtendedBooleanFunctions.py diff --git a/NAL/Functions/StampFunctions.py b/pynars/NAL/Functions/StampFunctions.py similarity index 89% rename from NAL/Functions/StampFunctions.py rename to pynars/NAL/Functions/StampFunctions.py index 941d06e..4bdf64c 100644 --- a/NAL/Functions/StampFunctions.py +++ b/pynars/NAL/Functions/StampFunctions.py @@ -1,8 +1,8 @@ from typing import Union -from Config import Config -from Narsese import Stamp +from pynars.Config import Config +from pynars.Narsese import Stamp from copy import deepcopy -from Narsese import Connector, Copula +from pynars.Narsese import Connector, Copula _temporal_interval = { diff --git a/NAL/Functions/TemporalFunctions.py b/pynars/NAL/Functions/TemporalFunctions.py similarity index 98% rename from NAL/Functions/TemporalFunctions.py rename to pynars/NAL/Functions/TemporalFunctions.py index d5badc1..9d59494 100644 --- a/NAL/Functions/TemporalFunctions.py +++ b/pynars/NAL/Functions/TemporalFunctions.py @@ -1,5 +1,5 @@ -from Narsese import Truth +from pynars.Narsese import Truth from .UncertaintyMappingFunctions import w_to_c diff --git a/NAL/Functions/Tools.py b/pynars/NAL/Functions/Tools.py similarity index 95% rename from NAL/Functions/Tools.py rename to pynars/NAL/Functions/Tools.py index 4036a08..f82c50e 100644 --- a/NAL/Functions/Tools.py +++ b/pynars/NAL/Functions/Tools.py @@ -3,19 +3,17 @@ # def compound_remove_components from typing import Union -import Global -from Config import Config, Enable -from NAL.Functions.TemporalFunctions import eternalize, project -from Narsese import Budget -from Narsese import Sentence, Judgement, Truth, Task +from pynars import Global +from pynars.Config import Config, Enable +from pynars.NAL.Functions.TemporalFunctions import eternalize, project +from pynars.Narsese import Budget +from pynars.Narsese import Sentence, Judgement, Truth, Task from copy import deepcopy # import Config, Global from math import sqrt -from Narsese import Sentence, Stamp -from Narsese import TRUE, FALSE, UNSURE -from Narsese._py.Sentence import Goal, Quest, Question -from Narsese._py.Task import Belief -from Narsese._py.Term import Term +from pynars.Narsese import Sentence, Stamp, Term +from pynars.Narsese import TRUE, FALSE, UNSURE +from pynars.Narsese import Goal, Quest, Question def truth_to_quality(truth: Truth) -> float: return max(truth.e, (1 - truth.e)*0.75); diff --git a/NAL/Functions/TruthValueFunctions.py b/pynars/NAL/Functions/TruthValueFunctions.py similarity index 99% rename from NAL/Functions/TruthValueFunctions.py rename to pynars/NAL/Functions/TruthValueFunctions.py index faa39f6..ef9a64d 100644 --- a/NAL/Functions/TruthValueFunctions.py +++ b/pynars/NAL/Functions/TruthValueFunctions.py @@ -1,6 +1,6 @@ from typing import Callable -from Narsese import Truth, truth_analytic +from pynars.Narsese import Truth, truth_analytic from .ExtendedBooleanFunctions import * # from .Tools import * from .UncertaintyMappingFunctions import * diff --git a/NAL/Functions/UncertaintyMappingFunctions.py b/pynars/NAL/Functions/UncertaintyMappingFunctions.py similarity index 94% rename from NAL/Functions/UncertaintyMappingFunctions.py rename to pynars/NAL/Functions/UncertaintyMappingFunctions.py index 4f2501d..2dca724 100644 --- a/NAL/Functions/UncertaintyMappingFunctions.py +++ b/pynars/NAL/Functions/UncertaintyMappingFunctions.py @@ -1,4 +1,4 @@ -from Narsese import Truth +from pynars.Narsese import Truth fc_to_w_plus = lambda f, c, k: k*f*c/(1-c) fc_to_w = lambda f, c, k: k*c/(1-c) diff --git a/NAL/Functions/__init__.py b/pynars/NAL/Functions/__init__.py similarity index 100% rename from NAL/Functions/__init__.py rename to pynars/NAL/Functions/__init__.py diff --git a/NAL/Inference/CompositionalRules.py b/pynars/NAL/Inference/CompositionalRules.py similarity index 98% rename from NAL/Inference/CompositionalRules.py rename to pynars/NAL/Inference/CompositionalRules.py index 7299216..73d02f1 100644 --- a/NAL/Inference/CompositionalRules.py +++ b/pynars/NAL/Inference/CompositionalRules.py @@ -1,10 +1,10 @@ ''' Composition rules ''' -from Narsese import Copula, Statement, Compound, Connector, Task, Belief, Budget, Truth +from pynars.Narsese import Copula, Statement, Compound, Connector, Task, Belief, Budget, Truth from ..Functions import * -from Narsese import Judgement, Goal, Quest, Question +from pynars.Narsese import Judgement, Goal, Quest, Question '''first-order With common subject''' def intersection_extension(task: Task, belief: Belief, budget_tasklink: Budget=None, budget_termlink: Budget=None, inverse_premise: bool=False, inverse_copula: bool=False): diff --git a/NAL/Inference/ConditionalSyllogisticRules.py b/pynars/NAL/Inference/ConditionalSyllogisticRules.py similarity index 99% rename from NAL/Inference/ConditionalSyllogisticRules.py rename to pynars/NAL/Inference/ConditionalSyllogisticRules.py index c7c7e6a..b82d9e6 100644 --- a/NAL/Inference/ConditionalSyllogisticRules.py +++ b/pynars/NAL/Inference/ConditionalSyllogisticRules.py @@ -12,12 +12,12 @@ def syllogistic_rule(task: Task, belief: Belief, budget_tasklink: Budget=None, b The param `inverse_copula` means whether to inverse the order of the subject and predicate in the task, for example, if the term in the task is M>, and the `inverse_copula` equals `True`, then the premise1 is S>. ''' -from Narsese import Copula, Statement, Compound, Connector, Task, Belief, Budget, Stamp, Truth +from pynars.Narsese import Copula, Statement, Compound, Connector, Task, Belief, Budget, Stamp, Truth from ..Functions import F_deduction, F_analogy, F_comparison, F_abduction, F_induction, \ fc_to_w_minus, fc_to_w_plus from ..Functions import * -from Narsese import Judgement, Goal, Quest, Question +from pynars.Narsese import Judgement, Goal, Quest, Question ''' The Conditional Syllogistic Rules (Table B.2) diff --git a/NAL/Inference/ImmediateRules.py b/pynars/NAL/Inference/ImmediateRules.py similarity index 95% rename from NAL/Inference/ImmediateRules.py rename to pynars/NAL/Inference/ImmediateRules.py index 0ec5d8b..cd693f5 100644 --- a/NAL/Inference/ImmediateRules.py +++ b/pynars/NAL/Inference/ImmediateRules.py @@ -1,11 +1,11 @@ -from Narsese._py.Sentence import Sentence +from pynars.Narsese._py.Sentence import Sentence from ..Functions.TruthValueFunctions import * -from Narsese import Copula, Statement, Compound, Connector, Term, Task, Budget, Stamp +from pynars.Narsese import Copula, Statement, Compound, Connector, Term, Task, Budget, Stamp from ..Functions.BudgetFunctions import * from ..Functions import F_negation, F_conversion, F_contraposition, \ fc_to_w_minus, fc_to_w_plus, w_to_f, w_to_c -from Narsese import Judgement, Truth, Goal, Quest, Question +from pynars.Narsese import Judgement, Truth, Goal, Quest, Question # TODO: P> |- P> OpenNARS 3.0.4 LocalRules.java line 424~441 diff --git a/NAL/Inference/LocalRules.py b/pynars/NAL/Inference/LocalRules.py similarity index 84% rename from NAL/Inference/LocalRules.py rename to pynars/NAL/Inference/LocalRules.py index e9df3e9..72222d5 100644 --- a/NAL/Inference/LocalRules.py +++ b/pynars/NAL/Inference/LocalRules.py @@ -1,18 +1,18 @@ from typing import List, Union -from NAL.Functions.BudgetFunctions import Budget_revision -from NAL.Functions.ExtendedBooleanFunctions import Or -from Narsese import Stamp, Task -from Narsese._py.Budget import Budget -from Narsese._py.Sentence import Goal, Quest, Question -from Narsese._py.Task import Belief +from pynars.NAL.Functions.BudgetFunctions import Budget_revision +from pynars.NAL.Functions.ExtendedBooleanFunctions import Or +from pynars.Narsese import Stamp, Task +from pynars.Narsese._py.Budget import Budget +from pynars.Narsese._py.Sentence import Goal, Quest, Question +from pynars.Narsese._py.Task import Belief from ..Functions import Truth_revision -from Narsese import Sentence, Judgement, Truth +from pynars.Narsese import Sentence, Judgement, Truth # from .TemporalRules import matching_order from copy import deepcopy -import Global -from Config import Enable +from pynars import Global +from pynars.Config import Enable -from NAL.Functions.Tools import calculate_solution_quality, truth_to_quality +from pynars.NAL.Functions.Tools import calculate_solution_quality, truth_to_quality def revision(task: Task, belief: Task, budget_tasklink: Budget=None, budget_termlink: Budget=None): premise1: Judgement = task.sentence diff --git a/NAL/Inference/SyllogisticRules.py b/pynars/NAL/Inference/SyllogisticRules.py similarity index 97% rename from NAL/Inference/SyllogisticRules.py rename to pynars/NAL/Inference/SyllogisticRules.py index 3c2b3cf..22babc5 100644 --- a/NAL/Inference/SyllogisticRules.py +++ b/pynars/NAL/Inference/SyllogisticRules.py @@ -13,11 +13,11 @@ def syllogistic_rule(task: Task, belief: Belief, budget_tasklink: Budget=None, b ''' import math -from NAL.Functions.DesireValueFunctions import Desire_strong, Desire_weak, Desire_deduction, Desire_induction -from NAL.Functions.TruthValueFunctions import * -from NAL.Functions.BudgetFunctions import Budget_backward_weak, Budget_forward, Budget_inference, Budget_backward -from Narsese import Term, Copula, Statement, Truth, Task, Belief, Budget, Stamp -from Narsese import Punctuation, Sentence, Judgement, Goal, Question, Quest +from pynars.NAL.Functions.DesireValueFunctions import Desire_strong, Desire_weak, Desire_deduction, Desire_induction +from pynars.NAL.Functions.TruthValueFunctions import * +from pynars.NAL.Functions.BudgetFunctions import Budget_backward_weak, Budget_forward, Budget_inference, Budget_backward +from pynars.Narsese import Term, Copula, Statement, Truth, Task, Belief, Budget, Stamp +from pynars.Narsese import Punctuation, Sentence, Judgement, Goal, Question, Quest from ..Functions import F_deduction, fc_to_w_minus, fc_to_w_plus from copy import deepcopy from ..Functions.StampFunctions import * diff --git a/NAL/Inference/TemporalRules.py b/pynars/NAL/Inference/TemporalRules.py similarity index 97% rename from NAL/Inference/TemporalRules.py rename to pynars/NAL/Inference/TemporalRules.py index 27fc1b8..a46c057 100644 --- a/NAL/Inference/TemporalRules.py +++ b/pynars/NAL/Inference/TemporalRules.py @@ -1,9 +1,9 @@ -from Narsese import Task, Belief, Sentence, Judgement, Goal, Question, Quest -from Narsese import Statement, Term, Compound -from Narsese import Budget, Stamp -from Narsese import truth_analytic -from Config import Enable -from Narsese._py.Interval import Interval +from pynars.Narsese import Task, Belief, Sentence, Judgement, Goal, Question, Quest +from pynars.Narsese import Statement, Term, Compound +from pynars.Narsese import Budget, Stamp +from pynars.Narsese import truth_analytic +from pynars.Config import Enable +from pynars.Narsese._py.Interval import Interval from ..Functions import * from copy import copy, deepcopy diff --git a/NAL/Inference/__init__.py b/pynars/NAL/Inference/__init__.py similarity index 100% rename from NAL/Inference/__init__.py rename to pynars/NAL/Inference/__init__.py diff --git a/NAL/MentalOperation/__init__.py b/pynars/NAL/MentalOperation/__init__.py similarity index 100% rename from NAL/MentalOperation/__init__.py rename to pynars/NAL/MentalOperation/__init__.py diff --git a/NAL/MentalOperation/_aware.py b/pynars/NAL/MentalOperation/_aware.py similarity index 75% rename from NAL/MentalOperation/_aware.py rename to pynars/NAL/MentalOperation/_aware.py index 7480f23..faf76b2 100644 --- a/NAL/MentalOperation/_aware.py +++ b/pynars/NAL/MentalOperation/_aware.py @@ -1,20 +1,20 @@ from copy import copy from typing import List -from Config import Config -from Narsese._py import SELF -from Narsese._py.Budget import Budget -from Narsese._py.Compound import Compound -from Narsese._py.Connector import Connector -from Narsese._py.Operation import * -from Narsese._py.Sentence import Goal, Judgement, Quest, Question, Sentence, Stamp -from Narsese._py.Statement import Statement -from Narsese._py.Task import Belief, Desire, Task -from Narsese._py.Truth import Truth +from pynars.Config import Config +from pynars.Narsese._py import SELF +from pynars.Narsese._py.Budget import Budget +from pynars.Narsese._py.Compound import Compound +from pynars.Narsese._py.Connector import Connector +from pynars.Narsese._py.Operation import * +from pynars.Narsese._py.Sentence import Goal, Judgement, Quest, Question, Sentence, Stamp +from pynars.Narsese._py.Statement import Statement +from pynars.Narsese._py.Task import Belief, Desire, Task +from pynars.Narsese._py.Truth import Truth from ._register import registered_operations -from Narsese import Term +from pynars.Narsese import Term from ..Functions.Tools import truth_from_term, truth_to_quality, truth_to_term -from Narsese import Base -import Global +from pynars.Narsese import Base +from pynars import Global def _aware(statement: Statement, stamp: Stamp, budget_task: Budget=None): diff --git a/NAL/MentalOperation/_execute.py b/pynars/NAL/MentalOperation/_execute.py similarity index 82% rename from NAL/MentalOperation/_execute.py rename to pynars/NAL/MentalOperation/_execute.py index 6e7993f..9987a2e 100644 --- a/NAL/MentalOperation/_execute.py +++ b/pynars/NAL/MentalOperation/_execute.py @@ -1,16 +1,16 @@ from typing import List -from Config import Config -from Narsese._py.Budget import Budget -from Narsese._py.Operation import * -from Narsese._py.Sentence import Goal, Judgement, Quest, Question, Sentence, Stamp -from Narsese._py.Statement import Statement -from Narsese._py.Task import Belief, Desire, Task -from Narsese._py.Truth import Truth +from pynars.Config import Config +from pynars.Narsese._py.Budget import Budget +from pynars.Narsese._py.Operation import * +from pynars.Narsese._py.Sentence import Goal, Judgement, Quest, Question, Sentence, Stamp +from pynars.Narsese._py.Statement import Statement +from pynars.Narsese._py.Task import Belief, Desire, Task +from pynars.Narsese._py.Truth import Truth from ._register import registered_operations -from Narsese import Term +from pynars.Narsese import Term from ..Functions.Tools import truth_from_term, truth_to_quality -from Narsese import Base -import Global +from pynars.Narsese import Base +from pynars import Global def execute(task: Task): '''''' diff --git a/NAL/MentalOperation/_register.py b/pynars/NAL/MentalOperation/_register.py similarity index 84% rename from NAL/MentalOperation/_register.py rename to pynars/NAL/MentalOperation/_register.py index 74ec0cd..8168268 100644 --- a/NAL/MentalOperation/_register.py +++ b/pynars/NAL/MentalOperation/_register.py @@ -1,6 +1,6 @@ from typing import Callable, Dict -from Narsese._py.Operation import * +from pynars.Narsese._py.Operation import * registered_operations: Dict[Operation, Callable] = {} diff --git a/NAL/MetaLevelInference/GoalDerivation.py b/pynars/NAL/MetaLevelInference/GoalDerivation.py similarity index 100% rename from NAL/MetaLevelInference/GoalDerivation.py rename to pynars/NAL/MetaLevelInference/GoalDerivation.py diff --git a/NAL/MetaLevelInference/QuestionDerivation.py b/pynars/NAL/MetaLevelInference/QuestionDerivation.py similarity index 100% rename from NAL/MetaLevelInference/QuestionDerivation.py rename to pynars/NAL/MetaLevelInference/QuestionDerivation.py diff --git a/NAL/MetaLevelInference/TemporalInference.py b/pynars/NAL/MetaLevelInference/TemporalInference.py similarity index 100% rename from NAL/MetaLevelInference/TemporalInference.py rename to pynars/NAL/MetaLevelInference/TemporalInference.py diff --git a/NAL/MetaLevelInference/VariableSubstitution/Elimination.py b/pynars/NAL/MetaLevelInference/VariableSubstitution/Elimination.py similarity index 97% rename from NAL/MetaLevelInference/VariableSubstitution/Elimination.py rename to pynars/NAL/MetaLevelInference/VariableSubstitution/Elimination.py index 0aaf645..9f54680 100644 --- a/NAL/MetaLevelInference/VariableSubstitution/Elimination.py +++ b/pynars/NAL/MetaLevelInference/VariableSubstitution/Elimination.py @@ -1,8 +1,8 @@ from typing import Dict, List, Tuple from bidict import bidict -from Narsese import Term -from utils.IndexVar import IntVar +from pynars.Narsese import Term +from pynars.utils.IndexVar import IntVar from .Substitution import Substitution diff --git a/NAL/MetaLevelInference/VariableSubstitution/Introduction.py b/pynars/NAL/MetaLevelInference/VariableSubstitution/Introduction.py similarity index 92% rename from NAL/MetaLevelInference/VariableSubstitution/Introduction.py rename to pynars/NAL/MetaLevelInference/VariableSubstitution/Introduction.py index 4a1739e..b865e9d 100644 --- a/NAL/MetaLevelInference/VariableSubstitution/Introduction.py +++ b/pynars/NAL/MetaLevelInference/VariableSubstitution/Introduction.py @@ -1,6 +1,6 @@ from typing import List -from Narsese import Term -from utils.IndexVar import IntVar +from pynars.Narsese import Term +from pynars.utils.IndexVar import IntVar from .Substitution import Substitution diff --git a/NAL/MetaLevelInference/VariableSubstitution/Substitution.py b/pynars/NAL/MetaLevelInference/VariableSubstitution/Substitution.py similarity index 98% rename from NAL/MetaLevelInference/VariableSubstitution/Substitution.py rename to pynars/NAL/MetaLevelInference/VariableSubstitution/Substitution.py index 71d314a..51166c8 100644 --- a/NAL/MetaLevelInference/VariableSubstitution/Substitution.py +++ b/pynars/NAL/MetaLevelInference/VariableSubstitution/Substitution.py @@ -2,8 +2,8 @@ from typing import List from bidict import bidict -from Narsese import Term -from utils.IndexVar import IntVar +from pynars.Narsese import Term +from pynars.utils.IndexVar import IntVar class Substitution: diff --git a/NAL/MetaLevelInference/VariableSubstitution/Unification.py b/pynars/NAL/MetaLevelInference/VariableSubstitution/Unification.py similarity index 95% rename from NAL/MetaLevelInference/VariableSubstitution/Unification.py rename to pynars/NAL/MetaLevelInference/VariableSubstitution/Unification.py index 0d8140d..9cbb6a4 100644 --- a/NAL/MetaLevelInference/VariableSubstitution/Unification.py +++ b/pynars/NAL/MetaLevelInference/VariableSubstitution/Unification.py @@ -6,10 +6,10 @@ from typing import Callable, Dict, List, Tuple, Union from bidict import bidict -from Narsese import Term -from Narsese import Statement, Compound -from utils.IndexVar import IndexVar, IntVar -from utils.tools import find_pos_with_pos, find_var_with_pos +from pynars.Narsese import Term +from pynars.Narsese import Statement, Compound +from pynars.utils.IndexVar import IndexVar, IntVar +from pynars.utils.tools import find_pos_with_pos, find_var_with_pos from .Substitution import Substitution from .Elimination import Elimination diff --git a/NAL/MetaLevelInference/VariableSubstitution/__init__.py b/pynars/NAL/MetaLevelInference/VariableSubstitution/__init__.py similarity index 100% rename from NAL/MetaLevelInference/VariableSubstitution/__init__.py rename to pynars/NAL/MetaLevelInference/VariableSubstitution/__init__.py diff --git a/NARS/RuleMap/Interface/__init__.py b/pynars/NAL/MetaLevelInference/__init__.py similarity index 100% rename from NARS/RuleMap/Interface/__init__.py rename to pynars/NAL/MetaLevelInference/__init__.py diff --git a/NAL/MetaLevelInference/_trash/VariableSubstitution_v1.py b/pynars/NAL/MetaLevelInference/_trash/VariableSubstitution_v1.py similarity index 98% rename from NAL/MetaLevelInference/_trash/VariableSubstitution_v1.py rename to pynars/NAL/MetaLevelInference/_trash/VariableSubstitution_v1.py index e26febb..34a7506 100644 --- a/NAL/MetaLevelInference/_trash/VariableSubstitution_v1.py +++ b/pynars/NAL/MetaLevelInference/_trash/VariableSubstitution_v1.py @@ -5,9 +5,9 @@ from typing import Callable, List, Union from bidict import bidict -from Narsese import Term -from Narsese import Statement, Compound -from utils.IndexVar import IndexVar +from pynars.Narsese import Term +from pynars.Narsese import Statement, Compound +from pynars.utils.IndexVar import IndexVar class SubstituteVar: diff --git a/NAL/Theorems/DecompositionalRules.py b/pynars/NAL/Theorems/DecompositionalRules.py similarity index 98% rename from NAL/Theorems/DecompositionalRules.py rename to pynars/NAL/Theorems/DecompositionalRules.py index e992e95..cc3bef0 100644 --- a/NAL/Theorems/DecompositionalRules.py +++ b/pynars/NAL/Theorems/DecompositionalRules.py @@ -1,7 +1,7 @@ -from Narsese import Copula, Statement, Compound, Connector, Term, Truth, Task, Belief, Budget -from Narsese import Judgement, Goal, Quest, Question -from Narsese import truth_analytic +from pynars.Narsese import Copula, Statement, Compound, Connector, Term, Truth, Task, Belief, Budget +from pynars.Narsese import Judgement, Goal, Quest, Question +from pynars.Narsese import truth_analytic from ..Functions import * ''' diff --git a/NAL/Theorems/StructuralRules.py b/pynars/NAL/Theorems/StructuralRules.py similarity index 99% rename from NAL/Theorems/StructuralRules.py rename to pynars/NAL/Theorems/StructuralRules.py index d3fcaf0..0817bb9 100644 --- a/NAL/Theorems/StructuralRules.py +++ b/pynars/NAL/Theorems/StructuralRules.py @@ -1,6 +1,6 @@ from typing import List -from Narsese import Copula, Statement, Compound, Connector, Term, Judgement, Truth, Task, Belief, Budget, Stamp, Goal, Quest, Question -from Narsese import place_holder, truth_analytic +from pynars.Narsese import Copula, Statement, Compound, Connector, Term, Judgement, Truth, Task, Belief, Budget, Stamp, Goal, Quest, Question +from pynars.Narsese import place_holder, truth_analytic from ..Functions.TruthValueFunctions import * from ..Functions.DesireValueFunctions import * diff --git a/NAL/Theorems/TransformRules.py b/pynars/NAL/Theorems/TransformRules.py similarity index 95% rename from NAL/Theorems/TransformRules.py rename to pynars/NAL/Theorems/TransformRules.py index ebe397a..d537b1e 100644 --- a/NAL/Theorems/TransformRules.py +++ b/pynars/NAL/Theorems/TransformRules.py @@ -2,9 +2,9 @@ In this file, some more generalized functions of transform are implemented, though with a little differences in terms of parameters. ''' from typing import List -from Narsese import Copula, Statement, Compound, Connector, Term, Judgement, Truth, Task, Belief, Budget, Stamp, Goal, Quest, Question -from Narsese import place_holder -from Narsese._py.Sentence import Sentence +from pynars.Narsese import Copula, Statement, Compound, Connector, Term, Judgement, Truth, Task, Belief, Budget, Stamp, Goal, Quest, Question +from pynars.Narsese import place_holder +from pynars.Narsese._py.Sentence import Sentence from ..Functions.TruthValueFunctions import * from ..Functions.DesireValueFunctions import * diff --git a/NAL/Theorems/__init__.py b/pynars/NAL/Theorems/__init__.py similarity index 100% rename from NAL/Theorems/__init__.py rename to pynars/NAL/Theorems/__init__.py diff --git a/Narsese/Parser/__init__.py b/pynars/NAL/__init__.py similarity index 100% rename from Narsese/Parser/__init__.py rename to pynars/NAL/__init__.py diff --git a/NAL/_generate_init_file.py b/pynars/NAL/_generate_init_file.py similarity index 100% rename from NAL/_generate_init_file.py rename to pynars/NAL/_generate_init_file.py diff --git a/NARS/Control/Reasoner_OpenNARS_3_0_4.py b/pynars/NARS/Control/Reasoner_OpenNARS_3_0_4.py similarity index 94% rename from NARS/Control/Reasoner_OpenNARS_3_0_4.py rename to pynars/NARS/Control/Reasoner_OpenNARS_3_0_4.py index 0b9cbc3..030b0c3 100644 --- a/NARS/Control/Reasoner_OpenNARS_3_0_4.py +++ b/pynars/NARS/Control/Reasoner_OpenNARS_3_0_4.py @@ -1,16 +1,16 @@ from os import remove -from NAL.Functions.Tools import truth_to_quality +from pynars.NAL.Functions.Tools import truth_to_quality -from NARS.DataStructures._py.Link import TaskLink -from NARS.InferenceEngine import TemporalEngine -from Narsese._py.Budget import Budget +from pynars.NARS.DataStructures._py.Link import TaskLink +from pynars.NARS.InferenceEngine import TemporalEngine +from pynars.Narsese._py.Budget import Budget from ..DataStructures import Bag, Memory, NarseseChannel, Buffer, Task, Concept from ..InferenceEngine import GeneralEngine -import Config -from Config import Enable +from pynars import Config +from pynars.Config import Enable from typing import List, Tuple, Union -import NARS.MentalOperation as MentalOperation -import Global +import pynars.NARS.MentalOperation as MentalOperation +from pynars import Global class Reasoner: diff --git a/NARS/Control/__init__.py b/pynars/NARS/Control/__init__.py similarity index 100% rename from NARS/Control/__init__.py rename to pynars/NARS/Control/__init__.py diff --git a/NARS/DataStructures/__init__.py b/pynars/NARS/DataStructures/__init__.py similarity index 100% rename from NARS/DataStructures/__init__.py rename to pynars/NARS/DataStructures/__init__.py diff --git a/NARS/DataStructures/_py/Bag.py b/pynars/NARS/DataStructures/_py/Bag.py similarity index 98% rename from NARS/DataStructures/_py/Bag.py rename to pynars/NARS/DataStructures/_py/Bag.py index c22de7c..0389b5d 100644 --- a/NARS/DataStructures/_py/Bag.py +++ b/pynars/NARS/DataStructures/_py/Bag.py @@ -2,9 +2,9 @@ import random import math from depq import DEPQ -from Config import Config -from Narsese import Item, Task -from NAL.Functions.BudgetFunctions import * +from pynars.Config import Config +from pynars.Narsese import Item, Task +from pynars.NAL.Functions.BudgetFunctions import * from typing import Union class Bag: diff --git a/NARS/DataStructures/_py/Buffer.py b/pynars/NARS/DataStructures/_py/Buffer.py similarity index 95% rename from NARS/DataStructures/_py/Buffer.py rename to pynars/NARS/DataStructures/_py/Buffer.py index 60fca76..adcbce2 100644 --- a/NARS/DataStructures/_py/Buffer.py +++ b/pynars/NARS/DataStructures/_py/Buffer.py @@ -1,6 +1,6 @@ from .Bag import Bag -from Config import Config -from Narsese import Item +from pynars.Config import Config +from pynars.Narsese import Item class Buffer(Bag): ''' diff --git a/NARS/DataStructures/_py/Channel.py b/pynars/NARS/DataStructures/_py/Channel.py similarity index 76% rename from NARS/DataStructures/_py/Channel.py rename to pynars/NARS/DataStructures/_py/Channel.py index e899521..216191f 100644 --- a/NARS/DataStructures/_py/Channel.py +++ b/pynars/NARS/DataStructures/_py/Channel.py @@ -1,9 +1,9 @@ -from Narsese import Sentence +from pynars.Narsese import Sentence from .Buffer import Buffer from queue import Queue -from Narsese import Task -from Narsese import parser -from utils.Print import out_print, PrintType +from pynars.Narsese import Task +from pynars.Narsese import parser +from pynars.utils.Print import out_print, PrintType class Channel(Buffer): '''''' diff --git a/NARS/DataStructures/_py/Concept.py b/pynars/NARS/DataStructures/_py/Concept.py similarity index 96% rename from NARS/DataStructures/_py/Concept.py rename to pynars/NARS/DataStructures/_py/Concept.py index fcc7ada..292867e 100644 --- a/NARS/DataStructures/_py/Concept.py +++ b/pynars/NARS/DataStructures/_py/Concept.py @@ -1,14 +1,14 @@ from typing import Tuple, Type, List, Union -from NAL.Functions.Tools import calculate_solution_quality, distribute_budget_among_links -from NAL.Functions.BudgetFunctions import Budget_merge -from Narsese import Belief, Task, Item, Budget, Sentence, Term, Task, Judgement, Goal -from Narsese._py.Sentence import Quest, Question +from pynars.NAL.Functions.Tools import calculate_solution_quality, distribute_budget_among_links +from pynars.NAL.Functions.BudgetFunctions import Budget_merge +from pynars.Narsese import Belief, Task, Item, Budget, Sentence, Term, Task, Judgement, Goal +from pynars.Narsese._py.Sentence import Quest, Question # from .Link import Link, TermLink, TaskLink, LinkType from .Link import * from .Table import Table from .Bag import Bag -from Config import Config, Enable -from Narsese import place_holder +from pynars.Config import Config, Enable +from pynars.Narsese import place_holder class Concept(Item): diff --git a/NARS/DataStructures/_py/Link.py b/pynars/NARS/DataStructures/_py/Link.py similarity index 96% rename from NARS/DataStructures/_py/Link.py rename to pynars/NARS/DataStructures/_py/Link.py index e7388b6..be80ebf 100644 --- a/NARS/DataStructures/_py/Link.py +++ b/pynars/NARS/DataStructures/_py/Link.py @@ -1,19 +1,19 @@ from enum import Enum import enum -from Narsese import Item, Budget, Task, Term +from pynars.Narsese import Item, Budget, Task, Term from typing import List, Type, Union -from Narsese._py.Compound import Compound -from Narsese._py.Connector import Connector +from pynars.Narsese._py.Compound import Compound +from pynars.Narsese._py.Connector import Connector -from Narsese._py.Copula import Copula -from Narsese._py.Statement import Statement -from Narsese._py.Truth import Truth +from pynars.Narsese._py.Copula import Copula +from pynars.Narsese._py.Statement import Statement +from pynars.Narsese._py.Truth import Truth # from .Concept import * from .Concept import * # from . import Concept from copy import copy, deepcopy -from NAL.Functions.ExtendedBooleanFunctions import * -from Config import Config +from pynars.NAL.Functions.ExtendedBooleanFunctions import * +from pynars.Config import Config class LinkType(Enum): SELF = 0 # At C, point to C; TaskLink only diff --git a/NARS/DataStructures/_py/Memory.py b/pynars/NARS/DataStructures/_py/Memory.py similarity index 95% rename from NARS/DataStructures/_py/Memory.py rename to pynars/NARS/DataStructures/_py/Memory.py index b89dcbe..611181e 100644 --- a/NARS/DataStructures/_py/Memory.py +++ b/pynars/NARS/DataStructures/_py/Memory.py @@ -1,15 +1,15 @@ -from Config import Enable -from NAL.Inference.LocalRules import solve_query, solution_query, solution_question -from NAL.MetaLevelInference.VariableSubstitution import unification__var_const - -from NARS.DataStructures._py.Link import TaskLink -from Narsese._py.Sentence import Goal, Judgement, Question -from Narsese import Statement, Term, Sentence, Budget, Task -from Narsese._py.Task import Belief, Desire +from pynars.Config import Enable +from pynars.NAL.Inference.LocalRules import solve_query, solution_query, solution_question +from pynars.NAL.MetaLevelInference.VariableSubstitution import unification__var_const + +from pynars.NARS.DataStructures._py.Link import TaskLink +from pynars.Narsese._py.Sentence import Goal, Judgement, Question +from pynars.Narsese import Statement, Term, Sentence, Budget, Task +from pynars.Narsese._py.Task import Belief, Desire from .Concept import Concept from .Bag import Bag -from NAL.Functions.Tools import revisible -from NAL.Inference import local__revision +from pynars.NAL.Functions.Tools import revisible +from pynars.NAL.Inference import local__revision class Memory: def __init__(self, capacity: int, n_buckets: int = None, take_in_order: bool = False) -> None: diff --git a/NARS/DataStructures/_py/Table.py b/pynars/NARS/DataStructures/_py/Table.py similarity index 96% rename from NARS/DataStructures/_py/Table.py rename to pynars/NARS/DataStructures/_py/Table.py index 37737c7..93f8ff3 100644 --- a/NARS/DataStructures/_py/Table.py +++ b/pynars/NARS/DataStructures/_py/Table.py @@ -1,6 +1,6 @@ from typing import Union from depq import DEPQ -from Narsese import Task, Belief +from pynars.Narsese import Task, Belief class Table: ''' diff --git a/pynars/NARS/DataStructures/_py/__init__.py b/pynars/NARS/DataStructures/_py/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/NARS/InferenceEngine/Engine.py b/pynars/NARS/InferenceEngine/Engine.py similarity index 63% rename from NARS/InferenceEngine/Engine.py rename to pynars/NARS/InferenceEngine/Engine.py index abb8c2e..491eea6 100644 --- a/NARS/InferenceEngine/Engine.py +++ b/pynars/NARS/InferenceEngine/Engine.py @@ -1,12 +1,12 @@ from copy import copy -from NAL.Functions.Tools import project_truth, revisible -from Narsese._py.Budget import Budget -from Narsese._py.Term import Term +from pynars.NAL.Functions.Tools import project_truth, revisible +from pynars.Narsese._py.Budget import Budget +from pynars.Narsese._py.Term import Term from ..DataStructures import Task, Belief, Concept, TaskLink, TermLink from typing import Callable, List, Tuple from ..RuleMap import RuleCallable, RuleMap_v2 -from NAL.Inference import local__revision -import Global +from pynars.NAL.Inference import local__revision +from pynars import Global class Engine: diff --git a/NARS/InferenceEngine/GeneralEngine.py b/pynars/NARS/InferenceEngine/GeneralEngine.py similarity index 95% rename from NARS/InferenceEngine/GeneralEngine.py rename to pynars/NARS/InferenceEngine/GeneralEngine.py index dadb70a..8d4313a 100644 --- a/NARS/InferenceEngine/GeneralEngine.py +++ b/pynars/NARS/InferenceEngine/GeneralEngine.py @@ -1,18 +1,18 @@ from copy import copy -from NAL.Functions.Tools import project_truth, revisible -from Narsese._py.Budget import Budget -from Narsese._py.Term import Term +from pynars.NAL.Functions.Tools import project_truth, revisible +from pynars.Narsese._py.Budget import Budget +from pynars.Narsese._py.Term import Term from ..DataStructures import Task, Belief, Concept, TaskLink, TermLink from typing import Callable, List, Tuple from ..RuleMap import RuleCallable, RuleMap_v2 -from NAL.Inference import local__revision -import Global +from pynars.NAL.Inference import local__revision +from pynars import Global from .Engine import Engine class GeneralEngine(Engine): - rule_map = RuleMap_v2() + # rule_map = RuleMap_v2() def __init__(self): '''''' diff --git a/NARS/InferenceEngine/TemporalEngine.py b/pynars/NARS/InferenceEngine/TemporalEngine.py similarity index 86% rename from NARS/InferenceEngine/TemporalEngine.py rename to pynars/NARS/InferenceEngine/TemporalEngine.py index 604975c..3167ed1 100644 --- a/NARS/InferenceEngine/TemporalEngine.py +++ b/pynars/NARS/InferenceEngine/TemporalEngine.py @@ -1,26 +1,25 @@ from copy import copy from typing import Union -from distutils.unixccompiler import UnixCCompiler -from NAL.Functions.Tools import project_truth, revisible, truth_to_quality -from NARS.DataStructures._py.Buffer import Buffer -from Narsese._py.Budget import Budget -from Narsese._py.Copula import Copula -from Narsese._py.Evidence import Base -from Narsese._py.Statement import Statement -from Narsese._py.Term import Term +from pynars.NAL.Functions.Tools import project_truth, revisible, truth_to_quality +from pynars.NARS.DataStructures._py.Buffer import Buffer +from pynars.Narsese._py.Budget import Budget +from pynars.Narsese._py.Copula import Copula +from pynars.Narsese._py.Evidence import Base +from pynars.Narsese._py.Statement import Statement +from pynars.Narsese._py.Term import Term from ..DataStructures import Task, Belief, Concept, TaskLink, TermLink from typing import Callable, List, Tuple from ..RuleMap import RuleCallable, RuleMap_v2 -from NAL.Inference import local__revision -from Config import Config -import Global -from NAL.Inference import * +from pynars.NAL.Inference import local__revision +from pynars.Config import Config +from pynars import Global +from pynars.NAL.Inference import * from .Engine import Engine class TemporalEngine(Engine): '''''' - rule_map = RuleMap_v2() + # rule_map = RuleMap_v2() def __init__(self) -> None: '''''' diff --git a/NARS/InferenceEngine/__init__.py b/pynars/NARS/InferenceEngine/__init__.py similarity index 100% rename from NARS/InferenceEngine/__init__.py rename to pynars/NARS/InferenceEngine/__init__.py diff --git a/NARS/MentalOperation/Execution.py b/pynars/NARS/MentalOperation/Execution.py similarity index 63% rename from NARS/MentalOperation/Execution.py rename to pynars/NARS/MentalOperation/Execution.py index a911a63..7fba740 100644 --- a/NARS/MentalOperation/Execution.py +++ b/pynars/NARS/MentalOperation/Execution.py @@ -1,18 +1,18 @@ from typing import Callable, List -from Config import Config -from NARS.DataStructures._py.Concept import Concept -from NARS.DataStructures._py.Memory import Memory -from Narsese._py.Budget import Budget -from Narsese._py.Operation import * -from Narsese._py.Sentence import Goal, Judgement, Quest, Question, Sentence, Stamp -from Narsese._py.Statement import Statement -from Narsese._py.Task import Belief, Desire, Task -from Narsese._py.Truth import Truth +from pynars.Config import Config +from pynars.NARS.DataStructures._py.Concept import Concept +from pynars.NARS.DataStructures._py.Memory import Memory +from pynars.Narsese._py.Budget import Budget +from pynars.Narsese._py.Operation import * +from pynars.Narsese._py.Sentence import Goal, Judgement, Quest, Question, Sentence, Stamp +from pynars.Narsese._py.Statement import Statement +from pynars.Narsese._py.Task import Belief, Desire, Task +from pynars.Narsese._py.Truth import Truth from .Register import registered_operations -from Narsese import Term -from NAL.Functions.Tools import truth_from_term, truth_to_quality -from Narsese import Base -import Global +from pynars.Narsese import Term +from pynars.NAL.Functions.Tools import truth_from_term, truth_to_quality +from pynars.Narsese import Base +from pynars import Global def executed_task(task: Task): ''' diff --git a/NARS/MentalOperation/Interface_Awareness.py b/pynars/NARS/MentalOperation/Interface_Awareness.py similarity index 84% rename from NARS/MentalOperation/Interface_Awareness.py rename to pynars/NARS/MentalOperation/Interface_Awareness.py index 7d44c52..3305d71 100644 --- a/NARS/MentalOperation/Interface_Awareness.py +++ b/pynars/NARS/MentalOperation/Interface_Awareness.py @@ -1,8 +1,8 @@ from typing import List -import NAL.MentalOperation._aware as aware -from NARS.DataStructures._py.Concept import Concept -from NARS.DataStructures._py.Memory import Memory -from Narsese import Task, Term +import pynars.NAL.MentalOperation._aware as aware +from pynars.NARS.DataStructures._py.Concept import Concept +from pynars.NARS.DataStructures._py.Memory import Memory +from pynars.Narsese import Task, Term from ..DataStructures import Bag from copy import copy, deepcopy diff --git a/NARS/MentalOperation/Interface_Execution.py b/pynars/NARS/MentalOperation/Interface_Execution.py similarity index 86% rename from NARS/MentalOperation/Interface_Execution.py rename to pynars/NARS/MentalOperation/Interface_Execution.py index 260858c..0b54ec2 100644 --- a/NARS/MentalOperation/Interface_Execution.py +++ b/pynars/NARS/MentalOperation/Interface_Execution.py @@ -1,8 +1,8 @@ from typing import Iterable, List -import NAL.MentalOperation._execute as _execute -from NARS.DataStructures._py.Concept import Concept -from NARS.DataStructures._py.Memory import Memory -from Narsese import Task, Term +import pynars.NAL.MentalOperation._execute as _execute +from pynars.NARS.DataStructures._py.Concept import Concept +from pynars.NARS.DataStructures._py.Memory import Memory +from pynars.Narsese import Task, Term from ..DataStructures import Bag from copy import copy, deepcopy diff --git a/NARS/MentalOperation/Register.py b/pynars/NARS/MentalOperation/Register.py similarity index 84% rename from NARS/MentalOperation/Register.py rename to pynars/NARS/MentalOperation/Register.py index 1a3389f..8866cf5 100644 --- a/NARS/MentalOperation/Register.py +++ b/pynars/NARS/MentalOperation/Register.py @@ -1,5 +1,5 @@ from typing import Callable, Dict -from Narsese._py.Operation import * +from pynars.Narsese._py.Operation import * registered_operations: Dict[Operation, Callable] = {} diff --git a/NARS/MentalOperation/__init__.py b/pynars/NARS/MentalOperation/__init__.py similarity index 100% rename from NARS/MentalOperation/__init__.py rename to pynars/NARS/MentalOperation/__init__.py diff --git a/NARS/RuleMap/Interface/Interface_CompositionalRules.py b/pynars/NARS/RuleMap/Interface/Interface_CompositionalRules.py similarity index 96% rename from NARS/RuleMap/Interface/Interface_CompositionalRules.py rename to pynars/NARS/RuleMap/Interface/Interface_CompositionalRules.py index 957c068..7533e29 100644 --- a/NARS/RuleMap/Interface/Interface_CompositionalRules.py +++ b/pynars/NARS/RuleMap/Interface/Interface_CompositionalRules.py @@ -1,8 +1,8 @@ -from NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task -from Narsese import Belief -from NAL.Inference import * -from NAL.Theorems import * -import Global +from pynars.NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task +from pynars.Narsese import Belief +from pynars.NAL.Inference import * +from pynars.NAL.Theorems import * +from pynars import Global '''first-order With common subject''' diff --git a/NARS/RuleMap/Interface/Interface_ConditionalRules.py b/pynars/NARS/RuleMap/Interface/Interface_ConditionalRules.py similarity index 98% rename from NARS/RuleMap/Interface/Interface_ConditionalRules.py rename to pynars/NARS/RuleMap/Interface/Interface_ConditionalRules.py index 8bc1fbe..cfcb7c7 100644 --- a/NARS/RuleMap/Interface/Interface_ConditionalRules.py +++ b/pynars/NARS/RuleMap/Interface/Interface_ConditionalRules.py @@ -1,8 +1,8 @@ -from NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task -from Narsese import Belief -from NAL.Inference import * -from NAL.Theorems import * -import Global +from pynars.NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task +from pynars.Narsese import Belief +from pynars.NAL.Inference import * +from pynars.NAL.Theorems import * +from pynars import Global '''deduction''' def _conditional__deduction__0(task: Task, belief: Belief, tasklink: TaskLink=None, termlink: TermLink=None): diff --git a/NARS/RuleMap/Interface/Interface_DecompositionalRules.py b/pynars/NARS/RuleMap/Interface/Interface_DecompositionalRules.py similarity index 93% rename from NARS/RuleMap/Interface/Interface_DecompositionalRules.py rename to pynars/NARS/RuleMap/Interface/Interface_DecompositionalRules.py index 63215f2..f7af74d 100644 --- a/NARS/RuleMap/Interface/Interface_DecompositionalRules.py +++ b/pynars/NARS/RuleMap/Interface/Interface_DecompositionalRules.py @@ -1,8 +1,8 @@ -from NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task -from Narsese import Belief -from NAL.Inference import * -from NAL.Theorems import * -import Global +from pynars.NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task +from pynars.Narsese import Belief +from pynars.NAL.Inference import * +from pynars.NAL.Theorems import * +from pynars import Global def _decompositional__decomposition_theorem2__0_0(task: Task, belief: Belief, tasklink: TaskLink=None, termlink: TermLink=None): return decompositional__decomposition_theorem2(task, belief, (tasklink.budget if tasklink is not None else None), (termlink.budget if termlink is not None else None), inverse_premise=False) diff --git a/NARS/RuleMap/Interface/Interface_SyllogisticRules.py b/pynars/NARS/RuleMap/Interface/Interface_SyllogisticRules.py similarity index 97% rename from NARS/RuleMap/Interface/Interface_SyllogisticRules.py rename to pynars/NARS/RuleMap/Interface/Interface_SyllogisticRules.py index 3ba8534..6e6ffce 100644 --- a/NARS/RuleMap/Interface/Interface_SyllogisticRules.py +++ b/pynars/NARS/RuleMap/Interface/Interface_SyllogisticRules.py @@ -1,8 +1,8 @@ -from NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task -from Narsese import Belief -from NAL.Inference import * -from NAL.Theorems import * -import Global +from pynars.NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task +from pynars.Narsese import Belief +from pynars.NAL.Inference import * +from pynars.NAL.Theorems import * +from pynars import Global '''deduction''' def _syllogistic__deduction__0_1(task: Task, belief: Belief, tasklink: TaskLink=None, termlink: TermLink=None): diff --git a/NARS/RuleMap/Interface/Interface_TemporalRules.py b/pynars/NARS/RuleMap/Interface/Interface_TemporalRules.py similarity index 92% rename from NARS/RuleMap/Interface/Interface_TemporalRules.py rename to pynars/NARS/RuleMap/Interface/Interface_TemporalRules.py index 33608ff..cbc6a96 100644 --- a/NARS/RuleMap/Interface/Interface_TemporalRules.py +++ b/pynars/NARS/RuleMap/Interface/Interface_TemporalRules.py @@ -1,8 +1,8 @@ -from NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task -from Narsese import Belief -from NAL.Inference import * -from NAL.Theorems import * -import Global +from pynars.NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task +from pynars.Narsese import Belief +from pynars.NAL.Inference import * +from pynars.NAL.Theorems import * +from pynars import Global def _temporal__deduction_sequence_eliminate__0(task: Task, belief: Belief, tasklink: TaskLink=None, termlink: TermLink=None): diff --git a/NARS/RuleMap/Interface/Interface_TransformRules.py b/pynars/NARS/RuleMap/Interface/Interface_TransformRules.py similarity index 87% rename from NARS/RuleMap/Interface/Interface_TransformRules.py rename to pynars/NARS/RuleMap/Interface/Interface_TransformRules.py index 1b681c5..b11041f 100644 --- a/NARS/RuleMap/Interface/Interface_TransformRules.py +++ b/pynars/NARS/RuleMap/Interface/Interface_TransformRules.py @@ -1,8 +1,8 @@ -from NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task -from Narsese import Belief -from NAL.Inference import * -from NAL.Theorems import * -import Global +from pynars.NARS.DataStructures import Link, TaskLink, TermLink, LinkType, Task +from pynars.Narsese import Belief +from pynars.NAL.Inference import * +from pynars.NAL.Theorems import * +from pynars import Global '''negation''' def _transform__negation(task: Task, belief: Belief, tasklink: TaskLink=None, termlink: TermLink=None): diff --git a/pynars/NARS/RuleMap/Interface/__init__.py b/pynars/NARS/RuleMap/Interface/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/NARS/RuleMap/RuleMap_v2.py b/pynars/NARS/RuleMap/RuleMap_v2.py similarity index 94% rename from NARS/RuleMap/RuleMap_v2.py rename to pynars/NARS/RuleMap/RuleMap_v2.py index 573492a..60d0caf 100644 --- a/NARS/RuleMap/RuleMap_v2.py +++ b/pynars/NARS/RuleMap/RuleMap_v2.py @@ -10,22 +10,22 @@ from numpy import product -from Config import Enable -from Narsese import Copula, Task -from Narsese import Connector, Statement, Belief, Term, Truth, Compound, Budget +from pynars.Config import Enable +from pynars.Narsese import Copula, Task +from pynars.Narsese import Connector, Statement, Belief, Term, Truth, Compound, Budget from ..DataStructures import LinkType, TaskLink, TermLink -from NAL.Inference import * -from utils.SparseLUT import SparseLUT -from utils.tools import get_size +from pynars.NAL.Inference import * +from pynars.utils.SparseLUT import SparseLUT +from pynars.utils.tools import get_size -from utils.Print import out_print, PrintType +from pynars.utils.Print import out_print, PrintType import time from datetime import datetime import pickle import sty from ._extract_feature import extract_feature, _compound_has_common, _compound_at -import Global +from pynars import Global from .Rules import * @@ -138,18 +138,27 @@ def check_update(): # if Enable.debug: out_print(PrintType.INFO, f'Building time cost: {t_end-t_start}s.') self.rebuild(root_path, clear) else: - self.map.load(str(root_path)) + self.load(str(root_path)) # if Enable.debug: out_print(PrintType.INFO, f'The size of map: {get_size(self.map.lut)/1024/1024:.6f}MB') - + def load(self, root_path: str): + if Enable.debug: out_print(PrintType.INFO, f'Loading RuleMap...') + t_start = time.time() + self.map.load(str(root_path)) + t_end = time.time() + if Enable.debug: out_print(PrintType.INFO, f'Done. Time-cost: {t_end-t_start}s.') + def rebuild(self, root_path: str, clear=True): '''''' + if Enable.debug: out_print(PrintType.INFO, f'Building RuleMap...') t_start = time.time() self.map.build(clear) t_end = time.time() + if Enable.debug: out_print(PrintType.INFO, f'Done. Time-cost: {t_end-t_start}s.') + if Enable.debug: out_print(PrintType.INFO, f'Saving RuleMap...') self.map.dump(str(root_path)) - if Enable.debug: out_print(PrintType.INFO, f'Building time cost: {t_end-t_start}s.') + if Enable.debug: out_print(PrintType.INFO, f'Done.') def draw(self, show_labels=True): diff --git a/NARS/RuleMap/Rules/NAL1.py b/pynars/NARS/RuleMap/Rules/NAL1.py similarity index 96% rename from NARS/RuleMap/Rules/NAL1.py rename to pynars/NARS/RuleMap/Rules/NAL1.py index 2fe4465..f91ba62 100644 --- a/NARS/RuleMap/Rules/NAL1.py +++ b/pynars/NARS/RuleMap/Rules/NAL1.py @@ -1,7 +1,7 @@ from collections import OrderedDict -from NARS.DataStructures import LinkType, TaskLink, TermLink -from utils.SparseLUT import SparseLUT -import Global +from pynars.NARS.DataStructures import LinkType, TaskLink, TermLink +from pynars.utils.SparseLUT import SparseLUT +from pynars import Global from .add_rule import * def add_rules__NAL1(sparse_lut: SparseLUT, structure: OrderedDict): diff --git a/NARS/RuleMap/Rules/NAL2.py b/pynars/NARS/RuleMap/Rules/NAL2.py similarity index 98% rename from NARS/RuleMap/Rules/NAL2.py rename to pynars/NARS/RuleMap/Rules/NAL2.py index ecba284..f8b7b72 100644 --- a/NARS/RuleMap/Rules/NAL2.py +++ b/pynars/NARS/RuleMap/Rules/NAL2.py @@ -1,7 +1,7 @@ from collections import OrderedDict -from NARS.DataStructures import LinkType, TaskLink, TermLink -from utils.SparseLUT import SparseLUT -import Global +from pynars.NARS.DataStructures import LinkType, TaskLink, TermLink +from pynars.utils.SparseLUT import SparseLUT +from pynars import Global from .add_rule import * diff --git a/NARS/RuleMap/Rules/NAL3.py b/pynars/NARS/RuleMap/Rules/NAL3.py similarity index 98% rename from NARS/RuleMap/Rules/NAL3.py rename to pynars/NARS/RuleMap/Rules/NAL3.py index 310399f..36e6107 100644 --- a/NARS/RuleMap/Rules/NAL3.py +++ b/pynars/NARS/RuleMap/Rules/NAL3.py @@ -1,7 +1,7 @@ from collections import OrderedDict -from NARS.DataStructures import LinkType, TaskLink, TermLink -from utils.SparseLUT import SparseLUT -import Global +from pynars.NARS.DataStructures import LinkType, TaskLink, TermLink +from pynars.utils.SparseLUT import SparseLUT +from pynars import Global from .add_rule import * def add_rules__NAL3(sparse_lut: SparseLUT, structure: OrderedDict): diff --git a/NARS/RuleMap/Rules/NAL4.py b/pynars/NARS/RuleMap/Rules/NAL4.py similarity index 97% rename from NARS/RuleMap/Rules/NAL4.py rename to pynars/NARS/RuleMap/Rules/NAL4.py index d566008..59a5414 100644 --- a/NARS/RuleMap/Rules/NAL4.py +++ b/pynars/NARS/RuleMap/Rules/NAL4.py @@ -1,7 +1,7 @@ from collections import OrderedDict -from NARS.DataStructures import LinkType, TaskLink, TermLink -from utils.SparseLUT import SparseLUT -import Global +from pynars.NARS.DataStructures import LinkType, TaskLink, TermLink +from pynars.utils.SparseLUT import SparseLUT +from pynars import Global from .add_rule import * diff --git a/NARS/RuleMap/Rules/NAL5.py b/pynars/NARS/RuleMap/Rules/NAL5.py similarity index 99% rename from NARS/RuleMap/Rules/NAL5.py rename to pynars/NARS/RuleMap/Rules/NAL5.py index e9466db..4f7cf6a 100644 --- a/NARS/RuleMap/Rules/NAL5.py +++ b/pynars/NARS/RuleMap/Rules/NAL5.py @@ -1,7 +1,7 @@ from collections import OrderedDict -from NARS.DataStructures import LinkType, TaskLink, TermLink -from utils.SparseLUT import SparseLUT -import Global +from pynars.NARS.DataStructures import LinkType, TaskLink, TermLink +from pynars.utils.SparseLUT import SparseLUT +from pynars import Global from .add_rule import * diff --git a/NARS/RuleMap/Rules/NAL6.py b/pynars/NARS/RuleMap/Rules/NAL6.py similarity index 51% rename from NARS/RuleMap/Rules/NAL6.py rename to pynars/NARS/RuleMap/Rules/NAL6.py index c275c8a..8b3097c 100644 --- a/NARS/RuleMap/Rules/NAL6.py +++ b/pynars/NARS/RuleMap/Rules/NAL6.py @@ -1,7 +1,7 @@ from collections import OrderedDict -from NARS.DataStructures import LinkType, TaskLink, TermLink -from utils.SparseLUT import SparseLUT -import Global +from pynars.NARS.DataStructures import LinkType, TaskLink, TermLink +from pynars.utils.SparseLUT import SparseLUT +from pynars import Global from .add_rule import * diff --git a/NARS/RuleMap/Rules/NAL7.py b/pynars/NARS/RuleMap/Rules/NAL7.py similarity index 99% rename from NARS/RuleMap/Rules/NAL7.py rename to pynars/NARS/RuleMap/Rules/NAL7.py index 3a392de..34f91a4 100644 --- a/NARS/RuleMap/Rules/NAL7.py +++ b/pynars/NARS/RuleMap/Rules/NAL7.py @@ -1,7 +1,7 @@ from collections import OrderedDict -from NARS.DataStructures import LinkType, TaskLink, TermLink -from utils.SparseLUT import SparseLUT -import Global +from pynars.NARS.DataStructures import LinkType, TaskLink, TermLink +from pynars.utils.SparseLUT import SparseLUT +from pynars import Global from .add_rule import * diff --git a/NARS/RuleMap/Rules/NAL8.py b/pynars/NARS/RuleMap/Rules/NAL8.py similarity index 50% rename from NARS/RuleMap/Rules/NAL8.py rename to pynars/NARS/RuleMap/Rules/NAL8.py index 23281ff..8845a03 100644 --- a/NARS/RuleMap/Rules/NAL8.py +++ b/pynars/NARS/RuleMap/Rules/NAL8.py @@ -1,7 +1,7 @@ from collections import OrderedDict -from NARS.DataStructures import LinkType, TaskLink, TermLink -from utils.SparseLUT import SparseLUT -import Global +from pynars.NARS.DataStructures import LinkType, TaskLink, TermLink +from pynars.utils.SparseLUT import SparseLUT +from pynars import Global from .add_rule import * diff --git a/NARS/RuleMap/Rules/NAL9.py b/pynars/NARS/RuleMap/Rules/NAL9.py similarity index 71% rename from NARS/RuleMap/Rules/NAL9.py rename to pynars/NARS/RuleMap/Rules/NAL9.py index a077bfb..44c4f7a 100644 --- a/NARS/RuleMap/Rules/NAL9.py +++ b/pynars/NARS/RuleMap/Rules/NAL9.py @@ -1,9 +1,9 @@ from collections import OrderedDict -from NARS.DataStructures import LinkType, TaskLink, TermLink -from utils.SparseLUT import SparseLUT -import Global +from pynars.NARS.DataStructures import LinkType, TaskLink, TermLink +from pynars.utils.SparseLUT import SparseLUT +from pynars import Global from .add_rule import * -from NARS.MentalOperation import * +from pynars.NARS.MentalOperation import * def add_rules__NAL9(sparse_lut: SparseLUT=None, structure: OrderedDict=None): '''''' diff --git a/NARS/RuleMap/Rules/__init__.py b/pynars/NARS/RuleMap/Rules/__init__.py similarity index 100% rename from NARS/RuleMap/Rules/__init__.py rename to pynars/NARS/RuleMap/Rules/__init__.py diff --git a/NARS/RuleMap/Rules/add_rule.py b/pynars/NARS/RuleMap/Rules/add_rule.py similarity index 83% rename from NARS/RuleMap/Rules/add_rule.py rename to pynars/NARS/RuleMap/Rules/add_rule.py index 3e02d59..5d1c4c3 100644 --- a/NARS/RuleMap/Rules/add_rule.py +++ b/pynars/NARS/RuleMap/Rules/add_rule.py @@ -10,28 +10,28 @@ from numpy import product -from Config import Enable -from NARS.RuleMap.Interface import Interface_CompositionalRules, Interface_SyllogisticRules, Interface_DecompositionalRules, Interface_TransformRules, Interface_ConditionalRules, Interface_TemporalRules -from Narsese import Copula, Task -from Narsese._py.Connector import Connector -from Narsese._py.Sentence import Goal, Judgement, Quest, Question -from Narsese._py.Statement import Statement -from Narsese._py.Term import Term -from Narsese import Belief, Term, Truth, Compound, Budget +from pynars.Config import Enable +from pynars.NARS.RuleMap.Interface import Interface_CompositionalRules, Interface_SyllogisticRules, Interface_DecompositionalRules, Interface_TransformRules, Interface_ConditionalRules, Interface_TemporalRules +from pynars.Narsese import Copula, Task +from pynars.Narsese._py.Connector import Connector +from pynars.Narsese._py.Sentence import Goal, Judgement, Quest, Question +from pynars.Narsese._py.Statement import Statement +from pynars.Narsese._py.Term import Term +from pynars.Narsese import Belief, Term, Truth, Compound, Budget # from .RuleMap_v1 import RuleMap as RuleMap_v1, RuleCallable from ...DataStructures import LinkType, TaskLink, TermLink -from NAL.Inference import * -from utils.SparseLUT import SparseLUT -from utils.tools import get_size +from pynars.NAL.Inference import * +from pynars.utils.SparseLUT import SparseLUT +from pynars.utils.tools import get_size -from utils.Print import out_print, PrintType +from pynars.utils.Print import out_print, PrintType import time from datetime import datetime import pickle import sty from .._extract_feature import extract_feature, _compound_has_common, _compound_at -import Global +from pynars import Global class RuleCallable(Protocol): def __call__(self, diff --git a/NARS/RuleMap/__init__.py b/pynars/NARS/RuleMap/__init__.py similarity index 100% rename from NARS/RuleMap/__init__.py rename to pynars/NARS/RuleMap/__init__.py diff --git a/NARS/RuleMap/_extract_feature.py b/pynars/NARS/RuleMap/_extract_feature.py similarity index 99% rename from NARS/RuleMap/_extract_feature.py rename to pynars/NARS/RuleMap/_extract_feature.py index 28c308e..a02f8f7 100644 --- a/NARS/RuleMap/_extract_feature.py +++ b/pynars/NARS/RuleMap/_extract_feature.py @@ -1,9 +1,9 @@ from typing import Union from collections import namedtuple -from Narsese._py.Connector import Connector -from NAL.Inference import * -from Narsese import Statement, Term, Compound +from pynars.Narsese._py.Connector import Connector +from pynars.NAL.Inference import * +from pynars.Narsese import Statement, Term, Compound Feature = namedtuple( 'Feature', diff --git a/NARS/RuleMap/_trash/RuleMap_v1.py b/pynars/NARS/RuleMap/_trash/RuleMap_v1.py similarity index 98% rename from NARS/RuleMap/_trash/RuleMap_v1.py rename to pynars/NARS/RuleMap/_trash/RuleMap_v1.py index 6d3e725..e38c0b8 100644 --- a/NARS/RuleMap/_trash/RuleMap_v1.py +++ b/pynars/NARS/RuleMap/_trash/RuleMap_v1.py @@ -1,13 +1,13 @@ from typing import Callable, Tuple, Type, Protocol, List -from NARS.DataStructures import Link, TaskLink, TermLink -from Narsese.Parser.narsese_lark import Rule -from Narsese import Belief, Term, Truth, Compound, Budget -from Narsese._py.Copula import Copula -from Narsese._py.Statement import Statement -from Narsese._py.Term import TermType +from pynars.NARS.DataStructures import Link, TaskLink, TermLink +from pynars.Narsese.Parser.narsese_lark import Rule +from pynars.Narsese import Belief, Term, Truth, Compound, Budget +from pynars.Narsese._py.Copula import Copula +from pynars.Narsese._py.Statement import Statement +from pynars.Narsese._py.Term import TermType from ..DataStructures import LinkType, Task import numpy as np -from NAL.Inference import * +from pynars.NAL.Inference import * from . import Interface_SyllogisticRules diff --git a/NARS/__init__.py b/pynars/NARS/__init__.py similarity index 100% rename from NARS/__init__.py rename to pynars/NARS/__init__.py diff --git a/pynars/Narsese/Parser/__init__.py b/pynars/Narsese/Parser/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Narsese/Parser/_test.py b/pynars/Narsese/Parser/_test.py similarity index 100% rename from Narsese/Parser/_test.py rename to pynars/Narsese/Parser/_test.py diff --git a/Narsese/Parser/_test_earley.py b/pynars/Narsese/Parser/_test_earley.py similarity index 87% rename from Narsese/Parser/_test_earley.py rename to pynars/Narsese/Parser/_test_earley.py index a72eb94..9315661 100644 --- a/Narsese/Parser/_test_earley.py +++ b/pynars/Narsese/Parser/_test_earley.py @@ -1,5 +1,5 @@ from lark import Lark -from Narsese.Parser.parser import TreeToNarsese +from pynars.Narsese.Parser.parser import TreeToNarsese from pathlib import Path filepath = Path(r'Narsese\Parser\narsese.lark') diff --git a/Narsese/Parser/narsese.lark b/pynars/Narsese/Parser/narsese.lark similarity index 100% rename from Narsese/Parser/narsese.lark rename to pynars/Narsese/Parser/narsese.lark diff --git a/Narsese/Parser/narsese_lark.py b/pynars/Narsese/Parser/narsese_lark.py similarity index 100% rename from Narsese/Parser/narsese_lark.py rename to pynars/Narsese/Parser/narsese_lark.py diff --git a/Narsese/Parser/parser.py b/pynars/Narsese/Parser/parser.py similarity index 96% rename from Narsese/Parser/parser.py rename to pynars/Narsese/Parser/parser.py index d02b72c..5b280f0 100644 --- a/Narsese/Parser/parser.py +++ b/pynars/Narsese/Parser/parser.py @@ -1,16 +1,8 @@ -from Narsese._py.Evidence import Base -from Narsese._py.Operation import Operation -from Narsese._py.Budget import Budget -from Narsese._py.Task import Task -from Narsese._py.Sentence import Goal, Punctuation, Question, Quest, Sentence -from Narsese._py.Variable import VarPrefix, Variable -from Narsese._py.Connector import Connector -from Narsese._py.Compound import Compound -from Narsese._py import SELF -from Narsese import Term, Judgement, Tense, Statement, Copula, Truth, Stamp, Interval +from pynars.Narsese import Term, Judgement, Tense, Statement, Copula, Truth, Stamp, Interval +from pynars.Narsese import Base, Operation, Budget, Task, Goal, Punctuation, Question, Quest, Sentence, VarPrefix, Variable, Connector, Compound, SELF from pathlib import Path from datetime import datetime -import Config, Global +from pynars import Config, Global root_path = Path(__file__).parent narsese_path = root_path/Path('./narsese.lark') diff --git a/Narsese/__init__.py b/pynars/Narsese/__init__.py similarity index 100% rename from Narsese/__init__.py rename to pynars/Narsese/__init__.py diff --git a/Narsese/_py/Budget.py b/pynars/Narsese/_py/Budget.py similarity index 98% rename from Narsese/_py/Budget.py rename to pynars/Narsese/_py/Budget.py index 0cc0a5b..cd26f2a 100644 --- a/Narsese/_py/Budget.py +++ b/pynars/Narsese/_py/Budget.py @@ -1,5 +1,5 @@ from math import sqrt -from Config import Config +from pynars.Config import Config from typing import Type from .Truth import Truth diff --git a/Narsese/_py/Compound.py b/pynars/Narsese/_py/Compound.py similarity index 98% rename from Narsese/_py/Compound.py rename to pynars/Narsese/_py/Compound.py index 224ee36..230f4e5 100644 --- a/Narsese/_py/Compound.py +++ b/pynars/Narsese/_py/Compound.py @@ -1,13 +1,11 @@ -# from NAL.Functions.ExtendedBooleanFunctions import Or +# from pynars.NAL.Functions.ExtendedBooleanFunctions import Or from copy import copy import enum from matplotlib.pyplot import axis -from Config import Enable -from Narsese._py.Interval import Interval -from Narsese._py.Sentence import Stamp -# from Narsese._py.Statement import * -from utils.IndexVar import IndexVar +from pynars.Config import Enable +from pynars.Narsese._py.Interval import Interval +from pynars.utils.IndexVar import IndexVar from .Term import Term, TermType from .Terms import Terms from .Connector import Connector, place_holder @@ -15,7 +13,7 @@ from ordered_set import OrderedSet from typing import Set from numpy import prod -from utils.tools import list_contains +from pynars.utils.tools import list_contains import numpy as np class Compound(Term): #, OrderedSet): diff --git a/Narsese/_py/Connector.py b/pynars/Narsese/_py/Connector.py similarity index 98% rename from Narsese/_py/Connector.py rename to pynars/Narsese/_py/Connector.py index 9775cc4..8459f5e 100644 --- a/Narsese/_py/Connector.py +++ b/pynars/Narsese/_py/Connector.py @@ -1,5 +1,5 @@ # from enum import Enum -from utils.IdEnum import IdEnum +from pynars.utils.IdEnum import IdEnum from .Term import Term class Connector(IdEnum): diff --git a/Narsese/_py/Copula.py b/pynars/Narsese/_py/Copula.py similarity index 97% rename from Narsese/_py/Copula.py rename to pynars/Narsese/_py/Copula.py index 56f7ee3..84e4449 100644 --- a/Narsese/_py/Copula.py +++ b/pynars/Narsese/_py/Copula.py @@ -1,5 +1,5 @@ # from enum import Enum -from utils.IdEnum import IdEnum +from pynars.utils.IdEnum import IdEnum class Copula(IdEnum): Inheritance = "-->" diff --git a/Narsese/_py/Evidence.py b/pynars/Narsese/_py/Evidence.py similarity index 96% rename from Narsese/_py/Evidence.py rename to pynars/Narsese/_py/Evidence.py index 814dbb8..709463f 100644 --- a/Narsese/_py/Evidence.py +++ b/pynars/Narsese/_py/Evidence.py @@ -1,4 +1,4 @@ -# from Narsese._py.Task import Task +# from pynars.Narsese._py.Task import Task from .Truth import Truth from .Term import Term from .Statement import Statement @@ -10,8 +10,8 @@ # from .Evidence import Base # from .Task import * -from Config import Config, Enable -import Global +from pynars.Config import Config, Enable +from pynars import Global # class Evidence: # def __init__(self, task) -> None: diff --git a/Narsese/_py/Interval.py b/pynars/Narsese/_py/Interval.py similarity index 100% rename from Narsese/_py/Interval.py rename to pynars/Narsese/_py/Interval.py diff --git a/Narsese/_py/Item.py b/pynars/Narsese/_py/Item.py similarity index 95% rename from Narsese/_py/Item.py rename to pynars/Narsese/_py/Item.py index 3b1598f..82d814a 100644 --- a/Narsese/_py/Item.py +++ b/pynars/Narsese/_py/Item.py @@ -1,6 +1,6 @@ from .Budget import Budget from typing import Type -from Config import Config +from pynars.Config import Config from copy import deepcopy class Item: def __init__(self, hash_value, budget: Budget=None, copy_budget=True) -> None: diff --git a/Narsese/_py/Link.py b/pynars/Narsese/_py/Link.py similarity index 100% rename from Narsese/_py/Link.py rename to pynars/Narsese/_py/Link.py diff --git a/Narsese/_py/Operation.py b/pynars/Narsese/_py/Operation.py similarity index 100% rename from Narsese/_py/Operation.py rename to pynars/Narsese/_py/Operation.py diff --git a/Narsese/_py/Sentence.py b/pynars/Narsese/_py/Sentence.py similarity index 98% rename from Narsese/_py/Sentence.py rename to pynars/Narsese/_py/Sentence.py index 9b4a189..b4890fa 100644 --- a/Narsese/_py/Sentence.py +++ b/pynars/Narsese/_py/Sentence.py @@ -9,8 +9,8 @@ from ordered_set import OrderedSet from .Evidence import * -from Config import Config, Enable -import Global +from pynars.Config import Config, Enable +from pynars import Global class Punctuation(Enum): Judgement = r"." diff --git a/Narsese/_py/Statement.py b/pynars/Narsese/_py/Statement.py similarity index 98% rename from Narsese/_py/Statement.py rename to pynars/Narsese/_py/Statement.py index 4ece41d..2c18ae1 100644 --- a/Narsese/_py/Statement.py +++ b/pynars/Narsese/_py/Statement.py @@ -1,8 +1,8 @@ from copy import copy import enum from lib2to3.pgen2.tokenize import StopTokenizing -from Config import Enable -from utils.IndexVar import IndexVar +from pynars.Config import Enable +from pynars.utils.IndexVar import IndexVar from .Term import Term, TermType from .Copula import Copula from typing import List, Type diff --git a/Narsese/_py/Task.py b/pynars/Narsese/_py/Task.py similarity index 100% rename from Narsese/_py/Task.py rename to pynars/Narsese/_py/Task.py diff --git a/Narsese/_py/Tense.py b/pynars/Narsese/_py/Tense.py similarity index 100% rename from Narsese/_py/Tense.py rename to pynars/Narsese/_py/Tense.py diff --git a/Narsese/_py/Term.py b/pynars/Narsese/_py/Term.py similarity index 97% rename from Narsese/_py/Term.py rename to pynars/Narsese/_py/Term.py index 4e45b5c..ea68331 100644 --- a/Narsese/_py/Term.py +++ b/pynars/Narsese/_py/Term.py @@ -1,11 +1,11 @@ from .Copula import Copula -from Config import Enable +from pynars.Config import Enable from typing import Iterable, List, Set, Type from enum import Enum -from utils.IndexVar import IndexVar +from pynars.utils.IndexVar import IndexVar from numpy import prod from ordered_set import OrderedSet -from utils.tools import find_pos_with_pos, find_var_with_pos +from pynars.utils.tools import find_pos_with_pos, find_var_with_pos from copy import copy, deepcopy class TermType(Enum): diff --git a/Narsese/_py/Terms.py b/pynars/Narsese/_py/Terms.py similarity index 98% rename from Narsese/_py/Terms.py rename to pynars/Narsese/_py/Terms.py index c2aa4ab..abc5eec 100644 --- a/Narsese/_py/Terms.py +++ b/pynars/Narsese/_py/Terms.py @@ -1,10 +1,10 @@ from copy import copy from typing import Iterable, List, Set, Type -from utils.IndexVar import IndexVar +from pynars.utils.IndexVar import IndexVar from ordered_set import OrderedSet -from utils.tools import find_pos_with_pos, find_var_with_pos +from pynars.utils.tools import find_pos_with_pos, find_var_with_pos from .Term import Term -import Global +from pynars import Global class Terms: '''''' diff --git a/Narsese/_py/Truth.py b/pynars/Narsese/_py/Truth.py similarity index 95% rename from Narsese/_py/Truth.py rename to pynars/Narsese/_py/Truth.py index a523c40..204945e 100644 --- a/Narsese/_py/Truth.py +++ b/pynars/Narsese/_py/Truth.py @@ -1,4 +1,4 @@ -from Config import Config +from pynars.Config import Config from typing import Type import numpy as np diff --git a/Narsese/_py/Variable.py b/pynars/Narsese/_py/Variable.py similarity index 97% rename from Narsese/_py/Variable.py rename to pynars/Narsese/_py/Variable.py index 0b75109..af1f79c 100644 --- a/Narsese/_py/Variable.py +++ b/pynars/Narsese/_py/Variable.py @@ -1,9 +1,9 @@ from copy import copy, deepcopy from enum import Enum from typing import Type -from Config import Config +from pynars.Config import Config -from utils.IndexVar import IndexVar +from pynars.utils.IndexVar import IndexVar from .Term import Term class VarPrefix(Enum): diff --git a/Narsese/_py/__init__.py b/pynars/Narsese/_py/__init__.py similarity index 100% rename from Narsese/_py/__init__.py rename to pynars/Narsese/_py/__init__.py diff --git a/Narsese/_pyx/Term.c b/pynars/Narsese/_pyx/Term.c similarity index 100% rename from Narsese/_pyx/Term.c rename to pynars/Narsese/_pyx/Term.c diff --git a/Narsese/_pyx/Term.pyx b/pynars/Narsese/_pyx/Term.pyx similarity index 100% rename from Narsese/_pyx/Term.pyx rename to pynars/Narsese/_pyx/Term.pyx diff --git a/pynars/RL/Pong/__init__.py b/pynars/RL/Pong/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/RL/Pong/main.py b/pynars/RL/Pong/main.py similarity index 100% rename from RL/Pong/main.py rename to pynars/RL/Pong/main.py diff --git a/pynars/RL/SuperMario/__init__.py b/pynars/RL/SuperMario/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pynars/RL/__init__.py b/pynars/RL/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pynars/__init__.py b/pynars/__init__.py new file mode 100644 index 0000000..1475a38 --- /dev/null +++ b/pynars/__init__.py @@ -0,0 +1,4 @@ +__version__ = 'v0.0.1 pre-alpha' +version = __version__.split(' ')[0].lstrip('v') + +print(f'PyNARS version {__version__}') \ No newline at end of file diff --git a/config.json b/pynars/config.json similarity index 100% rename from config.json rename to pynars/config.json diff --git a/utils/.vscode/launch.json b/pynars/utils/.vscode/launch.json similarity index 100% rename from utils/.vscode/launch.json rename to pynars/utils/.vscode/launch.json diff --git a/utils/IdEnum.py b/pynars/utils/IdEnum.py similarity index 100% rename from utils/IdEnum.py rename to pynars/utils/IdEnum.py diff --git a/utils/Index.py b/pynars/utils/Index.py similarity index 100% rename from utils/Index.py rename to pynars/utils/Index.py diff --git a/utils/IndexVar.py b/pynars/utils/IndexVar.py similarity index 100% rename from utils/IndexVar.py rename to pynars/utils/IndexVar.py diff --git a/utils/Print.py b/pynars/utils/Print.py similarity index 100% rename from utils/Print.py rename to pynars/utils/Print.py diff --git a/pynars/utils/SparseLUT/__init__.py b/pynars/utils/SparseLUT/__init__.py new file mode 100644 index 0000000..0a38481 --- /dev/null +++ b/pynars/utils/SparseLUT/__init__.py @@ -0,0 +1,4 @@ +import warnings + +from .sparse_lut import SparseLUT +from typing import Any \ No newline at end of file diff --git a/pynars/utils/SparseLUT/branch_list.pyi b/pynars/utils/SparseLUT/branch_list.pyi new file mode 100644 index 0000000..8bc04c6 --- /dev/null +++ b/pynars/utils/SparseLUT/branch_list.pyi @@ -0,0 +1,49 @@ +import typing +from copy import copy as copy, deepcopy as deepcopy +from typing import Any, Callable, Dict, List, Set, Type + +deepcopy2: Any + +class DictList: + dict: Dict[tuple, Dict[int, Type['Node']]] + len: int + def __init__(self) -> None: ... + def __getitem__(self, key): ... + def __setitem__(self, key, value) -> None: ... + def __len__(self): ... + def values(self) -> List['Node']: ... + def pop(self, key, default: Any | None = ...): ... + def pop_identical(self, key, id, default: Any | None = ...): ... + +class Node: + next_nodes: DictList + last_nodes: DictList + is_end: bool + index: Set[int] + depth: int + def __init__(self, index: set, is_end: bool = ..., depth: int = ..., next_nodes: typing.OrderedDict[tuple, 'Node'] = ..., last_nodes: typing.OrderedDict[tuple, 'Node'] = ...) -> None: ... + def append(self, node: Type['Node']): ... + def duplicate_shallow(self, index: set = ..., enable_last_nodes: bool = ...): ... + def duplicate_deep(self, index: set = ...): ... + def remove_next(self, node: Type['Node'], identical: bool = ...): ... + def remove_last(self, node: Type['Node'], identical: bool = ...): ... + def reset_index(self, index): ... + @property + def is_fan_in(self): ... + @property + def next_nodes_list(self): ... + @property + def last_nodes_list(self): ... + def __getitem__(self, i): ... + def __setitem__(self, i, value) -> None: ... + +class BranchList: + blists: Node + shape: tuple + depth: int + lists: list + def __init__(self, shape: tuple) -> None: ... + def add(self, indices: list, value): ... + def build(self, value_func: Callable = ..., add_func: Callable = ...): ... + def clear(self) -> None: ... + def draw(self, blists: List[Node] = ..., show_labels: bool = ...): ... diff --git a/pynars/utils/SparseLUT/sparse_lut.pyi b/pynars/utils/SparseLUT/sparse_lut.pyi new file mode 100644 index 0000000..3b536aa --- /dev/null +++ b/pynars/utils/SparseLUT/sparse_lut.pyi @@ -0,0 +1,20 @@ +from .branch_list import BranchList as BranchList, Node as Node +from typing import Tuple, Union + +class SparseLUT: + shape: Tuple[int] + depth: int + blist: BranchList + lut: dict + data: list + def __init__(self, shape: tuple) -> None: ... + def add(self, indices: Union[list, tuple], value): ... + def build(self, clear: bool = ...) -> None: ... + def clear(self) -> None: ... + def dump(self, root_path: str): ... + def load(self, root_path: str): ... + def draw(self, show_labels: bool = ...) -> None: ... + def __setitem__(self, indices: tuple, value): ... + def get(self, indices: tuple): ... + def __getitem__(self, indices: tuple): ... + def __len__(self): ... diff --git a/pynars/utils/__init__.py b/pynars/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/_trash/RuleLUT.py b/pynars/utils/_trash/RuleLUT.py similarity index 100% rename from utils/_trash/RuleLUT.py rename to pynars/utils/_trash/RuleLUT.py diff --git a/utils/_trash/SparseLUT.py b/pynars/utils/_trash/SparseLUT.py similarity index 100% rename from utils/_trash/SparseLUT.py rename to pynars/utils/_trash/SparseLUT.py diff --git a/utils/_trash/sparse_lut_v2/branch_list.py b/pynars/utils/_trash/sparse_lut_v2/branch_list.py similarity index 100% rename from utils/_trash/sparse_lut_v2/branch_list.py rename to pynars/utils/_trash/sparse_lut_v2/branch_list.py diff --git a/utils/_trash/sparse_lut_v2/sparse_lut.py b/pynars/utils/_trash/sparse_lut_v2/sparse_lut.py similarity index 100% rename from utils/_trash/sparse_lut_v2/sparse_lut.py rename to pynars/utils/_trash/sparse_lut_v2/sparse_lut.py diff --git a/utils/tools.py b/pynars/utils/tools.py similarity index 100% rename from utils/tools.py rename to pynars/utils/tools.py diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..8c449f1 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,18 @@ +ale-py>=0.7.3 +# git+git://github.com/mila-iqia/atari-representation-learning.git +AutoROM>=0.4.2 +AutoROM.accept-rom-license>=0.4.2 +bidict>=0.21.2 +depq>=1.5.5 +gym>=0.21.0 +jstyleson>=0.0.2 +lark==0.12.0 +matplotlib>=3.5.0 +networkx>=2.6.3 +numpy>=1.21.5 +ordered-set>=4.0.2 +pygame>=2.1.2 +sty>=1.0.0rc2 +tqdm<=3.1.4 +typing>=3.7.4.3 +typing_extensions>=4.0.1 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..7f3ea48 --- /dev/null +++ b/setup.py @@ -0,0 +1,50 @@ +from os import path as os_path +from setuptools import setup, find_packages +import pynars +this_directory = os_path.abspath(os_path.dirname(__file__)) + + +def read_file(filename): + with open(os_path.join(this_directory, filename), encoding='utf-8') as f: + long_description = f.read() + return long_description + + +def read_requirements(filename): + return [line.strip() for line in read_file(filename).splitlines() + if not line.startswith('#')] + +setup( + name='pynars', + python_requires='>=3.7.0', # python version + version= pynars.version+'-6', # package version + description="An implementation of Non-Axiomatic Reasoning System", # introduction, displayed on PyPI + long_description=read_file('README.md'), # Readme + long_description_content_type="text/markdown", # markdown + author="Bowen XU", + author_email='xubowen@pku.edu.cn', + url='https://github.com/bowen-xu/PyNARS', + packages=find_packages(), + install_requires=read_requirements('requirements.txt'), + include_package_data=True, + package_data={ + '': ['*.json', '*.lark', '*.txt'], + 'pynars.utils.SparseLUT': ['*.pyd', '*.pyi'], + }, + license="MIT", + keywords=['NARS', 'Non-Axiomatic Reasoning System', 'NAL', 'Non-Axiomatic Logic', 'Narsese'], + classifiers=[ + 'Development Status :: 2 - Pre-Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Natural Language :: English', + 'Natural Language :: Chinese (Simplified)', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy' + ], +) \ No newline at end of file diff --git a/utils/SparseLUT b/utils/SparseLUT deleted file mode 160000 index 3d9fac0..0000000 --- a/utils/SparseLUT +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3d9fac0a025ed2c6403b0cc66c0f812daab95beb