Пример #1
0
def find_unique_tags(train_data_tags, null_label=False):

    unique_tags = Tags()

    for tags in train_data_tags:
        for tag, label in unfreeze_dict(tags).items():
            if not unique_tags.tagExists(tag):
                unique_tags.addTag(tag)

            curTag = unique_tags.getTagbyName(tag)

            if not curTag.labelExists(label):
                curTag.addLabel(label)

    # Add null labels to unseen tags in each tag set
    if null_label:
        for tag in unique_tags:
            tag.addLabel("NULL")

    return unique_tags