code: def filter_example(elem, text, *args, **kwargs):
      """Example function for filtering arbitrary documents from wikipedia dump.
  
  
      The custom filter function is called _before_ tokenisation and should work on
      the raw text and/or XML element information.
  
      The filter function gets the entire context of the XML element passed into it,
      but you can of course choose not the use some or all parts of the context. Please
      refer to :func:`gensim.corpora.wikicorpus.extract_pages` for the exact details
      of the page context.
  
      Parameters
      ----------
      elem : etree.Element
          XML etree element
      text : str
          The text of the XML node
      namespace : str
          XML namespace of the XML element
      title : str
         Page title
      page_tag : str
          XPath expression for page.
      text_path : str
          XPath expression for text.
      title_path : str
          XPath expression for title.
      ns_path : str
          XPath expression for namespace.
      pageid_path : str
          XPath expression for page id.
  
      Example
      -------
      .. sourcecode:: pycon
  
          >>> import gensim.corpora
          >>> filter_func = gensim.corpora.wikicorpus.filter_example
          >>> dewiki = gensim.corpora.WikiCorpus(
          ...     './dewiki-20180520-pages-articles-multistream.xml.bz2',
          ...     filter_articles=filter_func)
  
      """
      # Filter German wikipedia dump for articles that are marked either as
      # Lesenswert (featured) or Exzellent (excellent) by wikipedia editors.
      # *********************
      # regex is in the function call so that we do not pollute the wikicorpus
      # namespace do not do this in production as this function is called for
      # every element in the wiki dump
      _regex_de_excellent = re.compile(
          r".*\{\{(Exzellent.*?)\}\}[\s]*", flags=re.DOTALL
      )
      _regex_de_featured = re.compile(
          r".*\{\{(Lesenswert.*?)\}\}[\s]*", flags=re.DOTALL
      )
  
      if text is None:
          return False
      if _regex_de_excellent.match(text) or _regex_de_featured.match(
          text
      ):
          return True
      else:
          return False
  
imports: import bz2
  import logging
  import multiprocessing
  import re
  import signal
  from pickle import PicklingError
  from xml.etree.ElementTree import iterparse
  from gensim import utils
  from gensim.corpora.dictionary import Dictionary
  from gensim.corpora.textcorpus import TextCorpus
label_desc: Use image node_id 1 for calling a global function with example usage: filter_example(elem, text) and returns: False, True, False