Page 1 of 1

This task is from a real project. These are author names from COHA (Corpus of Historical American English). The guidelin

Posted: Tue May 24, 2022 8:00 am
by answerhappygod
This task is from a real project. These are author names
from COHA (Corpus of Historical American English). The guidelines
for entering the names of authors were severely lacking and
therefore there are many different ways they have been input. Your
task is to write a script that extracts the first name for all the
different ways of writing the author names as per the example code
(the different variations have been simplified some).
You will need to use multiple functions. You are free to use
regular expressions if you want, but it is not necessary and I have
not used them in my solution. You should not compare to namelists,
but instead create rules in a flowchart like manner. You will
likely need helper functions that check for the presence of commas,
periods, certain titles, parentheses etc.
For the full 50 points for this task, all the names need to be
extracted correctly, with no hard coding (checking for specific
names for example), and proper reuse of functions (i.e. depending
on your chosen approach, you are likely to need to use recursive
functions to check for names inside parentheses).
There are infinite ways to solve this task so use your
creativity. I recommend writing down what needs to be checked and
in which order on paper (like a step-by-step list or flowchart),
then writing the names of the functions you need with comments
describing what will need to take place inside those functions.
Then you can start testing one function at a time and ultimately
merge them all.
```
authors = ["Hawthorne, Nathaniel","Cranch, Christopher
Pearse","Hoffman, Charles Fenno","Dr. John Pierpont","Calvert,
George Henry","Whitman, Sarah Helen","Fields, James Thomas","Prime,
Benjamin Young","Smith, Seba","Bannister, Nathaniel
Harrington","Brougham, John","Mathews, Cornelius","Smith, John
N.","Fuller, Margaret","Landmark Anthologies","Conway, H.
J.","Allston, Washington","Simms, William Gilmore","Ware,
William","Hawthorne, Nathaniel","Gallagher, William D. (William
Davis)","Hale, Sarah Josepha Buell","Emerson, Ralph
Waldo","Sigourney, L. H. (Lydia Howard)","Sigourney, L. H. (Lydia
Howard)","La Bree, Lawrence","Sprague, Achsa
W.","Everpoint","Hawthorne, Nathaniel","Herbert, Henry
William","Mathews, Cornelius","Simms, William Gilmore","Hawthorne,
Nathaniel","Hawthorne, Nathaniel","Hawthorne,
Nathaniel","Hawthorne, Nathaniel","Hawthorne,
Nathaniel","Hawthorne, Nathaniel","Hawthorne, Nathaniel","Osgood,
Frances Sargent Locke","Chivers, T. H. (Thomas Holley)","Brooks,
Maria Gowen","Child, Lydia Maria Francis","Duganne, A. J. H.
(Augustine Joseph Hickey)","Fay, Theodore S. (Theodore
Sedgwick)","Hall, Baynard Rush","Ingraham, J. H. (Joseph
Holt)","Ingraham, J. H. (Joseph Holt)","Herbert, Henry
William","Dr. Herbert, Henry William","Hoffman, Charles
Fenno","Mathews, Cornelius","Stowe, Harriet Beecher","Hawthorne,
Nathaniel","Story, William Wetmore","Schoolcraft, Henry
Rowe","Smith, Seba","Hentz, Caroline Lee","Logan, Cornelius
Ambrosius","Longfellow, Henry Wadsworth","Hawthorne,
Nathaniel","Hawthorne, Nathaniel","Flagg, Edmund","Ingraham, J. H.
(Joseph Holt)","Ingraham, J. H. (Joseph Holt)","Ingraham, J. H.
(Joseph Holt)","Herbert, Henry William","Lippard, George","Lippard,
George","Simms, William Gilmore","Cranch, Christopher
Pearse","Whittier, John Greenleaf","Osgood, Frances Sargent
Locke","Willis, Nathaniel Parker","Smith, Samuel Francis","Smith,
Samuel Francis","Hale, Sarah Josepha Buell","Emerson, Ralph
Waldo","Mathews, Cornelius","Taylor, Bayard","Tuckerman, Henry T.
(Henry Theodore)","Keteltas, Caroline M.","Morey, Amos C.","Mrs.
Putnam, Mary Lowell","Thoreau, Henry David","Wilmer, Lambert
A.","Cooper, James Fenimore","Hale, Sarah Josepha Buell","Ingraham,
J. H. (Joseph Holt)","Herbert, Henry William","Judd,
Sylvester","Kirkland, Caroline M. (Caroline Matilda)","Sargent,
Epes","Simms, William Gilmore","Simms, William Gilmore","Simms,
William Gilmore","Thorpe, Thomas Bangs","Thorpe, Thomas
Bangs","Chivers, T. H. (Thomas Holley)","Peirson, Lydia
Jane","Simms, William Gilmore","Sigourney, L. H. (Lydia
Howard)","Anon.","Everett, Alexander Hill","Everett, Alexander
Hill","Everett, Alexander Hill","Hewitt, John H.","Poe, Edgar
Allan","Hawthorne, Nathaniel","Herbert, Henry William","Herbert,
Henry William","Melville, Herman","Cooper, Susan Fenimore","Cooper,
Susan Fenimore","Child, Lydia Maria Francis","Hale, Sarah Josepha
Buell","Ingraham, J. H. (Joseph Holt)","Ingraham, J. H. (Joseph
Holt)","Ingraham, J. H. (Joseph Holt)","Sigourney, L. H. (Lydia
Howard)","Whittier, John Greenleaf","Osgood, Frances Sargent
Locke","Osgood, Frances Sargent Locke","Osgood, Frances Sargent
Locke","Osgood, Frances Sargent Locke","Ware, Henry","Peirson,
Lydia Jane","Higginson, Thomas Wentworth","Embury, Emma C. (Emma
Catherine)","Smith, Elizabeth Oakes Prince","Payne, John
Howard","Sargent, Epes","Steele, Silas Sexton","Poe, Edgar
Allan","Durivage, O. E. (Oliver Everett)","Melville,
Herman","Talmage, T. De Witt (Thomas De Witt)","Follen, Eliza Lee
Cabot","Barker, B. (Benjamin)","Harris, George
Washington","Ingraham, J. H. (Holt, Joseph)","Ingraham, J. H.
(Joseph Holt)","Ingraham, J. H. (Joseph Holt)","Ingraham, J. H.
(Joseph Holt)","Herbert, Henry William","Herbert, Henry
William","Lippard, George","Lippard, George","Thorpe, Thomas
Bangs","Whittier, John Greenleaf","Osgood, Frances Sargent
Locke","Hoffman, Charles Fenno","Hoffman, Charles Fenno","Calvert,
George Henry","Hale, Sarah Josepha Buell","Taylor, Bayard","Clark,
Willis Gaylord","Brownell, Henry Howard","Hubbell,
Horatio","Paulding, James Kirke","Paulding, James Kirke","Paulding,
James Kirke","Paulding, James Kirke","Sargent, Epes","Sargent,
Epes","Sargent, Epes","Smith, William Henry","Thoreau, Henry
David","Aldridge, Ira Frederick","Cooper, James Fenimore","Ballou,
Maturin Murray","Ware, William","Bennett, Emerson","Bennett,
Emerson","Ingraham, J. H. (Joseph Holt)","Herbert, Henry
William","Lippard, George","Lippard, George","Myers, P. Hamilton
(Peter Hamilton)","Myers, P. Hamilton (Peter Hamilton)","Sedgwick,
Catharine Maria","Thompson, Daniel P. (Daniel Pierce)","Thompson,
William Tappan","Osgood, Frances Sargent Locke","Willis, Nathaniel
Parker","Hoffman, Charles Fenno","Hoffman, Charles Fenno","Saxe,
John Godfrey","Pike, Albert","Gallagher, William D. (William
Davis)","Legare, James Matthews","Hale, Sarah Josepha Buell","Hale,
Sarah Josepha Buell","Sargent, Epes","Taylor, Bayard","Boker,
George H. (George Henry)","Anthon, Charles Edward"]
#different name types:
#Hawthorne, Nathaniel -> Nathaniel
#Cranch, Christopher Pearse -> Christopher
#Conway, H. J. -> H
#Smith, John N. -> John
#Sigourney, L. H. (Lydia Howard)" -> Lydia
#Ingraham, J. H. (Holt, Joseph) -> Joseph
#Mrs. Putnam, Mary Lowell -> Mary
#Dr. John Pierpont -> John
```
I will give good feedback if you solve my problem
correctly