MCPcopy
hub / github.com/zjy-ucas/ChineseNER / char_mapping

Function char_mapping

loader.py:65–77  ·  view source on GitHub ↗

Create a dictionary and a mapping of words, sorted by frequency.

(sentences, lower)

Source from the content-addressed store, hash-verified

63
64
65def char_mapping(sentences, lower):
66 """
67 Create a dictionary and a mapping of words, sorted by frequency.
68 """
69 chars = [[x[0].lower() if lower else x[0] for x in s] for s in sentences]
70 dico = create_dico(chars)
71 dico["<PAD>"] = 10000001
72 dico['<UNK>'] = 10000000
73 char_to_id, id_to_char = create_mapping(dico)
74 print("Found %i unique words (%i in total)" % (
75 len(dico), sum(len(x) for x in chars)
76 ))
77 return dico, char_to_id, id_to_char
78
79
80def tag_mapping(sentences):

Callers 1

trainFunction · 0.90

Calls 2

create_dicoFunction · 0.90
create_mappingFunction · 0.90

Tested by

no test coverage detected