thak123 commited on
Commit
6bc5afd
·
1 Parent(s): 49c7bae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -16,7 +16,7 @@ nltk.download("omw-1.4")
16
  def get_english_synset_id(croatian_word):
17
  # Convert the Croatian word to English WordNet synset IDs
18
  synsets = wordnet.synsets(croatian_word, lang="hrv")
19
-
20
  # Check if any synsets were found
21
  if synsets:
22
  # Take the first synset (you can modify this to handle multiple synsets if needed)
@@ -61,8 +61,10 @@ def get_definition_and_image(word):
61
  # Print the first 10 image URLs
62
  for i, url in enumerate(image_urls[:10], start=1):
63
  print(f"Image {i}: {url}")
 
64
  else:
65
  print(f"Failed to retrieve image URLs. Status code: {response.status_code}")
 
66
 
67
  # Function to randomly sample a noun or verb
68
  def sample_word_and_display_info():
@@ -74,7 +76,7 @@ def sample_word_and_display_info():
74
 
75
  # Get a random word of the chosen part of speech from the Croatian WordNet
76
  word = random.choice(wordnet.all_lemma_names(pos, lang="hrv"))
77
-
78
  # Get the definition and image (change the function for your source)
79
  definition, image_url = get_definition_and_image(word)
80
 
 
16
  def get_english_synset_id(croatian_word):
17
  # Convert the Croatian word to English WordNet synset IDs
18
  synsets = wordnet.synsets(croatian_word, lang="hrv")
19
+ print(f"synsets: {synsets}")
20
  # Check if any synsets were found
21
  if synsets:
22
  # Take the first synset (you can modify this to handle multiple synsets if needed)
 
61
  # Print the first 10 image URLs
62
  for i, url in enumerate(image_urls[:10], start=1):
63
  print(f"Image {i}: {url}")
64
+ return word, image_urls[0]
65
  else:
66
  print(f"Failed to retrieve image URLs. Status code: {response.status_code}")
67
+ return None, None
68
 
69
  # Function to randomly sample a noun or verb
70
  def sample_word_and_display_info():
 
76
 
77
  # Get a random word of the chosen part of speech from the Croatian WordNet
78
  word = random.choice(wordnet.all_lemma_names(pos, lang="hrv"))
79
+ print(f"Word: {word}")
80
  # Get the definition and image (change the function for your source)
81
  definition, image_url = get_definition_and_image(word)
82