vidwan commited on
Commit
6e1b8a0
·
verified ·
1 Parent(s): a686777

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -46,32 +46,33 @@ def parse_word_info(word_info):
46
  meanings = word_info.get("meanings", [])
47
  for meaning in meanings:
48
  part_of_speech = meaning.get("partOfSpeech", "")
49
- ret_str += f"Part of Speech: {part_of_speech}\n"
50
- print(f"Part of Speech: {part_of_speech}\n")
51
 
52
  # Definitions
53
  definitions = meaning.get("definitions", [])
54
  for i, definition in enumerate(definitions, 1):
55
- ret_str +=f"\nDefinition {i}: {definition.get('definition', '')}"
56
- print(f"\nDefinition {i}: {definition.get('definition', '')}")
57
 
58
  # Example sentences
59
  example = definition.get("example", "")
60
  if example:
61
- ret_str += f"Example: {example}"
62
- print(f"Example: {example}")
63
 
64
  # Synonyms
65
  synonyms = definition.get("synonyms", [])
66
  if synonyms:
67
- ret_str += f"Synonyms: {', '.join(synonyms)}"
68
- print(f"Synonyms: {', '.join(synonyms)}")
69
 
70
  # Antonyms
71
  antonyms = definition.get("antonyms", [])
72
  if antonyms:
73
- ret_str += f"Antonyms: {', '.join(antonyms)}"
74
- print(f"Antonyms: {', '.join(antonyms)}")
 
75
  ret_str = "The complete meaning of the {word} is -" + ret_str
76
 
77
  return ret_str
 
46
  meanings = word_info.get("meanings", [])
47
  for meaning in meanings:
48
  part_of_speech = meaning.get("partOfSpeech", "")
49
+ ret_str += f"It is a:{part_of_speech}\n"
50
+ print(f"It is a:{part_of_speech}\n")
51
 
52
  # Definitions
53
  definitions = meaning.get("definitions", [])
54
  for i, definition in enumerate(definitions, 1):
55
+ ret_str +=f"{i}: {definition.get('definition', '')}"
56
+ print(f"{i}: {definition.get('definition', '')}")
57
 
58
  # Example sentences
59
  example = definition.get("example", "")
60
  if example:
61
+ ret_str += f"Example: {example}\n"
62
+ print(f"Example: {example}\n")
63
 
64
  # Synonyms
65
  synonyms = definition.get("synonyms", [])
66
  if synonyms:
67
+ ret_str += f"Synonyms: {', '.join(synonyms)}\n"
68
+ print(f"Synonyms: {', '.join(synonyms)}\n")
69
 
70
  # Antonyms
71
  antonyms = definition.get("antonyms", [])
72
  if antonyms:
73
+ ret_str += f"Antonyms: {', '.join(antonyms)}\n"
74
+ print(f"Antonyms: {', '.join(antonyms)}\n")
75
+ ret_str += "--------\n"
76
  ret_str = "The complete meaning of the {word} is -" + ret_str
77
 
78
  return ret_str