Home Page > > Details

Help With data Programming,Help With C++,Java Programming

Introduction to the Assignment
In Lab 0, you met the stream editor sed, which detects and replaces certain types of patterns in text, processing one line at a time. These patterns are actually specified by regular expressions. You will use sed again in Problem 1 of this Assignment, to help construct regular expressions.
You will also learn about awk, which is a simple programming language that is widely used in Unix/Linux systems and which also uses regular expressions. In Problem 1, you will construct an awk program to identify a class of Korean names.
Finally, Problem 2 is about applying induction to a problem of counting on graphs.
Introduction to awk
In an awk program, each line has the form
/pattern/ { action }
where the pattern is a regular expression (or certain other special patterns) and the action is an instruction that specifies what to do with any line that contains a match for the pattern. The action (and the {. . . } around it) can be omitted, in which case any line that matches the pattern is printed.
Once you have written your program, it does not need to be compiled. It can be executed di- rectly, by using the awk command in Linux:
$ awk -f programName inputFileName
Your program is then executed on an input file in the following way.
// Initially, we’re at the start of the input file, and haven’t read any of it yet. If the program has a line with the special pattern BEGIN, then
do the action specified for this pattern. Main loop, going through the input file:
do this action }else
just print inputLine // it goes to standard output }}
If the program has a line with the special pattern END, then do the action specified for this pattern.
Any output is sent to standard output.
You should read about the basics of awk, including the way it represents regular expressions and
the main instruction types used in its actions. Any of the following sources should be a reasonable place to start:
• A. V. Aho, B. W. Kernighan and P. J. Weinberger, The AWK Programming Language, Addison-Wesley, New York, 1988.
(The first few sections of Chapter 1 should have most of what you need, but be aware also of the regular expression specification on p28.)
inputLine := next line of input file
Go to the start of the program.
Inner loop, going through the program: {
programLine := next line of program (but ignore any BEGIN and END lines) if inputLine contains a string that matches the pattern in programLine, then
if there is an action specified in the programLine, then

• the Wikipedia article looks ok
• theawkmanpage
• the GNU Awk User’s Guide.
Introduction to Problem 1
The Master said, ‘What is necessary is to rectify names . . . . If names are not recti- fied, then words are not appropriate. If words are not appropriate, then deeds are not accomplished.’
– Confucius (T+P), The Analects (transl. R. Dawson), Oxford University Press, 1993, §13.3.
Most organisations today deal with people from many di↵erent cultures and language groups, and they must often record and process people’s names in systems that work mainly with English language text. In such contexts, it is helpful to be able to recognise names from di↵erent language groups. Example applications include: determining how to pronounce students’ names when reading them out from a list at graduation ceremonies; determining how to greet a person with whom you have an appointment; determining how to enter the various parts of a person’s name into a database; determining how automatically-generated emails, sent to many di↵erent people listed in some file, should address each recipient; determining the most likely native language of a person in situations where their name is known but they cannot be spoken to directly at the time (e.g., in some emergency situations). Recognising the language group that a name belongs to is an important first step in all these situations.
In this problem you will write some code in sed and awk to try to recognise one type of names in a long file of Asian names. More specifically, suppose you are given an input file in which each line starts with a person’s name in some language, with each name transcribed somehow into English text. Your task is to detect which of these names come from Korean. 1
In the input file, all text from the start of each line until the first colon (:) on the line (but not including the colon itself) is taken to be a person’s name. In most cases, each line ends with a string of non-blank letters specifying which language the name is believed to come from. An example input file is provided, as inputFileOfNames. If you browse through the file, you will notice that it contains names from a variety of Asian languages: Mandarin, Cantonese, Hokkien, Teochew, Hakka, Korean, Japanese, Thai, Vietnamese, Malay and Indonesian. They have been represented in English text using a variety of transcription schemes, and with all extra marks on letters (accents, tone marks, other diacritical marks, etc.) removed. 2 In many cases, the line about a person also contains some other information about them, but our name recognition task will ignore that information.3
Further information about working with names from di↵erent cultures can be found in:
• Fiona Swee-Lin Price, Success with Asian Names, Allen & Unwin, Crows Nest, NSW, 2007.
• J. Greenberg Motamedi, Z. Ja↵ery, A. Hagen, and S. Y. Yoon, Getting it right: Reference guides for registering students with non-English names, 2nd edition. (REL 2016-158 v2), U.S. Depart- ment of Education, Institute of Education Sciences, National Center for Education Evaluation and Regional Assistance, Regional Educational Laboratory Northwest, Washington, DC, 2017.
• SBS, The Cultural Atlas, https://culturalatlas.sbs.com.au/. You can look up a country or culture (e.g., by clicking on a map) and then click on a link to “Naming” for that culture.
1There are a few romanisation systems for transcribing Korean into English.
2These marks carry important information about meaning and pronunciation. But they are often removed when names are represented using other alphabets.
3The file was compiled from a number of sources, mainly Wikipedia lists of names of type https://en.wikipedia.org/wiki/ListofCultureNamepeople, where CultureName is one of the cultures listed above; also https://www.goratings.org/en/. The lists obtained from Wikipedia are rather imperfect, with peo- ple’s names often not written in a form that clearly shows the claimed cultural background.

Names in Korean
Korean names consist of a family name followed by a given name (the reverse of the usual order in English). The family name usually consists of just a single syllable, and the given name usually consists of two syllables. We restrict ourselves to names with these numbers of syllables from now on.4
We treat a Korean name as consisting of a syllable, followed by a space, followed by two consec- utive syllables which may have a hyphen between them.
Each syllable consists of an optional prefix,

Contact Us - Email:99515681@qq.com    WeChat:codinghelp
Programming Assignment Help!