示例#1
0
def output_categories(categories, remaining):
    f = open(OUTPUT_CATEGORY_FILE, "w")
    f.write("category number:" + str(len(categories)) + " , remaining locations:" + str(remaining) + "\n")
    for idx, a_category in enumerate(categories):
        f.write("Category:" + str(idx + 1) + " , #= " + str(len(a_category)) + ">>>\n")
        clocation.output_location_part_list([x.clocation for x in a_category], f)
    f.close()
示例#2
0
def output_categories(categories, remaining):
    f = open(OUTPUT_CATEGORY_FILE, "w")
    f.write("category number:" + str(len(categories)) +
            " , remaining locations:" + str(remaining) + "\n")
    for idx, a_category in enumerate(categories):
        f.write("Category:" + str(idx + 1) + " , #= " + str(len(a_category)) +
                ">>>\n")
        clocation.output_location_part_list([x.clocation for x in a_category],
                                            f)
    f.close()
示例#3
0
def output_location_cluster(locations, output_file):
    sorted_locations = sorted(locations.values(), key=lambda x:x.cluster1)
    groups = {x:list(y) for x, y in itertools.groupby(sorted_locations, lambda x:x.cluster1)}

    clocation.output_location_list([], output_file)
    f = open(output_file, "a")
    # for each cluster
    for c, a_group in groups.items():
        f.write("Cluster:" + str(c) + "\t#:" + str(len(a_group)) + "\n")
        clocation.output_location_part_list(a_group, f)
    f.close()
示例#4
0
def output_location_cluster(locations, output_file):
    sorted_locations = sorted(locations.values(), key=lambda x: x.cluster1)
    groups = {
        x: list(y)
        for x, y in itertools.groupby(sorted_locations, lambda x: x.cluster1)
    }

    clocation.output_location_list([], output_file)
    f = open(output_file, "a")
    # for each cluster
    for c, a_group in groups.items():
        f.write("Cluster:" + str(c) + "\t#:" + str(len(a_group)) + "\n")
        clocation.output_location_part_list(a_group, f)
    f.close()