Question: a program to validate the names You have a choice o a Prolog DCG program in a file called full_name.pl (started for you) with a
a program to validate the names
You have a choice o a Prolog DCG program in a file called full_name.pl (started for you) with a top predicate full_name
- a Prolog database of valid and invalid cases with comments on the test cases in a file called test_names.pl (started for you) . Ive put some testing code there as well.
Given the language
FullNames = {w: w is a full name possibly with title}
write a grammar to recognize this language FullNames and implement the grammar.
Details
Note in this language FullNames
- The name may or may not have a title.
- The possible titles are (exactly as shown below) o Mr. o Mrs. o Miss o Ms. o Dr. o Hon.
- Rt Hon.
but not Governor General. There has to be at least once space between the title and the first name.
- There are zero or more middle names but everyone has a first name (that could be hyphenated, have an apostrophe or both) and a last name (that could
be hyphenated, have an apostrophe or both)
Valid full names o Joseph Philippe Pierre Yves Elliott Trudeau o Rt Hon. Justin Pierre James Trudeau o Julie Payette
- The first letter of every word should be an upper case letter.
- A first name or last name could be hyphenated and it could contain an apostrophe or have both an apostrophe and be hyphenated. In such cases, each word (of the first name or last name) must start with an upper case letter and have no blanks before or after the apostrophe or the dash.
Valid full names
- Hon. Jody Wilson-Raybould o Hon. Erin OToole o Hon. Mary-Claude Bibeau o Mrs. Annie O'Connor-Bonnor o MalAsia-Paris Africa Jackson-ONeal
- A valid full name may have spaces at the beginning or at the end of the full name as well as between the first name, each middle name and the last name.
Valid full names o Mr. Michael Lee o Hon. Harjit Singh Sajjan
- The following are NOT valid full names o Buono
- Dr. Trotter o Brock O. Lee o Dr. Ms. Chris Both o k.d. lang o Mr. Psy
- Ms.Misty Waters
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
