Output Formats
List Output🔗
The default output of WordHoard is a Python list. This output is set using the variable output_format, which by default is preset to output_format='list'. All output is sorted by length.
from wordhoard import Synonyms
word = 'mother'
results = Synonyms(search_string=word, output_format='list').find_synonyms()
print(results)
['ma', 'mum', 'mom', 'dam', 'mama', 'mamma', 'mummy', 'momma', 'mommy',
'mater', 'para i', 'parent', 'old lady', 'supermom', 'puerpera', 'primipara',
'old woman', 'quadripara', 'quintipara', 'birth mother', 'foster mother',
'female parent', 'mother-in-law', 'surrogate mother', 'biological mother']
Dictionary Output🔗
The data elements can also be outputted in a Python dictionary. This is accomplished by changing the output_format variable, to output_format='dictionary'.
from wordhoard import Synonyms
word = 'mother'
results = Synonyms(search_string=word, output_format='dictionary').find_synonyms()
print(results)
{'mother': {'part_of_speech': 'noun', 'synonyms': ['ma', 'dam', 'mum', 'mom',
'mama', 'mater', 'mummy', 'mamma', 'mommy', 'momma', 'parent', 'para i',
'puerpera', 'old lady', 'supermom', 'old woman', 'primipara', 'quadripara',
'quintipara', 'birth mother', 'foster mother', 'mother-in-law', 'female parent',
'surrogate mother', 'biological mother']}}
JSON Output🔗
The data elements can also be outputted in JSON. This is accomplished by changing the output_format variable, to output_format='json'.
from wordhoard import Synonyms
word = 'mother'
results = Synonyms(search_string=word, output_format='json').find_synonyms()
print(results)
{
"mother": {
"part_of_speech": "noun",
"synonyms": [
"ma",
"mom",
"mum",
"dam",
"mama",
"mommy",
"mater",
"mummy",
"mamma",
"momma",
"parent",
"para i",
"puerpera",
"supermom",
"old lady",
"primipara",
"old woman",
"quintipara",
"quadripara",
"birth mother",
"female parent",
"mother-in-law",
"foster mother",
"surrogate mother",
"biological mother"
]
}
}
Last update:
March 21, 2023