def load_global_list(name):
  path = "help/"
  if not os.path.isfile(path + name):
    print "ERROR: File \"%s\" not found" % name
    exit(1)
  dial = []
  dial = load_file(path + name)
  dial.sort()
  return dial
Beispiel #2
0
    new_geoname = GeoName(
        geonameid, name, alternatenames, latitude,
        longitude, class_code, feature_code, country, 
        population, elevation, wikipedia_url, entity_type)

    geonames_part.append(new_geoname)
  return geonames_part

def split_list(alist, wanted_parts=1):
  length = len(alist)
  return [ alist[i*length // wanted_parts: (i+1)*length // wanted_parts] 
    for i in range(wanted_parts) ]

if  __name__ == "__main__":
  load_alternative_names()
  global_country_codes = load_file(global_file_country_codes)
  global_country_codes.sort()

  subcountry_code = load_file(global_file_admin1_codes_ascii)
  subcountry_code.sort()

  load_links()
  global_links.sort()

  global_wikipedia_statistic = load_file(global_file_wikipedia_statistics)
  global_wikipedia_statistic.sort()

  # argument parsing
  parser = argparse.ArgumentParser()
  parser.add_argument('-l', '--list', action='store_true', default=False,
                      dest='list', help='Print list for an automaton.')
  for d in _data:
    if d.name not in d.alias:
      if d.name.strip() != "":
        print str(d.name) + "\t" + d.freebase_id
    for a in d.alias:
      if a.strip() != "":
        print str(a) + "\t" + d.freebase_id

if __name__ == "__main__": 
  # argument parsing
  parser = argparse.ArgumentParser()
  parser.add_argument('-l', '--list', action='store_true', default=False, dest='list', help='Print list for an automaton.')
  parser.add_argument('-b', '--knowledge-base', action='store_true', default=False, dest='knowledge_base', help='Print knowledge base.')
  parser.add_argument('-t', '--data-type', default=False, dest='data_type', type=str, help='Select data type to convert.', nargs=1)
  parser.add_argument('-i', '--input-file', default=False, dest='input_file', type=str, help='Input file.', nargs=1)
  args = parser.parse_args()

  global_unwanted_ids = load_file("/mnt/minerva1/nlp/projects/decipher_freebase/crawler/help/unwanted_ids")
  global_nationality_country = load_file("/mnt/minerva1/nlp/projects/decipher_freebase/crawler/help/nationality_country")
  global_nationality_country.sort()

  if args.data_type:
    data = load_data(sys.stdin, args.data_type[0])
    add_alternative_by_wiki(data)
    remove_redirections(data)
  if args.knowledge_base:
    print_knowledge_base(data)
  if args.list:
    print_list(data)