コード例 #1
0
def map_wordnet_EVD():
  print "loading EVD"
  dict_EVD = EVDParser.readEVDFile()
  print "loading WN"
  dict_wn = WordnetProcessForEVD.read_nouns()

  for key, values in dict_wn.items():
    key_lemmas = key.split("=")[1]
    key_lemmas = key_lemmas.split("-")
    key = key.split("=")[0]
    key_definition = key.split("-")[1]
    key = key.split("-")[0]

    test_flag = 0
    for lemma in key_lemmas:
      if lemma[:1] == "b" :
        test_flag = 1
    if test_flag == 0:
      continue

    print "map_wordnet_EVD " + key

    vi_means = get_EVD_means(key, key_lemmas, values, dict_EVD)
    ox_means = get_Ox_means(key, key_lemmas)

    means = get_best_mean(vi_means, ox_means, 2)

################################################################################
# get greatest duplicated mean
#    if len(values) == 1:
#      means = vi_means
#      item_count = [(item,count) for item, count in collections.Counter(vi_means).items() if count > 1]
#      if len(item_count) > 0:
#        means = [max(item_count,key = itemgetter(1))[0]]
#
#        items_2 = [item for item, count in collections.Counter(vi_means).items() if count > 2]
#        for item in items_2:
#          means.append(item)
#        means = list(set(means))
#
#    else:
#      item_count = [(item,count) for item, count in collections.Counter(vi_means).items() if count > 1]
#      if len(item_count) == 0:
#        continue
#      means = [max(item_count,key = itemgetter(1))[0]]
#
#      items_2 = [item for item, count in collections.Counter(vi_means).items() if count > 2]
#      for item in items_2:
#        means.append(item)
#      means = list(set(means))
################################################################################

    if len(means) > 0:
      means = [means[0]]
      means.insert(0,key + "-" + key_definition)
      filename = "Results/EVD/wn_evd_b_0_1.csv"
      FileProcess.append_result_to_excel_file(filename, means)
コード例 #2
0
def append_params_and_result_to_file(values):
  FileProcess.append_result_to_excel_file(result_file_name,values)