Extract entities from ``text``; returns the number of mentions recorded.
(self, text: str, now: float = 0.0)
| 56 | ent.last_seen = now |
| 57 | |
| 58 | def record_from_text(self, text: str, now: float = 0.0) -> int: |
| 59 | """Extract entities from ``text``; returns the number of mentions recorded.""" |
| 60 | if not text: |
| 61 | return 0 |
| 62 | n = 0 |
| 63 | for m in _FILE_RE.finditer(text): |
| 64 | self.add(m.group(1), "file", now) |
| 65 | n += 1 |
| 66 | for m in _SYMBOL_RE.finditer(text): |
| 67 | self.add(m.group(1), "symbol", now) |
| 68 | n += 1 |
| 69 | for m in _URL_RE.finditer(text): |
| 70 | self.add(m.group(0), "url", now) |
| 71 | n += 1 |
| 72 | return n |
| 73 | |
| 74 | def stats(self) -> dict[str, int]: |
| 75 | by_type: dict[str, int] = {} |