MCPcopy Create free account
hub / github.com/csxmli2016/MARCONetPlusPlus / get_alphabet

Function get_alphabet

utils/utils_transocr.py:97–112  ·  view source on GitHub ↗
(alpha_path)

Source from the content-addressed store, hash-verified

95
96
97def get_alphabet(alpha_path):
98 global alp2num_character, alphabet_character
99 if alp2num_character == None:
100 alphabet_character_file = open(alpha_path)
101 alphabet_character = list(alphabet_character_file.read().strip())
102 alphabet_character_raw = ['START', '\xad']
103 for item in alphabet_character:
104 alphabet_character_raw.append(item)
105 alphabet_character_raw.append('END')
106 alphabet_character = alphabet_character_raw
107 alp2num = {}
108 for index, char in enumerate(alphabet_character):
109 alp2num[char] = index
110 alp2num_character = alp2num
111
112 return alphabet_character
113
114def tensor2str(tensor, alpha_path):
115 alphabet = get_alphabet(alpha_path)

Callers 2

TextEnhancement.pyFile · 0.90
tensor2strFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected