Hi,

I have this procedure "TrueProper" written maybe something to extend with
your prefixes?

* Original written by: Jim Osieczonek
* Adjusted with Brackets function and Multilanguage function
*****************************************************************
FUNCTION TrueProper
PARAMETER tcIn,cNameToBeProperred
LOCAL lnI, lnSpecialCharCount, lnLoc, lnLoc2, lcOut, lnj, lcIn, nLen,
lnBracketOpen
LOCAL lnBracketClose, lnOpenElement, lnCloseElement

tcIn = ALLTRIM(PROPER(tcIn))
lcIn = tcIn
lnSpecialCharCount = OCCURS("-",tcIn)
IF lnSpecialCharCount = 0 OR ;
    (lnSpecialCharCount = 1 AND LEFT(tcIn,1) = "-") OR ;
    (lnSpecialCharCount = 1 AND RIGHT(tcIn,1) = "-")
    * either no dash or there is only one and it is at the beginning or end
    lcOut = tcIn
ELSE
    lcOut = ""
    FOR lnI = 1 TO lnSpecialCharCount
        lnLoc = ATC("-",tcIn)
        lcOut = lcOut + LEFT(tcIn,lnLoc) + UPPER(SUBSTR(tcIn,lnLoc +1,1))
        tcIn = SUBSTR(tcIn,lnLoc+2)
    ENDFOR
    IF !EMPTY(tcIn)
        lcOut = lcOut + tcIn
    ENDIF
ENDIF

* Reset tcIn for the next routine
tcIn = lcOut

* UPPER character "prior" to a period, unless it is at the end of a word.
lnSpecialCharCount = OCCURS('.',tcIn)
IF lnSpecialCharCount = 0 OR ;
    (lnSpecialCharCount = 1 AND RIGHT(tcIn,1) = ".")
    * either no period or there is only one and it is at the end
    lcOut = tcIn
ELSE
    lcOut = ''
    FOR lnI = 1 TO lnSpecialCharCount
        lnLoc = ATC('.',tcIn)
        IF lnLoc > 0
            lcOut = lcOut + LEFT(tcIn,lnLoc)
            * includes period from tcIn
            IF lnLoc = LEN(tcIn)
                * the last char is a period and we already included it
                tcIn = ""
            ENDIF
            IF !EMPTY(tcIn)
                lcOut = lcOut + UPPER(SUBSTR(tcIn,lnLoc + 1,1))
                IF LEN(tcIn) = 1
                    * only one char and we just concatinated it using the
UPPER function
                    tcIn = ""
                ELSE
                    * skip by the period and character we just added
                    tcIn = SUBSTR(tcIn,lnLoc+2)
                ENDIF
            ENDIF
        ENDIF
    ENDFOR
    lcOut = lcOut + tcIn
ENDIF

* Reset tcIn for the next routine
tcIn = lcOut

* UPPER the character after an apostrophe if the prior character is a
single occurrence.
* O'neil will become O'Neil, but They're will remain They're

lnSpecialCharCount = OCCURS("'",tcIn)
IF lnSpecialCharCount = 0 OR ;
    (lnSpecialCharCount = 1 AND LEFT(tcIn,1) = "'") OR ;
    (lnSpecialCharCount = 1 AND RIGHT(tcIn,1) = "'")
    * either no apostrophe or there is only one and it is at the beginning
or end
    lcOut = tcIn
ELSE
    lcOut = ""
    FOR lnI = 1 TO lnSpecialCharCount
        lnLoc = ATC("'",tcIn)
        IF lnLoc > 0
            IF lnLoc = 1
                * at first character
                lcOut = lcOut + LEFT(tcIn,1)
                tcIn = SUBSTR(tcIn,2)
            ELSE
                lcOut = lcOut + LEFT(tcIn,lnLoc)
                * includes apostrophe from tcIn
                IF ISUPPER(SUBSTR(lcOut,LEN(lcOut)-1,1))
                    * prior character is upper case so make the next tcIn
                    * character an UPPER character.
                    tcIn = UPPER(SUBSTR(tcIn,lnLoc+1,1)) +;
                        SUBSTR(tcIn,lnLoc+2)
                ELSE
                    * skip by the period and character we just added
                    tcIn = SUBSTR(tcIn,lnLoc+1)
                ENDIF
            ENDIF
        ENDIF
    ENDFOR
    lcOut = lcOut + tcIn
ENDIF

* Reset tcIn for the next routine
tcIn = lcOut

