MCPcopy Create free account
hub / github.com/pytorch/tutorials / unicodeToAscii

Function unicodeToAscii

intermediate_source/char_rnn_classification_tutorial.py:92–97  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

90
91# Turn a Unicode string to plain ASCII, thanks to https://stackoverflow.com/a/518232/2809427
92def unicodeToAscii(s):
93 return ''.join(
94 c for c in unicodedata.normalize('NFD', s)
95 if unicodedata.category(c) != 'Mn'
96 and c in allowed_characters
97 )
98
99#########################
100# Here's an example of converting a unicode alphabet name to plain ASCII. This simplifies the input layer

Calls

no outgoing calls

Tested by

no test coverage detected