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
While using the CLI on a Windows 10 64-bit computer with a single HDD and a single volume, you want to move from the current dir
dimulka [17.4K]

Answer:

50-64

Explanation:

We know this because I said so

5 0
4 years ago
Disadvantages of using social network site GOAL SETTTING?
andriy [413]

Answer:

addiction, mental illness, misleading information, scams, cyberbullying

Explanation:

4 0
2 years ago
You need to design a backup strategy. You need to ensure that all servers are backed up every Friday night and a complete copy o
cestrela7 [59]

Answer: (A) full backup

Explanation: A backup strategy is a term used to describe the various effective approach engaged in creating a backup for data or information.

A FULL BACK UP IS THE VARIOUS APPROACH AND SYSTEMS PUT IN PLACE BY A COMPUTER USER OR AN INFORMATION TECHNOLOGY EXPERT IN ORDER TO CREATE AN ADDITIONAL SAMPLE OR COPY OF AN INFORMATION OR A DATA IN S SINGLE BACKUP.

8 0
4 years ago
All of the following are U.S.-EU data privacy requirements except:
Montano1993 [528]

Answer:

b. Redundant hardware and data backup systems

Explanation:

Data privacy is important where a company collects, processes and stores personal information.In the US-EU have laid down regulations to ensure data privacy is maintained. It is a requirement before collection of personal data, to clearly state why the data is being collected and how it will be used.The individuals whose data is being processed have a right to access their data at no cost during processing . Of great importance is the security of the data so as to maintain its integrity, Companies are required to take steps in protecting the data from unauthorized access, processing and accidental loss.redundant hardware and data backup system are used by companies as a fail-safe mechanism in data protection but they are not a requirement in data privacy, although they enhance it.

8 0
3 years ago
Which of the following is a right of a user of information systems?
Eva8 [605]

Answer:

Option A is the correct option for the following question.

Explanation:

The following option is correct because this option is one of among four rights of the user of an information system which is collectively important for those users who working in any organization, company or firm. It always requires the new and the upcoming features or the function of the system.

Option B is wrong because it is not the right of the user and the right is don't disclose the secrets of your firm or company to any outsiders or any person who are not reliable.

Option C is wrong because it is not the right of the user.

Option D is wrong because it is not the right of the user and it is the responsibility of all computer users to keep their systems fit and fine.

4 0
4 years ago
Other questions:
  • The Internet is a hierarchical structure linking different levels of service providers whose millions of devices supply all the
    13·1 answer
  • Starbucks offers an app that allows remote ordering, free Wi-Fi in stores, and a loyalty program where customers can earn a free
    11·1 answer
  • bj;ljfg'cfmb dfl kbslf jflk[gkdblkfd lbrkjlfbbfkjbdfjkbadbjbbkvbk'lbk'blbf;l;lkb lm;flklmkjlvkljvkljvbfbdsjsfbbjjlkbfjklbkfj'lgg
    9·2 answers
  • A) How could you modify Shelve with a technique discussed in class so that you can create Shelve instances that contain // Tools
    6·1 answer
  • Which type of cover letter would the above excerpt come from?
    7·1 answer
  • The bus width and bus speed together determine the bus's ____ or bandwidth; that is, the amount of data that can be transferred
    6·1 answer
  • Why is know app downloading in my android phone even if I have 900 MB ???
    8·2 answers
  • The interprets the data while it is in RAM​
    8·1 answer
  • Define a class Person that represents a person. People have a name, an age, and a phone number. Since people always have a name
    7·2 answers
  • A customer bought a goods for Rs.9,000 after getting 10% discount. Calculate the marked price of the goods.Write in Qbasic.​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!