Skip to content

Commit

Permalink
refactor: 🔇 删除测试用的「打印路径」代码;为真值、预算值增加抽象方法
Browse files Browse the repository at this point in the history
  • Loading branch information
ARCJ137442 committed Aug 29, 2023
1 parent 9562dc4 commit 95432b1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 36 deletions.
36 changes: 1 addition & 35 deletions src/JuNarsese.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,13 @@ module JuNarsese

using Reexport

# !测试用 #

@info "当前路径" pwd()

println("ls: ")
print_path(path) = begin
# 不能进入文件
isdir(path) || isdir("./$path") || return nothing
# 尝试在不同平台进入文件夹
try
cd("./$path")
catch _
try
cd(path)
catch _
@error "进入路径$(path)错误!"
return nothing
end
end
# 查询,打印
paths = split(`ls` |> read |> String, "\n")
try
@info "path@$path"
join(paths, "\n") |> println
catch _ return nothing end
for path in paths
# 避免空路径
isempty(path) || print_path(path)
end
cd("..")
end
print_path(pwd())

# 导入各个文件 #

# 不导出Util
include("Util/Util.jl")

include("Narsese/Narsese.jl")
include("Conversion/Conversion.jl")

# 不导出Util
@reexport using .Narsese
@reexport using .Conversion

Expand Down
8 changes: 8 additions & 0 deletions src/Narsese/Sentences/truth.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ abstract type AbstractTruth end
# 别名
const Truth = ATruth = AbstractTruth

# 抽象类方法 #

"获取频率f"
get_f(t::Truth) = error("$t: 未实现的`get_f`方法!")
"获取信度c"
get_c(t::Truth) = error("$t: 未实现的`get_c`方法!")

"""
判等の法:相等@f,c
- 判等忽略数值精度
Expand All @@ -44,6 +51,7 @@ Base.iterate(t::Truth, state=1) = iterate([get_f(t), get_c(t)], state)
"长度恒等于2"
Base.length(t::Truth) = 2

# 基础结构 #

"""
可配置的「真值」类型
Expand Down
12 changes: 11 additions & 1 deletion src/Narsese/Tasks/budget.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@ export get_p, get_d, get_q
"""
abstract type AbstractBudget end

# 别名
# 别名 #
const Budget = ABudget = AbstractBudget

# 抽象类方法 #

"获取优先级p"
get_p(b::Budget) = error("$b: 未实现的`get_p`方法!")
"获取耐久度d"
get_d(b::Budget) = error("$b: 未实现的`get_d`方法!")
"获取质量q"
get_q(b::Budget) = error("$b: 未实现的`get_q`方法!")

"""
判等の法:相等@p,d,q
- 判等忽略数值精度
Expand All @@ -48,6 +57,7 @@ Base.iterate(b::Budget, state=1) = iterate([get_p(b), get_d(b), get_q(b)], state
"长度恒等于3"
Base.length(b::Budget) = 3

# 基础结构 #

"""
基础的「预算值」类型
Expand Down

0 comments on commit 95432b1

Please sign in to comment.