-
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.
Rule groups. Why is install different from Rete.install?
- Loading branch information
1 parent
4fc12d9
commit a74a5bd
Showing
7 changed files
with
73 additions
and
7 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 |
---|---|---|
|
@@ -4,6 +4,7 @@ authors = ["MarkNahabedian <[email protected]> and contributors"] | |
version = "1.0.0-DEV" | ||
|
||
[deps] | ||
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" | ||
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09" | ||
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" | ||
|
||
|
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
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,31 @@ | ||
|
||
abstract type RuleGroup1 <: Rule end | ||
|
||
@rule RuleGroup1.AdjacentLetters(a::Char, b::Char) begin | ||
if codepoint(a) + 1 == codepoint(b) | ||
emit((a, b)) | ||
end | ||
end | ||
|
||
@rule RuleGroup1.DigitBetweenLetters(letters::Tuple{Char, Char}, | ||
digit::Int) begin | ||
emit(letters[1] * string(digit) * letters[2]) | ||
end | ||
|
||
@testset "rule grouping" begin | ||
root = BasicReteNode("root") | ||
Rete.install(root, RuleGroup1) | ||
conclusions = ensure_IsaMemoryNode(root, String) | ||
for c in 'a':'c' | ||
receive(root, c) | ||
end | ||
for i in 1:3 | ||
receive(root, i) | ||
end | ||
@test conclusions.memory == | ||
Set{String}([ | ||
"a1b", "a2b", "a3b", | ||
"b1c", "b2c", "b3c" | ||
]) | ||
end | ||
|
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 |
---|---|---|
|
@@ -81,4 +81,5 @@ end | |
|
||
include("rule_example_1.jl") | ||
include("rule_example_2.jl") | ||
include("rule_grouping.jl") | ||
|