Skip to content

Commit

Permalink
adding ability to toggle structural and immediate on and off
Browse files Browse the repository at this point in the history
  • Loading branch information
maxeeem committed Apr 27, 2024
1 parent 8e68b95 commit 0334569
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 212 deletions.
2 changes: 1 addition & 1 deletion Tests/test_NAL/test_NAL1.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_deduction(self):
tasks_derived = process_two_premises(
'<bird --> animal>. %1.00;0.90%',
'<robin --> bird>. %1.00;0.90%',
20
10
)
self.assertTrue(
output_contains(tasks_derived, '<robin --> animal>. %1.00;0.81%')
Expand Down
1 change: 1 addition & 0 deletions Tests/test_NAL/test_NAL2.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def test_analogy_0(self):
'<gull <-> swan>. %1.00;0.90%',
20
)
for t in tasks_derived: print(t)
self.assertTrue(
output_contains(tasks_derived, '<gull --> swimmer>. %1.00;0.81%')
)
Expand Down
6 changes: 3 additions & 3 deletions Tests/test_NAL/test_NAL6.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ def test_abduction_with_variable_elimination_abduction(self):
tasks_derived = process_two_premises(
'<(&&,<#1 --> lock>,<#1 --> (/,open,$2,_)>) ==> <$2 --> key>>. %1.00;0.90%',
'<<lock1 --> (/,open,$1,_)> ==> <$1 --> key>>. %1.00;0.90%',
4
20
)

