擅长:python、mysql、java
<blockquote>
<p>I want to generalize it for multiple
tokens</p>
</blockquote>
<pre><code>def boolean_search_and_multi(self, text):
and_tokens = self.tokenize(text)
results = set(self._inverted_index[and_tokens[0]])
for tok in and_tokens[1:]:
results.intersection_update(self._inverted_index[tok])
return list(results)
</code></pre>