-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneralKnowledgeBase.py
More file actions
33 lines (27 loc) · 1.04 KB
/
Copy pathGeneralKnowledgeBase.py
File metadata and controls
33 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from GeneralClause import GeneralClause
class GeneralKnowledgeBase:
def __init__(self):
"""Initialize an empty Knowledge Base."""
self.clauses = []
self.facts = []
self.query = None
def parse_input(self, sentences, query):
"""Parse input sentences and query to populate the Knowledge Base.
Args:
sentences (list): List of strings representing sentences in the knowledge base.
query (str): The query to be answered by the knowledge base.
"""
for sentence in sentences:
sentence = sentence.strip()
if sentence:
self.clauses.append(GeneralClause(sentence))
self.query = query
def get_all_symbols(self):
"""Get all propositional symbols present in the knowledge base.
Returns:
list: List of unique propositional symbols.
"""
all_symbols = set()
for clause in self.clauses:
all_symbols.update(clause.get_symbols())
return list(all_symbols)