class_docstr: The MongoDatabaseAdapter is an interface that allows
  ChatterBot to store statements in a MongoDB database.
  
  :keyword database_uri: The URI of a remote instance of MongoDB.
                         This can be any valid
                         `MongoDB connection string <https://docs.mongodb.com/manual/reference/connection-string/>`_
  :type database_uri: str
  
  .. code-block:: python
  
     database_uri='mongodb://example.com:8100/'
class_docstr_tok: ["The","MongoDatabaseAdapter","is","an","interface","that","allows","ChatterBot","to","store","statements","in","a","MongoDB","database",".",":","keyword","database_uri",":","The","URI","of","a","remote","instance","of","MongoDB",".","This","can","be","any","valid","`","MongoDB","connection","string","<","https",":","\/\/docs.mongodb.com\/manual\/reference\/connection-string\/",">","`","_",":","type","database_uri",":","str","..","code-block",":",":","python","database_uri='mongodb",":","\/\/example.com:8100\/","'"]
docstr: Returns a list of statements in the database
  that match the parameters specified.
docstr_tok: ["Returns","a","list","of","statements","in","the","database","that","match","the","parameters","specified","."]
code: def filter(self, **kwargs):
      """
      Returns a list of statements in the database
      that match the parameters specified.
      """
      import pymongo
  
      page_size = kwargs.pop("page_size", 1000)
      order_by = kwargs.pop("order_by", None)
      tags = kwargs.pop("tags", [])
      exclude_text = kwargs.pop("exclude_text", None)
      exclude_text_words = kwargs.pop("exclude_text_words", [])
      persona_not_startswith = kwargs.pop(
          "persona_not_startswith", None
      )
      search_text_contains = kwargs.pop("search_text_contains", None)
  
      if tags:
          kwargs["tags"] = {"$in": tags}
  
      if exclude_text:
          if "text" not in kwargs:
              kwargs["text"] = {}
          elif "text" in kwargs and isinstance(kwargs["text"], str):
              text = kwargs.pop("text")
              kwargs["text"] = {"$eq": text}
          kwargs["text"]["$nin"] = exclude_text
  
      if exclude_text_words:
          if "text" not in kwargs:
              kwargs["text"] = {}
          elif "text" in kwargs and isinstance(kwargs["text"], str):
              text = kwargs.pop("text")
              kwargs["text"] = {"$eq": text}
          exclude_word_regex = "|".join(
              [".*{}.*".format(word) for word in exclude_text_words]
          )
          kwargs["text"]["$not"] = re.compile(exclude_word_regex)
  
      if persona_not_startswith:
          if "persona" not in kwargs:
              kwargs["persona"] = {}
          elif "persona" in kwargs and isinstance(
              kwargs["persona"], str
          ):
              persona = kwargs.pop("persona")
              kwargs["persona"] = {"$eq": persona}
          kwargs["persona"]["$not"] = re.compile("^bot:*")
  
      if search_text_contains:
          or_regex = "|".join(
              [
                  "{}".format(re.escape(word))
                  for word in search_text_contains.split(" ")
              ]
          )
          kwargs["search_text"] = re.compile(or_regex)
  
      mongo_ordering = []
  
      if order_by:
          # Sort so that newer datetimes appear first
          if "created_at" in order_by:
              order_by.remove("created_at")
              mongo_ordering.append(
                  (
                      "created_at",
                      pymongo.DESCENDING,
                  )
              )
  
          for order in order_by:
              mongo_ordering.append((order, pymongo.ASCENDING))
  
      total_statements = self.statements.find(kwargs).count()
  
      for start_index in range(0, total_statements, page_size):
          if mongo_ordering:
              for match in (
                  self.statements.find(kwargs)
                  .sort(mongo_ordering)
                  .skip(start_index)
                  .limit(page_size)
              ):
                  yield self.mongo_to_object(match)
          else:
              for match in (
                  self.statements.find(kwargs)
                  .skip(start_index)
                  .limit(page_size)
              ):
                  yield self.mongo_to_object(match)
  
file_path: ChatterBot/chatterbot/storage/mongodb.py
imports: import re
  from chatterbot.storage import StorageAdapter
label_desc: Use image node_id 5 for calling the MongoDatabaseAdapter obj's underlying member method code with example usage: obj.filter() without return types