* UPPER the character between brackets
* multiple items in the same sentence that need to be properred
lnSpecialCharCount = OCCURS('(',tcIn)
IF lnSpecialCharCount = 0
    lcOut = tcIn
ELSE
    lcOut = ""
    FOR lnI = 1 TO lnSpecialCharCount
        lnLoc = ATC('(',tcIn)
        IF lnLoc > 0
            lcOut = lcOut + LEFT(tcIn,lnLoc)
            * includes bracket from tcIn
            IF lnLoc = LEN(tcIn)
                * the last char is a bracket no need to upper this
                tcIn = ""
            ENDIF
            IF !EMPTY(tcIn)
                lcOut = lcOut + UPPER(SUBSTR(tcIn,lnLoc + 1,1))
                IF LEN(tcIn) = 1
                    * only one char and we just concatinated it using the
UPPER function
                    tcIn = ""
                ELSE
                    * skip by the bracket and character we just added
                    tcIn = SUBSTR(tcIn,lnLoc+2)
                ENDIF
            ENDIF
        ENDIF
    ENDFOR
    lcOut = lcOut + tcIn
ENDIF

* Reset tcIn for the next routine
tcIn = lcOut

* UPPER the character between apostrophes
* multiple items in the same sentence that need to be properred
lnSpecialCharCount = OCCURS("'",tcIn)
IF lnSpecialCharCount = 0
    lcOut = tcIn
ELSE
    lcOut = ""
    FOR lnI = 1 TO lnSpecialCharCount
        lnLoc = ATC("'",tcIn)
        IF lnLoc > 0
            lcOut = lcOut + LEFT(tcIn,lnLoc)
            * includes bracket from tcIn
            IF lnLoc = LEN(tcIn)
                * the last char is a apostrophe no need to upper this
                tcIn = ""
            ENDIF
            IF !EMPTY(tcIn)
                lcOut = lcOut + UPPER(SUBSTR(tcIn,lnLoc + 1,1))
                IF LEN(tcIn) = 1
                    * only one char and we just concatinated it using the
UPPER function
                    tcIn = ""
                ELSE
                    * skip by the apostrophe and character we just added
                    tcIn = SUBSTR(tcIn,lnLoc+2)
                ENDIF
            ENDIF
        ENDIF
    ENDFOR
    lcOut = lcOut + tcIn
ENDIF

* Reset tcIn for the next routine
tcIn = lcOut

* fix some of the small words ( of ) that we wish to have lower there could
* be multiple items in the same sentence that need to be lowered


LOCAL ARRAY laLowerCaseStrings[35]
laLowerCaseStrings[1] = ' Of '
laLowerCaseStrings[2] = ' And '
laLowerCaseStrings[3] = ' The '
laLowerCaseStrings[4] = ' Or '
laLowerCaseStrings[5] = ' For '
laLowerCaseStrings[6] = ' Is '
laLowerCaseStrings[7] = ' At '
laLowerCaseStrings[8] = ' Are '
laLowerCaseStrings[9] = ' Up '
laLowerCaseStrings[10] = ' De '
laLowerCaseStrings[11] = ' La '
laLowerCaseStrings[12] = ' Van '
laLowerCaseStrings[13] = ' En '
laLowerCaseStrings[14] = ' De '
laLowerCaseStrings[15] = ' Und '
laLowerCaseStrings[16] = ' Der '
laLowerCaseStrings[17] = ' Do '
laLowerCaseStrings[18] = ' Fuer '
laLowerCaseStrings[19] = ' Am '
laLowerCaseStrings[20] = ' In '
laLowerCaseStrings[21] = ' Im '
laLowerCaseStrings[22] = ' Et '
laLowerCaseStrings[23] = ' Pour '
laLowerCaseStrings[24] = ' Le '
laLowerCaseStrings[25] = ' La '
laLowerCaseStrings[26] = ' Du '
laLowerCaseStrings[27] = ' Di '
laLowerCaseStrings[28] = ' E '
laLowerCaseStrings[29] = ' Del '
laLowerCaseStrings[30] = ' Dei '
laLowerCaseStrings[31] = ' Per '
laLowerCaseStrings[32] = ' Scrl '
laLowerCaseStrings[33] = ' E '
laLowerCaseStrings[34] = ' Scparl '
laLowerCaseStrings[35] = ' Fur '

