def validate_fields(fields):
  """Checks the validity of fields extracted from a <PAGE> element.

  Args:
    fields: A dictionary of fields extracted from a <PAGE> element.

  Returns:
    True if fields correspond to a valid article or redirect entry.
  """
  # If the namespace is not 0, then we are looking at something like an image
  # or a template, and do not want to further process it.
  if fields.get("ns") != "0":
    return False
  # We also want to check that the page has a title and text (if there is no
  # text then we are looking at some kind of upload).
  if not ("title" in fields and "text" in fields):
    return False
  return True
Checks the validity of fields extracted from a <PAGE> element.

  Args:
    fields: A dictionary of fields extracted from a <PAGE> element.

  Returns:
    True if fields correspond to a valid article or redirect entry.
  
language/fruit/wiki_utils.py