Skip to content

Commit

Permalink
Update: use existing embedding if a memory item of same term already …
Browse files Browse the repository at this point in the history
…exists, eternalize also when Narsese events are issued and update the currentTime also properly in case of Narsese events
  • Loading branch information
patham9 committed May 1, 2023
1 parent 7b272fd commit 939a78e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,14 @@ def ProcessInput(currentTime, memory, inputforNAR, backups = ["input", "answers"
if c2 > c:
memory[(term, time)] = (currentTime, usefulness + usefulnessAddition, (f2, c2), embedding)
else:
memory[(term, time)] = (currentTime, usefulnessAddition, (f2, c2), Term_Embedded(term))
if ">." in inputforNAR or "! :|:" in inputforNAR:
#optimization: if there is already an eternalized version with the same term, use that embedding:
if (term, "eternal") in memory:
embedding = memory[(term, "eternal")][3]
else:
embedding = Term_Embedded(term)
#now where we got the embedding too, make entry to memory:
memory[(term, time)] = (currentTime, usefulnessAddition, (f2, c2), embedding)
if ">." in inputforNAR or "! :|:" in inputforNAR or ". :|:" in inputforNAR:
currentTime += 1
if inputforNAR.isdigit():
currentTime += int(inputforNAR)
Expand Down
1 change: 1 addition & 0 deletions NarsGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def NarsGPT_AddInput(inp):
occurrenceTimeInfo = "" if answer["occurrenceTime"] == "eternal" else " t="+answer["occurrenceTime"]
print("Answer: " + answer["term"] + answer["punctuation"] + " {" + str(answer["truth"]["frequency"]) + " " + str(answer["truth"]["confidence"]) + "}" + occurrenceTimeInfo)
if not inp.endswith("?"):
Memory_Eternalize(currentTime, memory, eternalizationDistance)
Memory_store(filename, memory, currentTime)
return RET_ANSWER
if inp.startswith("*memory"):
Expand Down

0 comments on commit 939a78e

Please sign in to comment.