self.assertTrue(
Expand All @@ -983,7 +983,7 @@ def test_abduction_with_variable_elimination_abduction_0(self):
tasks_derived = process_two_premises(
'<(&&,<#1 --> A>,<#1 --> B>) ==> C>. %1.00;0.90%',
'<<M --> A> ==> C>. %1.00;0.90%',
4
20
)
self.assertTrue(
output_contains(tasks_derived, '<M --> B>. %1.00;0.45%')
Expand Down Expand Up @@ -1112,7 +1112,7 @@ def test_0(self):
<(&&, <#x-->A>, <#x-->B>, <<$y-->C>==><$y-->D>>, <$z-->E>) ==> <$x-->H>>.
'''

tasks_derived = rule_map_two_premises(
tasks_derived = process_two_premises(
"<(&&, <#x-->A>, <#x-->B>, <<$y-->C>==><$y-->D>>, <$z-->E>) ==> (&&, <$z-->F>, <#p-->G>, <#p-->H>)>. %1.00;0.90%",
"<(&&, <$x-->F>, <#p-->G>, <#p-->H>)==><$x-->H>>. %1.00;0.90%",
10)
Expand Down
70 changes: 31 additions & 39 deletions Tests/test_NAL/test_NAL7.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class TEST_NAL7(unittest.TestCase):
def setUp(self):
Global.time = 0
nars.reset()

''''''
Expand All @@ -34,8 +33,9 @@ def test_deduction(self):
tasks_derived = process_two_premises(
'<<(*, $x, room_101) --> enter> =\> <(*, $x, door_101) --> open>>. %0.90;0.90%',
'<<(*, $y, door_101) --> open> =\> <(*, $y, key_101) --> hold>>. %0.80;0.90%',
10
100
)

self.assertTrue(
output_contains(tasks_derived, '<<(*,$0,room_101) --> enter> =\> <(*,$0,key_101) --> hold>>. %0.72;0.58%')
)
Expand All @@ -59,7 +59,7 @@ def test_expemplification(self):
tasks_derived = process_two_premises(
'<<(*, $x, room_101) --> enter> =\> <(*, $x, door_101) --> open>>. %0.90;0.90%',
'<<(*, $y, door_101) --> open> =\> <(*, $y, key_101) --> hold>>. %0.80;0.90%',
10
100
)
self.assertTrue(
output_contains(tasks_derived, '<<(*,$0,key_101) --> hold> =/> <(*,$0,room_101) --> enter>>. %1.00;0.37%')
Expand All @@ -76,7 +76,7 @@ def test_induction_0(self):
'Someone open door_101 after he hold key_101
<<(*, $y, door_101) --> open> =\> <(*, $y, key_101) --> hold>>. %0.80;0.90%
10
100
'If someone hold key_101, he will enter room_101
''outputMustContain('<<(*,$1,key_101) --> hold> =/> <(*,$1,room_101) --> enter>>. %0.90;0.39%')
Expand All @@ -86,7 +86,7 @@ def test_induction_0(self):
tasks_derived = process_two_premises(
'<<(*, $x, door_101) --> open> =/> <(*, $x, room_101) --> enter>>. %0.90;0.90%',
'<<(*, $y, door_101) --> open> =\> <(*, $y, key_101) --> hold>>. %0.80;0.90%',
10
100
)

self.assertTrue(
Expand Down Expand Up @@ -117,7 +117,7 @@ def test_induction_1(self):
tasks_derived = process_two_premises(
'<<(*, $y, door_101) --> open> =\> <(*, $y, key_101) --> hold>>. %0.80;0.90%',
'<<(*, $x, door_101) --> open> =/> <(*, $x, room_101) --> enter>>. %0.90;0.90%',
10
100
)

self.assertTrue(
Expand Down Expand Up @@ -147,7 +147,7 @@ def test_comparison_0(self):
tasks_derived = process_two_premises(
'<<(*, $x, door_101) --> open> =/> <(*, $x, room_101) --> enter>>. %0.90;0.90%',
'<<(*, $y, door_101) --> open> =\> <(*, $y, key_101) --> hold>>. %0.80;0.90%',
10
100
)

self.assertTrue(
Expand All @@ -173,7 +173,7 @@ def test_comparison_1(self):
tasks_derived = process_two_premises(
'<<(*, $y, door_101) --> open> =\> <(*, $y, key_101) --> hold>>. %0.80;0.90%',
'<<(*, $x, door_101) --> open> =/> <(*, $x, room_101) --> enter>>. %0.90;0.90%',
10
100
)

self.assertTrue(
Expand All @@ -199,7 +199,7 @@ def test_comparison_2(self):
tasks_derived = process_two_premises(
'<<(*, $x, room_101) --> enter> =/> <(*, $x, door_101) --> open>>. %0.90;0.90%',
'<<(*, $y, key_101) --> hold> =\> <(*, $y, door_101) --> open>>. %0.80;0.90%',
10
100
)

self.assertTrue(
Expand All @@ -225,7 +225,7 @@ def test_comparison_3(self):
tasks_derived = process_two_premises(
'<<(*, $y, key_101) --> hold> =\> <(*, $y, door_101) --> open>>. %0.80;0.90%',
'<<(*, $x, room_101) --> enter> =/> <(*, $x, door_101) --> open>>. %0.90;0.90%',
10
100
)

self.assertTrue(
Expand Down Expand Up @@ -277,11 +277,11 @@ def test_inference_on_tense_0(self):
''outputMustContain('<(*,John,room_101) --> enter>. :!5: %1.00;0.81%')
'''
tasks_derived = process_two_premises(
'<<(*,John,key_101) --> hold> =/> <(*,John,room_101) --> enter>>. %1.00;0.90%',
'<(*,John,key_101) --> hold>. :|: %1.00;0.90%',
100
'<<(*,John,key_101) --> hold> =/> <(*,John,room_101) --> enter>>. %1.00;0.90%',
20
)
Global.time = 0

self.assertTrue(
output_contains(tasks_derived, '<(*,John,room_101) --> enter>. :!5: %1.00;0.81%')
)
Expand All @@ -303,11 +303,11 @@ def test_inference_on_tense_1(self):
''outputMustContain('<(*,John,key_101) --> hold>. :!-10: %1.00;0.45%')
'''
tasks_derived = process_two_premises(
'<<(*,John,key_101) --> hold> =/> <(*,John,room_101) --> enter>>. %1.00;0.90%',
'<(*,John,room_101) --> enter>. :\: %1.00;0.90%',
100
'<<(*,John,key_101) --> hold> =/> <(*,John,room_101) --> enter>>. %1.00;0.90%',
10
)
Global.time = 0

self.assertTrue(
output_contains(tasks_derived, '<(*,John,key_101) --> hold>. :!-10: %1.00;0.45%')
)
Expand All @@ -331,7 +331,7 @@ def test_inference_on_tense_2(self):
tasks_derived = process_two_premises(
'<<(*,John,key_101) --> hold> =/> <(*,John,room_101) --> enter>>. %1.00;0.90%',
'<(*,John,room_101) --> enter>. :\: %1.00;0.90%',
100
30
)

self.assertTrue(
Expand Down Expand Up @@ -375,9 +375,9 @@ def test_induction_on_tense_0_0(self):
tasks_derived.extend(process_two_premises(
'<John --> (/,enter,_,room_101)>. :|:',
None,
100
20
))
Global.time = 0

self.assertTrue(
output_contains(tasks_derived, '<<John --> (/,enter,_,room_101)> =\> (&/,<John --> (/,open,_,door_101)>,+6)>. :!6: %1.00;0.45%')
)
Expand Down Expand Up @@ -412,17 +412,12 @@ def test_induction_on_tense_0_1(self):
10
'''
tasks_derived = process_two_premises(
rules, task, belief, concept, task_link, term_link, result1, result2 = rule_map_two_premises(
'<John --> (/,open,_,door_101)>. :|: ',
None,
6
)
tasks_derived.extend(process_two_premises(
'<John --> (/,enter,_,room_101)>. :|: ',
None,
200
))
Global.time = 0
'John.'
)
tasks_derived = [rule(task, belief, task_link, term_link) for rule in rules]
self.assertTrue(
output_contains(tasks_derived, '<<$1 --> (/,enter,_,room_101)> =\> (&/,<$1 --> (/,open,_,door_101)>,+6)>. :!6: %1.00;0.45%')
)
Expand All @@ -449,17 +444,12 @@ def test_induction_on_tense_1(self):
'changed fomr +2 to +4 due to changes in interval calculations
'this one is working, just throwing exception
'''
tasks_derived = process_two_premises(
rules, task, belief, concept, task_link, term_link, result1, result2 = rule_map_two_premises(
'<(*,John,key_101) --> hold>. :|: %1.00;0.90% ',
None,
6
)
tasks_derived.extend(process_two_premises(
'<<(*,John,door_101) --> open> =/> <(*,John,room_101) --> enter>>. :|: %1.00;0.90%',
None,
200
))
Global.time = 0
'John.'
)
tasks_derived = [rule(task, belief, task_link, term_link) for rule in rules]
self.assertTrue(
output_contains(tasks_derived, '<(&/,<(*,John,key_101) --> hold>,+6,<(*,John,door_101) --> open>) =/> <(*,John,room_101) --> enter>>. :!6: %1.00;0.45%')
)
Expand All @@ -483,8 +473,9 @@ def test_analogy(self):
tasks_derived = process_two_premises(
'<<(*, $x, door_101) --> open> =/> <(*, $x, room_101) --> enter>>. %0.95;0.90%',
'<<(*, $x, room_101) --> enter> <|> <(*, $x, corridor_100) --> leave>>. %1.00;0.90%',
10
40
)

self.assertTrue(
output_contains(tasks_derived, '<<(*,$0,door_101) --> open> =/> <(*,$0,corridor_100) --> leave>>. %0.95;0.81%')
)
Expand All @@ -511,8 +502,9 @@ def test_deduction_sequence_eliminate_0(self):
tasks_derived = process_two_premises(
'<(*, John, key_101) --> hold>. :\: %1.00;0.90%',
'<(&/,<(*, John, key_101) --> hold>,+100) =/> <(*, John, room_101) --> enter>>. %1.00;0.90%',
20
200
)
tasks_derived = [rule(task, belief, task_link, term_link) for rule in rules]
self.assertTrue(
output_contains(tasks_derived, '<(*,John,room_101) --> enter>. :!100: %1.00;0.81%')
)
Expand Down
1 change: 0 additions & 1 deletion pynars/Console.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pathlib import Path
from pynars import Narsese, NAL, NARS
from time import sleep
from multiprocessing import Process
import os
from pynars.Narsese.Parser.parser import TreeToNarsese
from pynars.Narsese import Sentence
Expand Down
Loading

0 comments on commit 0334569

Please sign in to comment.