| … | … | @@ -306,7 +306,7 @@ class OpencogAgent: |
| 306 | 306 | ] |
| 307 | 307 | return "\n".join(ss) |
| 308 | 308 | |
| 309 | | def insert_to_percepta_record(self, timed_atom: Atom, i: int) -> None: |
| 309 | def insert_to_percepta_record(self, timed_atom: Atom, i: int = -1) -> None: |
| 310 | 310 | """Insert a timestamped atom into self.percepta_record. |
| 311 | 311 | |
| 312 | 312 | The percepta_record is a list of sets of timestamped percepta. |
| … | … | @@ -314,8 +314,14 @@ class OpencogAgent: |
| 314 | 314 | list is a set of percepta at the timestamp corresponding to |
| 315 | 315 | its index. |
| 316 | 316 | |
| 317 | If it's index i is not provided (or is negative), then it is |
| 318 | extracted from the timestamp. |
| 319 | |
| 317 | 320 | """ |
| 318 | 321 | |
| 322 | if i < 0: |
| 323 | i = to_int(get_time(timed_atom)) |
| 324 | |
| 319 | 325 | while len(self.percepta_record) <= i: |
| 320 | 326 | self.percepta_record.append(set()) |
| 321 | 327 | self.percepta_record[i].add(timed_atom) |
| … | … | @@ -1680,12 +1686,13 @@ class OpencogAgent: |
| 1680 | 1686 | |
| 1681 | 1687 | success = load_atomspace(self.percepta_atomspace, filepath, overwrite) |
| 1682 | 1688 | if success: |
| 1683 | | pas_roots = atomspace_roots(self.percepta_atomspace) |
| 1684 | 1689 | if overwrite: |
| 1685 | 1690 | self.percepta_record.clear() |
| 1686 | | print("TODO") |
| 1687 | | # NEXT: take care of filling the percepta record |
| 1688 | | # NEXT: update the cycle count as well |
| 1691 | pas_roots = atomspace_roots(self.percepta_atomspace) |
| 1692 | for mbr in pas_roots: |
| 1693 | self.insert_to_percepta_record(mbr.out[0]) |
| 1694 | new_count = len(self.percepta_record) |
| 1695 | self.cycle_count = new_count - 1 if 0 < new_count else 0 |
| 1689 | 1696 | return success |
| 1690 | 1697 | |
| 1691 | 1698 | def save_cogscms_atomspace(self, filepath: str, overwrite: bool = True) -> bool: |