-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🏗️OpenNARS:基本实现除「特定方言语法」外的Narsese解析 - 顺带一并更新实用库,新增并应用「管道宏」`pipe!` 🏗️ONA:同OpenNARS ✅NARS-Python:基本实现输入转译,但未有成功截获到输出 - 为此引入可选依赖`lazy_static`
- Loading branch information
1 parent
453105e
commit a24c12b
Showing
10 changed files
with
411 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,9 @@ | |
"editor.formatOnSave": true, | ||
"cSpell.words": [ | ||
"Errno", | ||
"rfind", | ||
"runpy", | ||
"traceback" | ||
"traceback", | ||
"tstate" | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//! 用于存储NARS-Python的方言格式 | ||
//! * 🚩【2024-03-26 01:31:44】本质上就是陈述括弧改变了而已 | ||
use narsese::conversion::string::impl_lexical::{ | ||
format_instances::create_format_ascii, NarseseFormat, | ||
}; | ||
use narsese::lexical::Narsese; | ||
|
||
#[cfg(feature = "lazy_static")] | ||
lazy_static::lazy_static! { | ||
/// NARS-Python的方言格式 | ||
/// * 🚩仅在`lazy_static`启用时开启 | ||
pub static ref FORMAT: NarseseFormat = create_format_nars_python(); | ||
} | ||
|
||
pub fn create_format_nars_python() -> NarseseFormat { | ||
let mut f = create_format_ascii(); | ||
f.statement.brackets = ("(".into(), ")".into()); | ||
f | ||
} | ||
|
||
/// 获取NARS-Python的方言格式 | ||
/// * 🚩使用`lazy_static`定义的静态常量,无需重复初始化 | ||
/// * 🚩否则总是创建一个新的「Narsese格式」 | ||
#[cfg(feature = "lazy_static")] | ||
pub fn format_in_nars_python(narsese: &Narsese) -> String { | ||
FORMAT.format_narsese(narsese) | ||
} | ||
|
||
/// 获取NARS-Python的方言格式 | ||
/// * 🚩否则总是创建一个新的「Narsese格式」 | ||
#[cfg(not(feature = "lazy_static"))] | ||
pub fn format_in_nars_python(narsese: &Narsese) -> String { | ||
// 创建格式,并立即格式化Narsese | ||
create_format_nars_python().format_narsese(narsese) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.