faqts : Computers : Programming : Languages : Tse : Search

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 4 people (50%) answered Yes
Recently 2 of 4 people (50%) answered Yes

Entry

TSE: Text: Noun: Article: Algorithm: Which algorithm to use 'a' or 'an' as indefinite article?

Nov 21st, 2003 17:13
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 11 November 2003 - 07:42 pm -------------------

TSE: Text: Noun: Article: Algorithm: Which algorithm to use 'a' 
or 'an' as indefinite article?

---

From the table:

a = always pronounced with a vowel as first character, so use 'an'

b = always pronounced with a consonant as first character, so use 'a'

c = always pronounced with a consonant as first character, so use 'a'

d = always pronounced with a consonant as first character, so use 'a'

e = always pronounced with a vowel as first character, so use 'an'

f = if single character noun (e.g. in acronym) then vowel, so use 
use 'an'
    if non-single character then consonant, so use 'a'

g = always pronounced with a consonant as first character, so use 'a'

h = if single character noun (e.g. in acronym) then vowel, so use 
use 'an'
    if non-single character then consonant, so use 'a'

i = always pronounced with a vowel as first character, so use 'an'

j = always pronounced with a consonant as first character, so use 'a'

k = always pronounced with a consonant as first character, so use 'a'

l = if single character noun (e.g. in acronym) then vowel, so use 'an'
    if non-single character then consonant, so use 'a'

m = if single character noun (e.g. in acronym) then vowel, so use 
use 'an'
    if non-single character then consonant, so use 'a'

n = if single character noun (e.g. in acronym) then vowel, so use 
use 'an'
    if non-single character then consonant, so use 'a'

o = if single character always pronounced with a vowel as first
    character, so use 'an'
    otherwise
    leave it to user to decide

p = always pronounced with a consonant as first character, so use 'a'

q = always pronounced with a consonant as first character, so use 'a'

r = if single character noun (e.g. in acronym) then vowel, so use 
use 'an'
    if non-single character then consonant, so use 'a'

s = if single character noun (e.g. in acronym) then vowel, so use 
use 'an'
    if non-single character then consonant, so use 'a'

t = always pronounced with a consonant as first character, so use 'a'

u = always pronounced with a consonant as first character, so use 'a'

v = always pronounced with a consonant as first character, so use 'a'

w = always pronounced with a consonant as first character, so use 'a'

x = if single character noun (e.g. in acronym) then vowel, so use 
use 'an'
    if non-single character then consonant, so use 'a'

y = always pronounced with a consonant as first character, so use 'a'

z = always pronounced with a consonant as first character, so use 'a'

you can create the function:

--- cut here ---------------------------------------------------------

  PROC Main()
   Warn( FNStringGetArticleIndefiniteNounEnglishS( "uniform" ) ) // 
gives e.g. "a"
   Warn( FNStringGetArticleIndefiniteNounEnglishS( "SUV" ) ) // gives 
e.g. "an"
   Warn( FNStringGetArticleIndefiniteNounEnglishS( "elephant" ) ) // 
gives e.g. "an"
   Warn( FNStringGetArticleIndefiniteNounEnglishS( "RGB" ) ) // gives 
e.g. "an"
   Warn( FNStringGetArticleIndefiniteNounEnglishS( "dog" ) ) // gives 
e.g. "a"
   Warn( FNStringGetArticleIndefiniteNounEnglishS( "one" ) ) // gives 
e.g. decision to user (can be 'a' or 'an')
  END

  <F12> Main()

// --- LIBRARY --- //

  // library: string: get: article: indefinite: noun: english 
(filenamemacro=getstnen.s) [kn, ni, tu, 11-11-2003 19:23:17]
  STRING PROC FNStringGetArticleIndefiniteNounEnglishS( STRING wordS )
   STRING firstS[255] = FNInitializeNewStringS()
   STRING s[255] = FNInitializeNewStringS()
   INTEGER nounlengthI = FNInitializeNewIntegerI()
   IF FNStringCheckCaseUpperB( wordS ) // if an acronym, thus all 
characters in uppercase, then take off only first character
    firstS = wordS[1]
   ELSE // else take off the first part of the word separated by spaces
    firstS = GetToken( wordS, " ", 1 )
   ENDIF
   nounlengthI = Length( firstS )
   s = firstS[1] // take off the first character of this first word or 
character
   s = Lower( s ) // make it lower case to simplify the comparison to 
