def _collect_script_to_punct(files):
  """Builds script to punct from provided cldr files.  Builds 'LGC'
  data from component scripts.  Adds ASCII single and double quotes if
  corresponding quotes are in the punct."""

  script_to_punct = collections.defaultdict(set)
  curly_quotes_to_standard = [
      (frozenset([unichr(0x2018), unichr(0x2019)]), frozenset(['\''])),
      (frozenset([unichr(0x201C), unichr(0x201D)]), frozenset(['"'])),
  ]
  for f in files:
    tree = ET.parse(f)
    punct = _collect_punct_data(tree)
    if punct:
      filename = path.splitext(path.basename(f))[0]
      script = cldr_data.get_likely_script(filename)
      if script == 'Zzzz':
        if filename != 'root':
          print >> sys.stderr, 'no script for %s' % filename
      else:
        script_to_punct[script] |= punct

  script_to_punct['LGC'] = set(
      script_to_punct['Latn'] |
      script_to_punct['Grek'] |
      script_to_punct['Cyrl'])

  for script in script_to_punct:
    punct = script_to_punct[script]
    for curly, standard in curly_quotes_to_standard:
      if curly & punct:
        punct.update(standard)

  return script_to_punct
dataset/ETHPy150Open googlei18n/nototools/nototools/collect_cldr_punct.py/_collect_script_to_punct/original