Presentation is loading. Please wait.

Presentation is loading. Please wait.

Parsing a Name Homework 1. Cases to Consider Rest Last Rest Last Last, Rest Last, Rest Rest Last, Suffix Rest Last, Suffix Last, Rest, Suffix Last, Rest,

Similar presentations


Presentation on theme: "Parsing a Name Homework 1. Cases to Consider Rest Last Rest Last Last, Rest Last, Rest Rest Last, Suffix Rest Last, Suffix Last, Rest, Suffix Last, Rest,"— Presentation transcript:

1 Parsing a Name Homework 1

2 Cases to Consider Rest Last Rest Last Last, Rest Last, Rest Rest Last, Suffix Rest Last, Suffix Last, Rest, Suffix Last, Rest, Suffix Others??? Others??? Question: how do we tell the computer to recognize and distinguish each case from the others? Question: how do we tell the computer to recognize and distinguish each case from the others?

3 Distinguishing the Four Cases Case Rest LastRest Last Last, RestLast, Rest Rest Last, SuffixRest Last, Suffix Last, Rest, SuffixLast, Rest, Suffix Distinguishing Characteristic No Comma presentNo Comma present First Comma before First SpaceFirst Comma before First Space First Space before First CommaFirst Space before First Comma First Comma Last CommaFirst Comma Last Comma Note that one must remove extraneous white space before the strategy above works correctly Remove leading and trailing whitespaceRemove leading and trailing whitespace Replace multiple consecutive whitespace characters with single spaceReplace multiple consecutive whitespace characters with single space Remove any whitespace immediately before a commaRemove any whitespace immediately before a comma

4 Distinguishing the Four Cases Case Rest LastRest Last Last, RestLast, Rest Rest Last, SuffixRest Last, Suffix Last, Rest, SuffixLast, Rest, Suffix Distinguishing Characteristic No Comma presentNo Comma present First Comma before First SpaceFirst Comma before First Space First Space before First CommaFirst Space before First Comma First Comma Last CommaFirst Comma Last Comma After handling the suffix in the last two cases and then removing it along with its preceding comma and space, we are left with the first two cases


Download ppt "Parsing a Name Homework 1. Cases to Consider Rest Last Rest Last Last, Rest Last, Rest Rest Last, Suffix Rest Last, Suffix Last, Rest, Suffix Last, Rest,"

Similar presentations


Ads by Google