all lower cases
   IF s == "" RETURN( "?: do not enter empty string" ) ENDIF
   // Warn( wordS ) // for debugging purposes only. Remove later
   // Warn( s ) // for debugging purposes only. Remove later
   IF s == "a" RETURN( "an" ) ENDIF
   IF s == "b" RETURN( "a" ) ENDIF
   IF s == "c" RETURN( "a" ) ENDIF
   IF s == "d" RETURN( "a" ) ENDIF
   IF s == "e" RETURN( "an" ) ENDIF
   IF Lower( wordS ) == "ftp" RETURN( "an" ) ENDIF
   IF ( s == "f" ) AND ( nounlengthI == 1 ) RETURN( "an" ) ENDIF
   IF ( s == "f" ) AND ( nounlengthI > 1 ) RETURN( "a" ) ENDIF
   IF s == "g" RETURN( "a" ) ENDIF
   IF Lower( wordS ) == "hour" RETURN( "an" ) ENDIF
   IF Lower( wordS ) == "http" RETURN( "an" ) ENDIF
   IF ( s == "h" ) AND ( nounlengthI == 1 ) RETURN( "an" ) ENDIF
   IF ( s == "h" ) AND ( nounlengthI > 1 ) RETURN( "can be 'a' 
or 'an'. Please decide further yourself" ) ENDIF
   IF s == "i" RETURN( "an" ) ENDIF
   IF s == "j" RETURN( "a" ) ENDIF
   IF s == "k" RETURN( "a" ) ENDIF
   IF ( s == "l" ) AND ( nounlengthI == 1 ) RETURN( "an" ) ENDIF
   IF ( s == "l" ) AND ( nounlengthI > 1 ) RETURN( "a" ) ENDIF
   IF ( s == "m" ) AND ( nounlengthI == 1 ) RETURN( "an" ) ENDIF
   IF ( s == "m" ) AND ( nounlengthI > 1 ) RETURN( "a" ) ENDIF
   IF ( s == "n" ) AND ( nounlengthI == 1 ) RETURN( "an" ) ENDIF
   IF ( s == "n" ) AND ( nounlengthI > 1 ) RETURN( "a" ) ENDIF
   IF ( s == "o" ) AND ( nounlengthI == 1 ) RETURN( "an" ) ENDIF
   IF Lower( wordS ) == "one" RETURN( "a" ) ENDIF
   IF ( s == "o" ) AND ( nounlengthI > 1 ) RETURN( "an" ) ENDIF
   IF s == "p" RETURN( "a" ) ENDIF
   IF s == "q" RETURN( "a" ) ENDIF
   IF ( s == "r" ) AND ( nounlengthI == 1 ) RETURN( "an" ) ENDIF
   IF ( s == "r" ) AND ( nounlengthI > 1 ) RETURN( "a" ) ENDIF
   IF ( s == "s" ) AND ( nounlengthI == 1 ) RETURN( "an" ) ENDIF
   IF ( s == "s" ) AND ( nounlengthI > 1 ) RETURN( "a" ) ENDIF
   IF ( s == "t" ) RETURN( "a" ) ENDIF
   IF Lower( wordS ) == "uniform" RETURN( "a" ) ENDIF
   IF Lower( wordS ) == "update" RETURN( "an" ) ENDIF
   IF ( s == "u" ) AND ( nounlengthI == 1 ) RETURN( "a" ) ENDIF
   // IF ( s == "u" ) AND ( nounlengthI > 1 ) RETURN( "can be 'a' 
or 'an'. Please decide further yourself" ) ENDIF
   IF ( s == "u" ) AND ( nounlengthI > 1 ) RETURN( "an" ) ENDIF // 
almost always 'an'
   IF ( s == "v" ) RETURN( "a" ) ENDIF
   IF ( s == "x" ) AND ( nounlengthI == 1 ) RETURN( "an" ) ENDIF
   IF ( s == "x" ) AND ( nounlengthI > 1 ) RETURN( "a" ) ENDIF
   IF ( s == "y" ) RETURN( "a" ) ENDIF
   IF ( s == "z" ) RETURN( "a" ) ENDIF
   //
   IF ( s == "1" ) RETURN( "a" ) ENDIF
   IF ( s == "2" ) RETURN( "a" ) ENDIF
   IF ( s == "3" ) RETURN( "a" ) ENDIF
   IF ( s == "4" ) RETURN( "a" ) ENDIF
   IF ( s == "5" ) RETURN( "a" ) ENDIF
   IF ( s == "6" ) RETURN( "a" ) ENDIF
   IF ( s == "7" ) RETURN( "a" ) ENDIF
   IF ( s == "8" ) RETURN( "an" ) ENDIF
   IF ( s == "9" ) RETURN( "a" ) ENDIF
   IF ( s == "0" ) RETURN( "a" ) ENDIF
   RETURN( "character currently not known, please adapt this table" )
  END

--- cut here ---------------------------------------------------------

---
---

Internet: see also:

---

Search: Algorithm: Language: Natural: Article: Indefinite: Algorithm 
to insert 'a' or 'an' in text?
http://www.faqts.com/knowledge_base/view.phtml/aid/26340/fid/828

----------------------------------------------------------------------