MCPcopy Create free account
hub / github.com/google-research/language / validate_fields

Function validate_fields

language/fruit/wiki_utils.py:33–50  ·  view source on GitHub ↗

Checks the validity of fields extracted from a element. Args: fields: A dictionary of fields extracted from a element. Returns: True if fields correspond to a valid article or redirect entry.

(fields)

Source from the content-addressed store, hash-verified

31
32
33def validate_fields(fields):
34 """Checks the validity of fields extracted from a <PAGE> element.
35
36 Args:
37 fields: A dictionary of fields extracted from a <PAGE> element.
38
39 Returns:
40 True if fields correspond to a valid article or redirect entry.
41 """
42 # If the namespace is not 0, then we are looking at something like an image
43 # or a template, and do not want to further process it.
44 if fields.get("ns") != "0":
45 return False
46 # We also want to check that the page has a title and text (if there is no
47 # text then we are looking at some kind of upload).
48 if not ("title" in fields and "text" in fields):
49 return False
50 return True
51
52
53def generate_pages(xml_file):

Callers 1

generate_pagesFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…