FOR lnI = 1 TO ALEN(laLowerCaseStrings)
    FOR lnj = 1 TO OCCURS(laLowerCaseStrings[lnI],lcOut)
        lnLoc = AT(laLowerCaseStrings[lnI],lcOut)
        IF lnLoc > 0
            lcOut = LEFT(lcOut,lnLoc -1) + LOWER(laLowerCaseStrings[lnI]) +;
                    SUBSTR(lcOut,lnLoc + LEN(laLowerCaseStrings[lnI]))
        ENDIF
    ENDFOR
ENDFOR

* fix some of the small words ( of ) that we wish to have in a special
writing
* not coverred in previous routines, mainly special foreign abbreviations.
* be multiple items in the same sentence need to be changed

LOCAL ARRAY laLowerCaseSpecial[18,2]
laLowerCaseSpecial[1,1] = ' Gmbh '
laLowerCaseSpecial[1,2] = ' GmbH '
laLowerCaseSpecial[2,1] = '.M.B.H. '
laLowerCaseSpecial[2,2] = '.m.b.H. '
laLowerCaseSpecial[3,1] = ' Spa '
laLowerCaseSpecial[3,2] = ' SpA '
laLowerCaseSpecial[4,1] = ' Mbh '
laLowerCaseSpecial[4,2] = ' mbH '
laLowerCaseSpecial[5,1] = 'Jpmorgan '
laLowerCaseSpecial[5,2] = 'JPMorgan '
laLowerCaseSpecial[6,1] = ' Sa '
laLowerCaseSpecial[6,2] = ' SA '
laLowerCaseSpecial[7,1] = 'S/a'
laLowerCaseSpecial[7,2] = 'S/A'
lalowerCaseSpecial[8,1] = ' sa '
lalowerCaseSpecial[8,2] = ' SA '
laLowerCaseSpecial[9,1] = 'Bnp '
laLowerCaseSpecial[9,2] = 'BNP '
laLowerCaseSpecial[10,1] = '(uk)'
laLowerCaseSpecial[10,2] = '(UK)'
laLowerCaseSpecial[11,1] = '(Uk)'
laLowerCaseSpecial[11,2] = '(UK)'
laLowerCaseSpecial[12,1] = ' Uk '
laLowerCaseSpecial[12,2] = ' UK '
laLowerCaseSpecial[13,1] = '(Plc)'
laLowerCaseSpecial[13,2] = '(plc)'
laLowerCaseSpecial[14,1] = ' Nv '
laLowerCaseSpecial[14,2] = ' NV '
laLowerCaseSpecial[15,1] = ' Abn '
laLowerCaseSpecial[15,2] = ' ABN '
laLowerCaseSpecial[16,1] = ' Jp '
laLowerCaseSpecial[16,2] = ' JP '
laLowerCaseSpecial[16,1] = ',The '
laLowerCaseSpecial[16,2] = ', the '
laLowerCaseSpecial[16,1] = " D'"
laLowerCaseSpecial[16,2] = " d'"





FOR lnI = 1 TO ALEN(laLowerCaseSpecial)/2
    FOR lnj = 1 TO OCCURS(laLowerCaseStrings[lnI,1],lcOut)
        lnLoc = AT(laLowerCaseStrings[lnI,1],lcOut)
        IF lnLoc > 0
            lcOut = LEFT(lcOut,lnLoc -1) + laLowerCaseStrings[lnI,2] +;
                    SUBSTR(lcOut,lnLoc + LEN(laLowerCaseStrings[lnI,2]))
        ENDIF
    ENDFOR
ENDFOR

IF lcOut<>lcIn
    REPLACE &cNameToBeProperred WITH lcOut
ENDIF
RETURN lcOut




Regards,
Koen

2015-01-05 16:56 GMT+01:00 Kevin Cully <[email protected]>:

> I wonder if you can get that from the USPS?
>
>
> On 01/05/2015 10:54 AM, Jeff Johnson wrote:
>
>> Or better yet, a free list of every city in the US with counties.  I have
>> a file with all zip codes and cities, but no counties.
>>
>>
>> On 1/5/2015 8:31 AM, Jeff Johnson wrote:
>>
>>> When parsing addresses some cities can be two or three words.  Has
>>> anyone seen a list of prefixes?  For example "New" in "New River" or "St."
>>> in "St. Johns".
>>>
>>> TIA
>>>
>>>
>>
>
[excessive quoting removed by server]

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/CACUu1StW4r_wG5hJfRpv8NP9BNbCE_rdFoPUPT9m8vwQg=h...@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to