| 
 
| 
|  Author | Topic: Splitting up complex names  (Read 914 times) |  |  
| 
| 
| hinckleyj New Member
 
 
 member is offline
 
  
 
 
 
 
  
 Gender:
  Posts: 14
 
 | 
|  | Splitting up complex names « Thread started on: Apr 3rd, 2016, 06:11am »
 |  |  Hi All,
 
 Is there a way to split up a name into separate strings when the name may contain more than 2 elements?
 
 I know how to deal with 2 elements, such as John Smith, for example:-
 
 rem Separate names into first and last
 input "Enter the full name ";FullName$
 Posn% = instr(FullName$, " ")
 FirstName$ = left$(FullName$, Posn%-1)
 Surname$ = mid$(FullName$, Posn%+1)
 print "Your first name is ";FirstName$
 print "Your surname is ";Surname$
 end
 
 But how would you handle names like:-
 John van Smith
 John van de Burgh
 John Paul Bob Smith Jr.
 
 Thanks to anyone who has had the same issue before and solved it.
 
 Regards,
 
 John
 |  
| 
|  |  Logged |  
 |  |  |  
| 
| 
| Ian Kings New Member
 
 
 member is offline
 
  
 
 
 
 
  
 Gender:
  Posts: 3
 
 | 
|  | Re: Splitting up complex names « Reply #1 on: Apr 3rd, 2016, 10:20am »
 |  |  John,
 
 You can use Richards split function available in the STRINGLIB.
 
 Here's a short example.
 
 Code:
 
      REM FN_split(A$, d$, RETURN a$())
      REM
      REM Split a string at specified delimiter:
      REM A$ is the string to be split
      REM d$ is the delimiter at which to split
      REM a$() is an array to receive the parts (created if necessary)
      REM The returned value is the number of array elements written
      INSTALL @lib$+"STRINGLIB"
      fullname$="John Paul Smith"
      result=FN_split(fullname$, " ", parts$())
      FOR i=0 TO result-1
        PRINT parts$(i)
      NEXT i
      END
 
 Ian
 
 |  
| 
|  |  Logged |  
 |  |  |  
| 
| 
| hinckleyj New Member
 
 
 member is offline
 
  
 
 
 
 
  
 Gender:
  Posts: 14
 
 | 
|  | Re: Splitting up complex names « Reply #2 on: Apr 3rd, 2016, 8:18pm »
 |  |  Hi Ian,
 
 Thank you.
 
 That's worked great!
 
 Appreciate your help.
 
 Regards,
 John.
 |  
| 
|  |  Logged |  
 |  |  |  
| 
| 
| JGHarston Junior Member
 
 
 member is offline
 
  
 
 
 
 
    
 Gender:
  Posts: 52
 
 | 
|  | Re: Splitting up complex names « Reply #3 on: Apr 10th, 2016, 3:00pm »
 |  |  on Apr 3rd, 2016, 06:11am, hinckleyj  wrote:
 | | Is there a way to split up a name into separate strings when the name may contain more than 2 elements? ...
 But how would you handle names like:-
 John van Smith
 John van de Burgh
 John Paul Bob Smith Jr.
 
 | 
 | 
 Some of that requires human interaction, or a degree of artificial intelligence. For example, how does a program know which part of "John van de Burgh" is the surname? Is he Mr Burgh, first name John, middle names van de? With that example you can program in that components with a lower-case initial letter are part of the surname, but then you get Mao Ze Dung. Is he Mr Dung or Mr Ze Dung?
 
 I've written programs that parse Census records and spit out regular data fields. When the source has had the entire name in one field I parse it backwards looking for the first space, or the last space followed by a lower case letter.
 
 Viz:
 Elizabeth Anderson Gibbons
 Elizabeth Anderson#Gibbons
 Jacob Henley-Stamp
 Jacob#Henley-Stamp
 Mikael van der Holdt
 Mikael#van der Holdt
 Pietor von Tasman von Beringburg
 Pietor von Tasman#von Beringburg
 
 Though it still needs outside knowledge added to it to cope with:
 David Lloyd George
 David#Lloyd George
 
 |  
| 
|  |  Logged |  
 |  |  |  
| 
| 
| hinckleyj New Member
 
 
 member is offline
 
  
 
 
 
 
  
 Gender:
  Posts: 14
 
 | 
|  | Re: Splitting up complex names « Reply #4 on: Apr 10th, 2016, 8:39pm »
 |  |  on Apr 10th, 2016, 3:00pm, JGHarston  wrote:
 | | I've written programs that parse Census records and spit out regular data fields. 
 | 
 | 
 
 Would you be willing to share those here?
 
 
 |  
| 
|  |  Logged |  
 |  |  |  
 |