Skip to content

Commit 18dfd30

Browse files
committed
fixed some Github test issue
1 parent 205fb53 commit 18dfd30

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

inference_engine_algorithms/__init__.py

Whitespace-only changes.

inference_engine_algorithms/forward_chaining.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
def find_symbols_in_kb(knowledge_base: list[str]) -> dict:
1414
'''
15-
Find all unique symbols in the Knowledge_base
15+
Find all unique symbols in the Knowledge_base.
1616
:param knowledge_base: a list of string of definite clauses
1717
:returns: a dictionary with symbols as the keys their values are False
1818
'''
@@ -31,9 +31,9 @@ def find_symbols_in_kb(knowledge_base: list[str]) -> dict:
3131
def number_of_symbols_in_premise(knowledge_base: list[str]) -> dict:
3232

3333
'''
34-
Count the number of prposiotion symbols in each premise of KB clause
34+
Count the number of prposiotion symbols in each premise of KB clause.
3535
:param knowledge_base: a list of string of definite clauses
36-
:returns: a dictionary with key as the premise of KB clause and value of count of symbols in the premise
36+
:returns: a dict with keys as the premise and value is count of symbols in premise
3737
'''
3838

3939
count = {}
@@ -49,7 +49,7 @@ def number_of_symbols_in_premise(knowledge_base: list[str]) -> dict:
4949

5050
def get_known_facts(knowledge_base: list[str]) -> list[str]:
5151
'''
52-
Get the known facts in KB
52+
Get the known facts in KB.
5353
:param knowledge_base: a list of string of definite clauses
5454
:returns: list of facts
5555
@@ -66,13 +66,17 @@ def get_known_facts(knowledge_base: list[str]) -> list[str]:
6666

6767

6868
def forward_chaining(knowledge_base: list[str], query:str) -> bool:
69-
''' Forward chaining on Knowledge Base(KB) of definite clauses
69+
''' Forward chaining on Knowledge Base(KB) of definite clauses.
7070
:param knowledge_base: a list of string of definite clauses
71-
:param query: a single proposition symbol that you are checking if it is entailed by the KB
71+
:param query: a single proposition symbol
7272
:returns: If the query entailed by the KB or not?
73-
>>> forward_chaining([ "P => Q", "L & M => P", "B&L=> M", "A&P=>L", "A&B=>L", "A", "B" ], "Q")
73+
>>> input_kb = [ "P => Q", "L & M => P",
74+
... "B&L=> M", "A&P=>L", "A&B=>L", "A", "B" ]
75+
>>> forward_chaining(input_kb, "Q")
7476
True
75-
>>> forward_chaining([ "P => Q", "L & M => P", "B&L=> M", "A&P=>L", "A&B=>L", "A", "B" ], "C")
77+
>>> input_kb = [ "P => Q", "L & M => P",
78+
... "B&L=> M", "A&P=>L", "A&B=>L", "A", "B" ]
79+
>>> forward_chaining(input_kb, "C")
7680
False
7781
7882
'''
@@ -110,15 +114,14 @@ def forward_chaining(knowledge_base: list[str], query:str) -> bool:
110114

111115
'''
112116
1)- KB must be written in horn form.
113-
2)- It must be written as an implcaion whose
114117
2)- It must be written as an implcaion whose
115-
its premise(head) must be conjunction of positive literals and its conclusion(body)
116-
3)- It must contains facts about the world which are written as a single proposition symbol
118+
its premise(head) must be conjunction of positive literals and its conclusion(body).
119+
3)- Contains facts about the world as single proposition symbol.
117120
'''
118121
QUERY = "Q"
119122

120123
'''
121-
Query is a signe proposition symbol that you check if it is entailed by the KB
124+
Query is a signe proposition symbol that you check if it is entailed by the KB.
122125
123126
'''
124127

0 commit comments

Comments
 (0)