Write a structured (procedural) Python program that solves the following spec:
Soundex System Coding: Soundex is a system that encodes a word into a letter followed by three numbers that roughly describe how the word sounds. Therefore, similar sounding words have the same four-character code. Use the following set of (slightly modified #4) rules to create a translator from English words to Soundex Code:
Python program Requirements: Your program is expected to…
Soundex is primarily used as a tool to group homophobic English-sounding surnames. It was developed by Robert C. Russell and Margaret King over 100 years ago!
You can read more about it at Wikipedia: https://en.wikipedia.org/wiki/Soundex
thanks for the question, here is the python code with screenshot. I ran for two words PRORAMMING and ANITA and its giving the right soundex code.
let me know for any questions, comments added for each important function
=======================================================================
# function accepts a raw word
# function returns a word with deleted vowel and letters
HWY
def delete_vowels(word):
word = word.upper()
delete_letters = ['A',
'E', 'I', 'O',
'U', 'H', 'W',
'Y']
modified = word[0]
for letter in
word[1:]:
if
letter not in delete_letters:
modified += letter
return modified
# function takes a word (with deleted vowels) and return the
final soundex code
def assign_number(word):
# letter to number dictionary
letter_keys = {'B': 1,
'F': 1, 'P': 1,
'V': 1, 'C': 2,
'G': 2, 'J': 2,
'K': 2, 'Q': 2,
'S': 2, 'X': 2,
'Z': 2,
'D': 3, 'T': 3,
'L': 4, 'M': 5,
'N': 5, 'R': 6}
previous = 0 # track the previous
letter
modified = word[0] # keep the first
letter
# iterate over each letter in the word
for i in
range(1, len(word)):
if i ==
1:
previous = letter_keys.get(word[i])
modified += str(letter_keys.get(word[i]))
else:
number = letter_keys.get(word[i])
if number != previous:
modified += str(number)
previous = number
if len(modified) >= 4:
return
modified[:4]
else: # append extra 0 at
the end
spaces = 4 -
len(modified)
return
modified + '0' * spaces
# main function that accepts a raw word and retursn the soundex
code of the word
def convert_to_soundex(word):
word = delete_vowels(word)
return
assign_number(word)
def main():
# keeping asking user for a word or name
until user enters 0
while True:
word =
input('Enter a word/name to convert (enter 0 to quit):
').upper()
if word ==
'0': break
print(convert_to_soundex(word))
main()
![1: Project untitled - [C:\Users\248341\Pycharm Projects\untitled] - ... \Name.py - PyCharm Community Edition 4.0.3 File Edit](http://img.homeworklib.com/questions/81e9df80-a112-11ea-95d8-ed8cd6ab5315.png?x-oss-process=image/resize,w_560)
Write a structured (procedural) Python program that solves the following spec: Soundex System Coding: Soundex is...
python
Hi I have a project due on this Friday and I really can’t seem
to figure this code out. If anyone could write this for me it’d be
very appreciated. Thank you!
The Soundex Code code for surnames. It was code. All Al Soundex is a system that designed to produce one code for natha may be speled differenty, similar sounds. For example, Horn and Heron the same Soundex US Census Indexes from 1880 to the most recent availabie...
python
Hi I have a project due on this Friday and I really can’t seem
to figure this code out. If anyone could write this for me it’d be
very appreciated. Thank you!
The Soundex Code code for surnames. It was code. All Al Soundex is a system that designed to produce one code for natha may be speled differenty, similar sounds. For example, Horn and Heron the same Soundex US Census Indexes from 1880 to the most recent availabie...
1. Write a python program that reads a file and prints the letters in increasing order of frequency. Your program should convert entire input to lower case and only counts letters a-z. Special characters or spaces should not be counted. Each letter and it's occurrences should be listed on a separate line. 2. Test and verify your program and it's output. ---Please provide a code and a screenshot of the code and output. Thank you. ----
Write a Python program stored in a file q6.py that takes a text (without punctuation) as input and prints the number of occurrences of each word. Your program is case-insensitive, meaning that uppercase and lowercase of the same letter is considered the same. Printing should be done in decreasing order of the number of occurrences. If several words have the same number of occurrences, they should be printed in alphabetical order. A new line must be printed between the words...
I need help with building the program since Huffman's
algorithm is not clear. I would appreciate if a pseudo code for
encoding and decoding the algorithm is provided, as well as the
program for both of them since it deals with English text instead
of characters. I'd appreciate it if it was in C++, or Java.
1. si o Write a program that constructs a Huffman code for a given English text and encode it. The English character occurrence probabilities...
Python program. Character-Analysis Program Problem Statement: Design a program - IN PYTHON - that asks the user to enter a string. The string will then be displayed back to the user. This is followed by determining the number of alphabetic characters, numeric characters, lower_case letters, upper_case letters, whitespace characters, and then displaying them. The user should be given additional chances to enter additional strings, and each time a string is entered, the above process is to be performed. The inputting...
Write an FST to implement the Soundex algorithm. The Soundex algorithm is a method commonly used in libraries and older Census records for representing people’s names. It has the advantage that versions of the names that are slightly misspelled or otherwise modified (common, for example, in hand-written census records) will still have the same representation as correctly spelled names. (e.g., Jurafsky, Jarofsky, Jarovsky, and Jarovski all map to J612). Keep the first letter of the name, and drop all occurrences...
Create a python code named LetterCount with a text file named words.txt that contains at least 100 words in any format - some words on the same line, some alone (this program involves no writing so you should not be erasing this file). Then create a program in the main.py that prompts the user for a file name then iterates through all the letters in words.txt, counting the frequency of each letter, and then printing those numbers at the end...
Make a C program to count the number of occurrences of words from the input. For example, with input "one two one three one two" your program should output: one 3 two 2 three 1 It should work for up to 100 different words. If there are more than 100 unique words in the input, the program should still work, and count the number of appearances of the first 100 unique words. Each word should have the same maximum amount...
C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...