Question

In: Computer Science

write a python program that reads a sentence and identifies a word from an existing glossary...

write a python program that reads a sentence and identifies a word from an existing glossary and states the meaning of the word

Solutions

Expert Solution

Here is the code in python:

import json 
from difflib import get_close_matches 
  
# Loading data from json file 
data = json.load(open("dictionary.json")) 
  
def translate(w): 
    # convert it to lower case 
    w = w.lower() 
  
    if w in data:
        print("\n",w,":",data[w])
        
  
# Driver code 
word = input("Enter the sentence: ")
word = word.split()
for i in word:
    output = translate(i) 
  

JSON file named as dictionary.json

{

"python": "Python is an interpreted, high-level and general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python's design philosophy emphasizes code readability with its notable use of significant whitespace.", 
"human": "Humans (Homo sapiens) are highly intelligent primates that have become the dominant species on Earth", 
"city":"A city is a large human settlement. It can be defined as a permanent and densely settled place with administratively defined boundaries whose members work primarily on non-agricultural tasks." 
}


Here in the json file for demo purpose i took three words and its meaning. please update it according to your requirement or you can also download premade json english dictionarys.

Output:


Related Solutions

python: Write a program that turns a sentence into camel case. The first word is lowercase,...
python: Write a program that turns a sentence into camel case. The first word is lowercase, the rest of the words have their initial letter capitalized, and all of the words are joined together. For example, with the input "fOnt proCESSOR and ParsER", your program will output "fontProcessorAndParser". Optional: can you do this with a list comprehension? Optional extra question: print a warning message if the input will not produce a valid variable name. You don't need to be exhaustive...
Write a Python program that reads a file, input by the user, containing one word/token per...
Write a Python program that reads a file, input by the user, containing one word/token per line with an empty line between sentences. The program prints out the longest word found in the file along with its length.
In PYTHON: Write a function that receives a sentence and returns the last word of that...
In PYTHON: Write a function that receives a sentence and returns the last word of that sentence. You may assume that there is exactly one space between every two words, and that there are no other spaces at the sentence. To make the problem simpler, you may assume that the sentence contains no hyphens, and you may return the word together with punctuation at its end.
Python program: Write a program that reads a text file named test_scores.txt to read the name...
Python program: Write a program that reads a text file named test_scores.txt to read the name of the student and his/her scores for 3 tests. The program should display class average for first test (average of scores of test 1) and average (average of 3 tests) for each student. Expected Output: ['John', '25', '26', '27'] ['Michael', '24', '28', '29'] ['Adelle', '23', '24', '20'] [['John', '25', '26', '27'], ['Michael', '24', '28', '29'], ['Adelle', '23', '24', '20']] Class average for test 1...
Write a python program to sum the prime numbers existing in an array . For instance...
Write a python program to sum the prime numbers existing in an array . For instance , if A = [4, 7, 12, 3, 9] the output should be 10
Write a Python program that reads in two times, an earlier time and a later time,...
Write a Python program that reads in two times, an earlier time and a later time, and prints the difference between the two times in minutes as well as in hours/minutes. The format of the time is HH:MMAM or H:MMAM or HH:MMPM or H:MMPM. Also the AM or PM may be in lower case. A sample run of the program is shown below: $ python3 Time.py Enter Earlier Time: 9:36aM Enter Later Time: 6:22PM Number of minutes between 9:36aM and...
Design and write a python program that reads a file of text and stores each unique...
Design and write a python program that reads a file of text and stores each unique word in some node of binary search tree while maintaining a count of the number appearance of that word. The word is stored only one time; if it appears more than once, the count is increased. The program then prints out 1) the number of distinct words stored un the tree, Function name: nword 2) the longest word in the input, function name: longest...
Using Python. Write a program that reads a sequence (unknown number of inputs) of integer inputs...
Using Python. Write a program that reads a sequence (unknown number of inputs) of integer inputs and prints the number of even and odd inputs in the sequence. please explain. Thanks
Write a class to accept a sentence from the user and prints a new word in...
Write a class to accept a sentence from the user and prints a new word in a terminal formed out of the third letter of each word. For example, the input line “Mangoes are delivered after midnight” would produce “neltd”. Program Style : Basic Java Programming
Python 8.17 LAB: Strings of a Frequency Write a program that reads whitespace delimited strings (words)...
Python 8.17 LAB: Strings of a Frequency Write a program that reads whitespace delimited strings (words) and an integer (freq). Then, the program outputs the strings from words that have a frequency equal to freq in a case insensitive manner. Your specific task is to write a function wordsOfFreqency(words, freq), which will return a list of strings (in the order in which they appear in the original list) that have a frequency same as the function parameter freq. The parameter...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT