Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ARCJ137442 committed Jan 30, 2024
2 parents 800e7e4 + 4c738e0 commit db0f1cd
Show file tree
Hide file tree
Showing 25 changed files with 309 additions and 108 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
/.vscode
*.log

# 本地化配置
Manifest.toml

# 文档
docs/build
docs/site

# 本地化配置
Manifest.toml
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "11330a76-bea1-45e0-8f80-7114e2f607b1"
authors = ["ARCJ137442 <61109168+ARCJ137442@users.noreply.github.com>"]
git-tree-sha1 = "308b5830bd3f1eb7f6bde386a3a23b3ce8b3365e"
repo-url = "https://github.com/ARCJ137442/JuNarsese.jl"
version = "2.6.3"
version = "2.7.0"

[deps]
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Expand Down
51 changes: 34 additions & 17 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,43 @@ Knowledge representation language of NARS
### ***CommonNarsese***

- Defined by [Narsese Grammar (IO Format)](https://github.com/opennars/opennars/wiki/Narsese-Grammar-(Input-Output-Format))
- Among various NARS (Narsese) implementations
- The first generated specification that is most widely accepted syntax
- Among the various NARS(Narsese) implementations, the first to produce specifications and the most widely accepted syntax
- is basically an intersection of the Narsese syntax of the various NARS implementations

Differences from other dialects and supersets:

- Atomic terms:
- Consistently use `$`, `#`, `?`, `^` to distinguish "independent variable", "dependent variable", "query variable", "operator"
- Consistently use separate `_` to represent "placeholders"
- Compound terms:
- Consistently use special brackets `{terms...}` and `[terms...]` to represent "extension set" and "intension set"
- Consistently use "(connector, term...)" to represent "non-extension and intension compound terms"
- e.g. `(&, <A --> B>, ^op)`
- Do not use prefix expression for "negation" (such as `--<A --> B>`)
- Do not use infix expression for other "binary compound terms" (such as `(A*B)`)
- Propositions:
- Consistently use angle brackets to represent propositions, no other options
- e.g. `<A --> B>`
- Do not use retrospective equivalence "<\\>"
- Consistently use predictive equivalence "</>" with equivalent representational capability instead
- e.g. `<A <\> B>` will be expressed as `<B </> A>`
#### Atomic term

- Consistently use `$`, `#`, `?`, `^` to distinguish "independent variable", "dependent variable", "query variable", "operator"
- Consistently use separate `_` to represent "placeholders"

#### Compound term

- Consistently use special brackets `{terms...}` and `[terms...]` to represent "extension set" and "intension set"
- Consistently use "(connector, term...)" to represent "non-extension and intension compound terms"
- e.g. `(&, <A --> B>, ^op)`
- Do not use prefix expression for "negation" (such as `--<A --> B>`)
- Do not use infix expression for other "binary compound terms" (such as `(A*B)`)

#### Statement

- Consistently use angle brackets to represent propositions, no other options
- e.g. `<A --> B>`
- Not use retrospective equivalence "<\\>"
- Consistently use predictive equivalence "</>" with equivalent representational capability instead
- e.g. `<A <\> B>` will be expressed as `<B </> A>`

#### Sentence

- Truth default: No part of the truth value can be entered during statement parsing
- Such truth values will be completed when entering a specific NARS implementation
- e.g. OpenNARS 'Default truth' `%1.0; 0.9%`
- e.g. OpenJunars 'Default truth' `%1.0; 0.5%`
- Specific form
- Single default (single truth value) : f is specified, and c is missing
- Such as `A. %1.0%`
- Full default (null true value) : neither f nor c is specified
- Such as `A`

## Code Map

Expand Down
61 changes: 40 additions & 21 deletions README-zh_tr.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,46 @@ NARS 的知識表示語言

### ***CommonNarsese***

-[Narsese Grammar (IO Format)](https://github.com/opennars/opennars/wiki/Narsese-Grammar-(Input-Output-Format)) 定義,
- 在各類 NARS(Narsese) 實現中,
- 最先產生規範,並最為廣泛接受的一種語法

與其它方言、超集的不同點舉例:

- 原子詞項:
- 一律使用 `$``#``?``^` 區分「獨立變量」「非獨變量」「查詢變量」「操作」
- 一律使用單獨的 `_` 表示「像佔位符」
- 複合詞項:
- 一律使用特殊括弧 `{詞項...}``[詞項...]` 表示「外延集」「內涵集」
- 一律使用「圓括號+前綴表達式」`(連接符, 詞項...)` 形式表示「非外延集、內涵集的複合詞項」
-`(&, <A --> B>, ^op)`
- 對「否定」不使用前綴表達式(如`--<A --> B>`
- 對其它「二元複合詞項」不使用中綴表達式(如`(A*B)`
- 陳述:
- 一律使用尖括號表示陳述,沒有其他選項
-`<A --> B>`
- 不使用「回顧性等價」`<\>`系詞
- 一律用表義能力等同的「預測性等價」`</>`系詞代替
-`<A <\> B>` 將表示為 `<B </> A>`
-[Narsese Grammar (IO Format)](https://github.com/opennars/opennars/wiki/Narsese-Grammar-(Input-Output-Format))定義,
- 在各類NARS(Narsese)實現中,最先產生規範,且最廣爲接受的一種語法
- 基本是各路NARS實現之Narsese語法的**交集**

與其它方言、超集的不同點舉例:

#### Atom 原子詞項

- 一律使用`$``#``?``^`區分「獨立變量」「非獨變量」「查詢變量」「操作」
- 一律使用單獨的`_`表示「像佔位符」
- 一律不在名稱中包含特殊符號
-`^goto`(不允許`^go-to`

#### Compound 複合詞項

- 一律使用特殊括弧`{詞項...}``[詞項...]`表示「外延集」「內涵集」
- 一律使用「圓括號+前綴表達式」`(連接符, 詞項...)`形式表示「非外延集、內涵集的複合詞項」
-`(&, <A --> B>, ^op)`
- 對「否定」不使用前綴表達式
- 對其它「二元複合詞項」不使用中綴表達式

#### Statement 陳述

- 一律使用尖括號表示陳述,沒有其他選項
-`<A --> B>`
- 不使用「回顧性等價」`<\>`繫詞
- 一律用表義能力等同的「預測性等價」`</>`繫詞代替
-`<A <\> B>`將表示爲`<B </> A>`

#### Sentence 語句

- 「真值缺省」:解析語句時,允許不輸入一部分真值
- 此類真值將在輸入具體NARS實現時被補全
- 如:OpenNARS的「默認真值」`%1.0; 0.9%`
- 如:OpenJunars的「默認真值」`%1.0; 0.5%`
- 具體形式
- 單缺省(單真值):f已指定,缺c值
-`A. %1.0%`
- 全缺省(空真值):f、c均未指定
-`A.`

## 代碼地圖

Expand Down
53 changes: 36 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,45 @@ NARS的知识表示语言
### ***CommonNarsese***

-[Narsese Grammar (IO Format)](https://github.com/opennars/opennars/wiki/Narsese-Grammar-(Input-Output-Format))定义,
- 在各类NARS(Narsese)实现中,
- 最先产生规范,并最为广泛接受的一种语法
- 在各类NARS(Narsese)实现中,最先产生规范,且最广为接受的一种语法
- 基本是各路NARS实现之Narsese语法的**交集**

与其它方言、超集的不同点举例:

- 原子词项:
- 一律使用`$``#``?``^`区分「独立变量」「非独变量」「查询变量」「操作」
- 一律使用单独的`_`表示「像占位符」
- 复合词项:
- 一律使用特殊括弧`{词项...}``[词项...]`表示「外延集」「内涵集」
- 一律使用「圆括号+前缀表达式」`(连接符, 词项...)`形式表示「非外延集、内涵集的复合词项」
-`(&, <A --> B>, ^op)`
- 对「否定」不使用前缀表达式(如`--<A --> B>`
- 对其它「二元复合词项」不使用中缀表达式(如`(A*B)`
- 陈述:
- 一律使用尖括号表示陈述,没有其他选项
-`<A --> B>`
- 不使用「回顾性等价」`<\>`系词
- 一律用表义能力等同的「预测性等价」`</>`系词代替
-`<A <\> B>`将表示为`<B </> A>`
#### Atom 原子词项

- 一律使用`$``#``?``^`区分「独立变量」「非独变量」「查询变量」「操作」
- 一律使用单独的`_`表示「像占位符」
- 一律不在名称中包含特殊符号
-`^goto`(不允许`^go-to`

#### Compound 复合词项

- 一律使用特殊括弧`{词项...}``[词项...]`表示「外延集」「内涵集」
- 一律使用「圆括号+前缀表达式」`(连接符, 词项...)`形式表示「非外延集、内涵集的复合词项」
-`(&, <A --> B>, ^op)`
- 对「否定」不使用前缀表达式
- 对其它「二元复合词项」不使用中缀表达式

#### Statement 陈述

- 一律使用尖括号表示陈述,没有其他选项
-`<A --> B>`
- 不使用「回顾性等价」`<\>`系词
- 一律用表义能力等同的「预测性等价」`</>`系词代替
-`<A <\> B>`将表示为`<B </> A>`

#### Sentence 语句

- 「真值缺省」:解析语句时,允许不输入一部分真值
- 此类真值将在输入具体NARS实现时被补全
- 如:OpenNARS的「默认真值」`%1.0; 0.9%`
- 如:OpenJunars的「默认真值」`%1.0; 0.5%`
- 具体形式
- 单缺省(单真值):f已指定,缺c值
-`A. %1.0%`
- 全缺省(空真值):f、c均未指定
-`A.`

## 代码地图

Expand Down
19 changes: 16 additions & 3 deletions src/Conversion/core/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -772,13 +772,16 @@ end

begin "语句相关"

"真值→字符串"
"真值→字符串(通用@单真值、双真值)"
narsese2data(parser::StringParser, t::ATruth) = form_truth!budget(
parser.truth_brackets..., parser.truth_separator,
collect(t)
)

"真值→字符串"
"真值→字符串(空真值)"
narsese2data(parser::StringParser, ::TruthNull) = ""

"预算值→字符串"
narsese2data(parser::StringParser, b::ABudget) = form_truth!budget(
parser.budget_brackets..., parser.budget_separator,
collect(b)
Expand Down Expand Up @@ -875,6 +878,7 @@ begin "语句相关"
parser::StringParser, ::Type{Truth}, s::AbstractString,
stripped::Bool = false
)
# 未剥皮⇒剥皮 #
if !stripped
left::String, right::String = parser.truth_brackets
return data2narsese(
Expand All @@ -883,7 +887,16 @@ begin "语句相关"
true # 标示已经剥皮
)
end
# 剥皮后
# 剥皮后⇒尝试分隔,分为「无真值、单真值与双真值」 #
# 空字串⇒空真值
isempty(s) && return TruthNull()
# 无分隔符⇒单真值
if !contains(s, parser.truth_separator) # 无分隔符
return Narsese.default_precision_truth(
Narsese.parse_default_float(s)
)
end
# 最终⇒双真值
f_str::AbstractString, c_str::AbstractString = split(
s, # 已剥皮,待分割
parser.truth_separator # 分隔符
Expand Down
8 changes: 4 additions & 4 deletions src/Narsese/Sentences/sentence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ end
@inline function SentenceJudgement(
term::Term; # 下面无顺序,作为可选参数
stamp::Stamp = StampBasic(),
truth::ATruth = Truth64(1.0, 0.5),
truth::ATruth = truth_null, # !【2024-01-27 16:29:04】现在默认为空真值(未指定状态)
)
SentenceJudgement(
term,
Expand All @@ -69,7 +69,7 @@ end
@inline function SentenceGoal(
term::Term; # 下面无顺序,作为可选参数
stamp::Stamp = StampBasic(),
truth::ATruth = Truth64(1.0, 0.5),
truth::ATruth = truth_null, # !【2024-01-27 16:29:04】现在默认为空真值(未指定状态)
)
SentenceGoal(
term,
Expand All @@ -93,7 +93,7 @@ end
@inline function SentenceQuestion(
term::Term; # 下面无顺序,作为可选参数
stamp::Stamp = StampBasic(),
truth::UNothing{TruthBasic} = nothing # 📝Julia: 可选参数中不能省略参数变量名,会导致「畸形表达式」错误
truth::UNothing{ATruth} = nothing # 📝Julia: 可选参数中不能省略参数变量名,会导致「畸形表达式」错误
)
SentenceQuestion(
term,
Expand All @@ -115,7 +115,7 @@ end
@inline function SentenceQuest(
term::Term; # 下面无顺序,作为可选参数
stamp::Stamp = StampBasic(), # 将「只有一个参数」的情况交给上面
truth::UNothing{TruthBasic} = nothing
truth::UNothing{ATruth} = nothing
)
SentenceQuest(
term,
Expand Down
Loading

0 comments on commit db0f1cd

Please sign in to comment.