1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
julsineya [31]
3 years ago
12

Haigy Paigy is as a children's invented language which sounds exactly like English, except that "aig" is inserted before the vow

el 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.
Computers and Technology
1 answer:
Aleksandr-060686 [28]3 years ago
8 0

Answer:

def haigyPaigy(dict, text):

 # Create a regular expression  from the dictionary keys

 regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys())))

 # For each match, look-up corresponding value in dictionary

 return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)  

text = input("Enter text: ")

dict = {

   "a" : "aiga",

   "e" : "aige",

   "i" : "aigi",

   "o" : "aigo",

   "u" : "aigu",

   

 }  

print(haigyPaigy(dict, text))

Explanation:

Step 1:

define the haigyPaigy function: this function takes its argument from a dictionary and the text you you want to convert.

<em>def haigyPaigy(dict, text): </em>

<em />

In the function, there are two regular expressions:

  • <em>regex = re.compile("(%s)" % "|".join(map(re.escape, dict.keys()))) </em>

<em>this is a regular expression for the dictionary keys, it looks through the text for a match, it acts like a scanner, simply put, it looks for [a,e,i,o,u].</em>

re.compile(pattern, repl, string): is used to combine a regular expression pattern into pattern objects, which can be used for pattern matching. It also helps to search a pattern again without rewriting it.

  • <em>return regex.sub(lambda mo: dict[mo.string[mo.start():mo.end()]], text)  </em>

For each match, it looks up the key in the dictionary and replaces it with a corresponding value.

Step 2:

prompt the user to input the text that needs conversion to Haigy Paigy

<em>text = input("Enter text: ") </em>

Step 3:

Create the dictionary by inputting the key and the corresponding value.

NOTE: the key is what you want to replace in the text and the value is what you're replacing it with.

<em>dict = { </em>

<em>    "a" : "aiga", </em>

<em>    "e" : "aige", </em>

<em>    "i" : "aigi", </em>

<em>    "o" : "aigo", </em>

<em>    "u" : "aigu", </em>

<em>     </em>

<em>  }  </em>

<em />

Step 4:

Call the function and print the translated text to your screen.

<em>print(haigyPaigy(dict, text))</em>

<em />

You might be interested in
What is the command to disable any Processes in linix??
stiks02 [169]

Answer: killall[process_name]  or kill[PID]

Explanation:

Killall is a tool for disabling running processes on the system. It will disable all programs that matches the name mentioned.

kill disables processes based on process id numbers. it does not disable the process directly. The process recieves a signal where the process will follow instructions which it has to follow if it receives the signal.

7 0
3 years ago
In which of the following scenarios would you use the Redo function?
MakcuM [25]
D. <span>You have just used the Undo function to delete a paragraph, and you want that paragraph back.</span>
6 0
3 years ago
The type of cover letter written in response to a posted job opening
amm1812

Answer:

C

Explanation:

I don't have one but I hope you get an A.

I hope this helped

                     

4 0
3 years ago
) A stub network has ______. (Points : 2) one backup route
jeyben [28]

Answer: One backup router

Explanation:

 A stub network is the type of the packet network that basically describe the computer notwork. It typically capable for sending the complex data in the single network path when the network aware about its destination.

A stub network contain the one backup router as the stub routing is the typically designed for conserve the resources of the local router like the central processing unit (CPU) and the memory. It basically improve the stability of the network in the system.

6 0
3 years ago
¿Cómo las ciencias sociales y la tecnología han modificado tu comunidad?
sergeinik [125]

Answer:

La ciencia y la tecnología han tenido un gran impacto en la sociedad y su impacto está creciendo. ... Al hacer la vida más fácil, la ciencia le ha dado al hombre la oportunidad de perseguir preocupaciones sociales como la ética, la estética, la educación y la justicia; crear culturas; y mejorar las condiciones humanas.

4 0
3 years ago
Other questions:
  • What mode is generally used when delivering a presentation to an audience?
    8·2 answers
  • What is the name of the interface that uses graphics as compared to a command-driven interface?
    11·1 answer
  • What is 1/10 of 2.0 in decimal form​
    10·1 answer
  • How many 16ths are in 3/8 of an inch
    12·1 answer
  • How might an engineer test a computer chair for comfort?
    10·1 answer
  • If you need to define a connection request policy to apply to an 802.1x authenticating switch or a wireless access point, which
    12·1 answer
  • Which statistical function in a spreadsheet helps you to see how far each number varies, on average, from the average value of t
    5·1 answer
  • Iglesias intends to use a word processing program to create a web page. Which of these options should Iglesias use?
    14·1 answer
  • What is lasso tool write the name of any modelling and animation software<br>​
    8·1 answer
  • What is multimedia hard ware? Write any four examples of multimedia hardware. <br>​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!