From 53d1efb197d99c637e766afc857c74dede37624b Mon Sep 17 00:00:00 2001 From: dustyposa Date: Fri, 11 Aug 2023 17:54:20 +0800 Subject: [PATCH 1/2] delete the texts --- paperqa/docs.py | 2 ++ tests/test_paperqa.py | 1 + 2 files changed, 3 insertions(+) diff --git a/paperqa/docs.py b/paperqa/docs.py index f1bf36b8a..780b0facd 100644 --- a/paperqa/docs.py +++ b/paperqa/docs.py @@ -281,6 +281,8 @@ def delete( dockey = doc.dockey del self.docs[dockey] self.deleted_dockeys.add(dockey) + self.texts = list(filter(lambda x: x.doc.dockey != dockey, self.texts)) + async def adoc_match( self, query: str, k: int = 25, get_callbacks: CallbackFactory = lambda x: None diff --git a/tests/test_paperqa.py b/tests/test_paperqa.py index 8496d513d..9bca80409 100644 --- a/tests/test_paperqa.py +++ b/tests/test_paperqa.py @@ -558,6 +558,7 @@ def test_dockey_delete(): docs.delete(dockey="test") assert len(docs.docs) == 1 + assert len(list(filter(lambda x: x.doc.dockey == "test", docs.texts))) == 0 answer = Answer(question="What country was Bates born in?") answer = docs.get_evidence(answer, marginal_relevance=False) keys = set([c.text.doc.dockey for c in answer.contexts]) From 0fe94f70199b2955f99a294808da1cc0aa75b74b Mon Sep 17 00:00:00 2001 From: dustyposa Date: Mon, 21 Aug 2023 18:16:08 +0800 Subject: [PATCH 2/2] :wrench: remove empty line --- paperqa/docs.py | 1 - 1 file changed, 1 deletion(-) diff --git a/paperqa/docs.py b/paperqa/docs.py index 780b0facd..300984b45 100644 --- a/paperqa/docs.py +++ b/paperqa/docs.py @@ -283,7 +283,6 @@ def delete( self.deleted_dockeys.add(dockey) self.texts = list(filter(lambda x: x.doc.dockey != dockey, self.texts)) - async def adoc_match( self, query: str, k: int = 25, get_callbacks: CallbackFactory = lambda x: None ) -> Set[DocKey]: