-
-
Save utkarshkukreti/2630a3332d8313c192811d91c9e17313 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import change_manager | |
import wordnet | |
import wordnet_yaml | |
def normalize(text): | |
return text.strip().replace(" ", " ").replace("( ", "(").replace(" )", ")") | |
def main(): | |
wn = change_manager.parse_wordnet("wn.xml") | |
for synset in wn.synsets: | |
synset.definitions = [ | |
wordnet.Definition(normalize(d.text)) | |
for d in synset.definitions | |
if d.text.strip() | |
] | |
if synset.ili_definition: | |
synset.ili_definition = wordnet.Definition( | |
normalize(synset.ili_definition.text) | |
) | |
for example in synset.examples: | |
example.text = normalize(example.text) | |
synset.examples = [ | |
example for example in synset.examples if example.text.strip() | |
] | |
change_manager.save_all_xml(wn) | |
wordnet_yaml.save(wn) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment