Search and Replace

Gary Rathbone gary.rathbone at btclick.com
Tue Oct 15 18:42:01 EDT 2002


Ummm... further to my previous (and rapid) reply, you may also need to look
at other punctuation scenarios bar spaces. Normally there is a space after a
full stop and after a comma. However, it may be that a sentance could be
constructed so that a gender reliant word appears directly before
punctuation
eg "...in order to improve himself." or "...a very talented girl."

I do think that RegEx would be overkill for this scenario and with some
thought on word placement within a sentence a simple series 'find & replace'
would do the trick.

Regards

Gary Rathbone BSc MBCS
Chartered Information Systems Practitioner

-----Original Message-----
From: use-revolution-admin at lists.runrev.com
[mailto:use-revolution-admin at lists.runrev.com]On Behalf Of Dan Friedman
Sent: 15 October 2002 23:41
To: use-revolution at lists.runrev.com
Subject: Search and Replace


Greetings!

I need to switch the gender of some text.  But, I'm having a hard time
figuring out a way to do it.  Obviously I can't do a simple replace because

Replace "HE" with "SHE" in someText

Would turn "HELP" into "SHELP"

I've written this function about a dozen times and it still isn't working
perfectly.  Here's what I have to date:

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

function searchAndReplaceMaleToFemale TextToSearchNReplace
  set the caseSensitive to true
  set the itemDel to ","

  put "He,he,him,Him,himself,HimSelf,his,His,boy,Boy,he's,He's" into
SearchWordsMale
  put "She,she,her,Her,herself,Herself,her,Her,girl,Girl,she's,She's" into
SearchWordsFemale

  put TextToSearchNReplace into TextToSearchNReplace2
  put quote&"!?,.:;[]{}()£$¢%^&¾„÷<>=+-Š³Œ²¡#ƒ§¶*€ªº\/" into tList
  repeat for each char tChar in tList
    replace tChar with space in TextToSearchNReplace2
  end repeat

  repeat with i = the number of words in TextToSearchNReplace2 down to 1
    if word i of TextToSearchNReplace2 is among the items of SearchWordsMale
then
      replace (word i of TextToSearchNReplace2) with (item (itemOffset(word
i of TextToSearchNReplace2,SearchWordsMale)) of SearchWordsFemale) in word i
of TextToSearchNReplace
    end if
  end repeat

  set the caseSensitive to false
  return TextToSearchNReplace
end searchAndReplaceMaleToFemale

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

Anyone got any ideas?

Thank you in advance,
-Dan



If you feel like taking a stab at it... Here's some text to test with:

     The Reading goals for Becky are building comprehension using specific
strategies of [ answering questions, summarizing, and describing (beginning,
middle, end)].  He will be able to use phonics to decode words, show an
increasing his vocabulary, and gain fluency in oral reading. Becky will
strive to be able to read at grade level or above by the end of the year.
     The Mathematics goals for Becky is to know the addition/subtraction
facts, be able to solve word problems, gain a deeper understanding of place
value, and demonstrate a basic understanding of time and money.
     The writing goal for Becky is to write a paragraph using clear and
coherent sentences. Correct use of grammar, capitalization, and punctuation
should increase as the year progresses for him.
        Personal  Goals for Becky are to stay focused and on task  to
complete his work without  adult supervision.   Becky needs to make more
productive use of class time.  He is easily distracted and is often unable
to finish his assignments in class.  I am confident, with practice, Becky
will learn how to use his time wisely.

_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list