I guess that
def create_transition_matrix(alpha, tag_counts, transition_counts):
'''
Input:
alpha: number used for smoothing
tag_counts: a dictionary mapping each tag to its respective count
transition_counts: a dictionary where the keys are (prev_tag, tag) and the values are the counts
Output:
A: matrix of dimension (num_tags,num_tags)
'''
# Get a sorted list of unique POS tags
all_tags = sorted(tag_counts.keys(), key=lambda x: str(x))
If i don’t pass key=lambda x: str(x)) to sorted function, I got an error since almost all tag_counts keys are string but last few keys are integer.
I got an error without it, basically making sure that each key is string. I don’t know if others encountere a problem. I just want to share it.
Thanks,