home *** CD-ROM | disk | FTP | other *** search
/ What PC? 1996 August / WPCAUG96.ISO / multi / singing / shared.dxr / 01979_PLURALS.ls < prev    next >
Encoding:
Text File  |  1996-06-12  |  2.1 KB  |  118 lines

  1. on phraseLookUp thePhrase
  2.   set result to -1
  3.   repeat while 1
  4.     set result to TryNormal(thePhrase)
  5.     if result > 0 then
  6.       exit repeat
  7.     end if
  8.     set result to tryPlural(thePhrase)
  9.     if result > 0 then
  10.       exit repeat
  11.     end if
  12.     set result to TryPast(thePhrase)
  13.     if result > 0 then
  14.       exit repeat
  15.     end if
  16.     set result to TryItalian(thePhrase)
  17.     if result > 0 then
  18.       exit repeat
  19.     end if
  20.     set result to TryLatin(thePhrase)
  21.     if result > 0 then
  22.       exit repeat
  23.     end if
  24.     delete word 1 of thePhrase
  25.     if the number of words in thePhrase = 0 then
  26.       exit repeat
  27.     end if
  28.   end repeat
  29.   return result
  30. end
  31.  
  32. on TryNormal w
  33.   set try to BinarySearch(w)
  34.   if try > 0 then
  35.     return try
  36.     exit
  37.   end if
  38.   return -1
  39. end
  40.  
  41. on tryPlural w
  42.   if the last char in w = "s" then
  43.     delete char -30000 of w
  44.     put w
  45.     set try to BinarySearch(w)
  46.     if try > 0 then
  47.       return try
  48.       exit
  49.     end if
  50.     if the last char in w = "e" then
  51.       put w
  52.       delete char -30000 of w
  53.       set try to BinarySearch(w)
  54.       if try > 0 then
  55.         return try
  56.         exit
  57.       end if
  58.       if the last char in w = "i" then
  59.         delete char -30000 of w
  60.         set w to w & "y"
  61.         put w
  62.         set try to BinarySearch(w)
  63.         if try > 0 then
  64.           return try
  65.           exit
  66.         end if
  67.       end if
  68.     end if
  69.   end if
  70.   return -1
  71. end
  72.  
  73. on TryPast w
  74.   if the last char in w = "d" then
  75.     delete char -30000 of w
  76.     set try to BinarySearch(w)
  77.     if try > 0 then
  78.       return try
  79.       exit
  80.     end if
  81.     if the last char in w = "e" then
  82.       delete char -30000 of w
  83.       set try to BinarySearch(w)
  84.       if try > 0 then
  85.         return try
  86.         exit
  87.       end if
  88.     end if
  89.   end if
  90.   return -1
  91. end
  92.  
  93. on TryItalian w
  94.   if the last char in w = "i" then
  95.     delete char -30000 of w
  96.     set w to w & "o"
  97.     set try to BinarySearch(w)
  98.     if try > 0 then
  99.       return try
  100.       exit
  101.     end if
  102.   end if
  103.   return -1
  104. end
  105.  
  106. on TryLatin w
  107.   if the last char in w = "a" then
  108.     delete char -30000 of w
  109.     set w to w & "um"
  110.     set try to BinarySearch(w)
  111.     if try > 0 then
  112.       return try
  113.       exit
  114.     end if
  115.   end if
  116.   return -1
  117. end
  118.