Question

Question 1: Haigy Paigy is as a children's invented language which sounds exactly like English, except...

Question 1:

Haigy Paigy is as a children's invented language which sounds exactly like English, except that “aig” is inserted before the vowel sound of each syllable. E.g., the English word “hello” becomes “haigellaigo” in Haigy Paigy. Write a set of regular expressions that will automatically translate sentences from English into Haigy Paigy. The input of your program will be a string containing one English sentence. Your regular expressions should translate this sentence into Haigy Paigy. Simplifications: only vowels can be syllable nuclei; "y" is always a vowel; several consecutive vowel letters always make a single vowel sound; the final "e" is always silent, except when it is the only vowel letter in the word.

Example input: This is a test.

Example output: Thaigis aigis aiga taigest.

Question 2:

Write a set of regular expressions that will automatically replace all instances of the indefinite article ‘a’/’an’ with the definite article ‘the’ and vice versa. The input of your program will be a string of English words.

Example input: The student. An example.

Example output: A student. The example.

Question 3:

Linguists often need to use computers to deal with human language, especially when the dataset is very large. Large collections of authentic language are called corpora (singular corpus), and the field that primarily deals with analyzing corpora for patterns is called corpus linguistics. However, computers often require special formatting of human language in order to properly analyze it. Before corpus linguists begin their analysis, they often have to first clean their data, often involving the removal of (certain types of) punctuation, extra whitespace, unwanted characters, etc. Write a set of regular expressions that removes punctuation and extra whitespace from an English sentence. The input of your program will be a string containing one English sentence. Your regular expressions should remove the punctuation and extra whitespace from this sentence.

Example input: This is an example sentence, and here is another.

Example output: This is an example sentence and here is another

Homework Answers

Answer #1

1.

import re
string =input()
newString=re.sub(r'(?i)([aeiouy])',r'aig\1',string)
print(newString)



Input: This is a test
Output: Thaigis aigis aiga taigest

2.

import re
string =input()
chageAAn=re.sub('An|A','X',string)
changeThe=re.sub('The','Y',chageAAn)
ChangeX=re.sub('X','The',changeThe)
ChangeY=re.sub('Y','A',ChangeX)
print(ChangeY)


Input: The student.An example
Output: A student.The example

3.

import re
string =input()
s = re.sub(r'[^\w\s]',"",string)
print(s)


Input: The student, An example
Output: The student An example
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT