Create a python program that would perform the given description below       Program Description:   T9 is a predictive text technology for mobile phones (specifically those that contain a 3×4 numeric keypad). It allows the user to press a numerical key and form a set of keys. With this set of keys, T9 figures out exactly the word the user meant to type based on the list of valid words also called a dictionary. Here is exactly how T9 works: If the user wants to type a message to someone using a cellphone pad, they will only use the digits 2 through 9. The table below provides the corresponding letters for each digit:     If you wanted to type the message hello, you would just type 43556. Clearly, there are many alphabetic strings that correspond to this five-digit string, but of all of those, hello is the only word. It turns out that for most words, no other word will correspond to the same exact set of digits. This is how T9 works - it cross-references the digits pressed with a dictionary of words. Obviously, there are some instances where multiple words map to the same digits, such as "book" and "cool" which are both represented by "2665". In these cases, T9 selects the most frequently chosen word. Phones with advanced T9 adapt to the user's typical word choices. (This feature of T9 will not be covered in this activity).   Write a program that translates messages typed in T9 to their alphabetic format. In the case that more than one message is possible, your program should simply calculate the total number of possible messages. (Note: This value should only be determined based upon the total number of possible combinations of words   that could be formed and should not be restricted by the meaning of those words in any manner.) If no message is possible for the input T9 text, then your program should determine this as well.   INPUT: The first line of the input file will contain a single integer n (1 ~ n ~ 20), indicating the number of words in the dictionary. Each of the next n input lines will contain a single word from the dictionary. Each word will only consist of lowercase letters (length ~ 1) and there will be no duplicate words in the dictionary.   The next input line will contain a single integer, m, representing the number of messages to convert. Each of the next m lines will contain one message. A message will contain numeric strings (i.e., only digits 2 through 9) separated by spaces on a single line, with the first string starting in column 1 and each string is separated by a single space.   OUTPUT: For each input message, print a heading. Then, output one of the following three options:   If there is NO corresponding message, then print the following message out: not a valid text If there is exactly one possible message, then print out the corresponding message, all in lower case. If there is more than one possible message, then print a message of the following format: there are X possible messages; where X is the number of possible messages

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Create a python program that would perform the given description below

 

 

 

Program Description:

 

T9 is a predictive text technology for mobile phones (specifically those that contain a 3×4 numeric keypad). It allows the user to press a numerical key and form a set of keys. With this set of keys, T9 figures out exactly the word the user meant to type based on the list of valid words also called a dictionary. Here is exactly how T9 works: If the user wants to type a message to someone using a cellphone pad, they will only use the digits 2 through 9. The table below provides the corresponding letters for each digit:

 

 

If you wanted to type the message hello, you would just type 43556. Clearly, there are many alphabetic strings that correspond to this five-digit string, but of all of those, hello is the only word. It turns out that for most words, no other word will correspond to the same exact set of digits. This is how T9 works - it cross-references the digits pressed with a dictionary of words. Obviously, there are some instances where multiple words map to the same digits, such as "book" and "cool" which are both represented by "2665". In these cases, T9 selects the most frequently chosen word. Phones with advanced T9 adapt to the user's typical word choices. (This feature of T9 will not be covered in this activity).

 

Write a program that translates messages typed in T9 to their alphabetic format. In the case that more than one message is possible, your program should simply calculate the total number of possible messages. (Note: This value should only be determined based upon the total number of possible combinations of words

 

that could be formed and should not be restricted by the meaning of those words in any manner.) If no message is possible for the input T9 text, then your program should determine this as well.

 

INPUT: The first line of the input file will contain a single integer n (1 ~ n ~ 20), indicating the number of words in the dictionary. Each of the next n input lines will contain a single word from the dictionary. Each word will only consist of lowercase letters (length ~ 1) and there will be no duplicate words in the dictionary.

 

The next input line will contain a single integer, m, representing the number of messages to convert. Each of the next m lines will contain one message. A message will contain numeric strings (i.e., only digits 2 through 9) separated by spaces on a single line, with the first string starting in column 1 and each string is separated by a single space.

 

OUTPUT: For each input message, print a heading. Then, output one of the following three options:

 

If there is NO corresponding message, then print the following message out: not a valid text

If there is exactly one possible message, then print out the corresponding message, all in lower case.

If there is more than one possible message, then print a message of the following format: there are X possible messages; where X is the number of possible messages

TEST CASE:
SAMPLE INPUT:
11
No of words in the dictionary
hello
good
i
a
went
to
11 words
the
beach
cool
No of test cases
read
book
3
4 9368 86 843 23224
test cases to be tested
4 7323 2 2665 2665
8447 47 843 5278 8378 2273
SAMPLE OUTPUT:
3 outputs for 3 inputs
Message #1: i went to the beach
Message #2: there are 4 possible messages
Test each case and display
required output
Message #3: not a valid text
WORDS
T9
OUTPUT EXPLANATION:
hello
43556
good
4663
4
9368
86
843
23224
4
i
went
to
the
beach
a
went
9368
4
7323
2665
2665
to
86
i
read
a
col
Cool
the
843
book book
beach
23224
T read a cool cool
I read a cool book
I read a book cool
I read a book book
сool
2665
read
7323
book
2665
8447
47
843
5278
8378
2273
the
No message is form
Transcribed Image Text:TEST CASE: SAMPLE INPUT: 11 No of words in the dictionary hello good i a went to 11 words the beach cool No of test cases read book 3 4 9368 86 843 23224 test cases to be tested 4 7323 2 2665 2665 8447 47 843 5278 8378 2273 SAMPLE OUTPUT: 3 outputs for 3 inputs Message #1: i went to the beach Message #2: there are 4 possible messages Test each case and display required output Message #3: not a valid text WORDS T9 OUTPUT EXPLANATION: hello 43556 good 4663 4 9368 86 843 23224 4 i went to the beach a went 9368 4 7323 2665 2665 to 86 i read a col Cool the 843 book book beach 23224 T read a cool cool I read a cool book I read a book cool I read a book book сool 2665 read 7323 book 2665 8447 47 843 5278 8378 2273 the No message is form
Digit
2
Letters
a, b, c
d, e, f
g, h, i
j. k, I
m, n, o
p, q, r, s
t, u, v
3
4
5
7
8
9.
W, X, y, Z
Transcribed Image Text:Digit 2 Letters a, b, c d, e, f g, h, i j. k, I m, n, o p, q, r, s t, u, v 3 4 5 7 8 9. W, X, y, Z
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY