MsOf03 Macro to write Cloze Text-VBForums
Results 1 to 10 of 10

Thread: Macro to write Cloze Text

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    5

    Macro to write Cloze Text

    I teach English as a foreign language and would like to use flash cards with "cloze" sentences (sentences with key words missing) to help my students learn their phrasal verbs.

    For example, to help them learn the phrasal verb "take on" I might give them a flash card with this "cloze" sentence on one side of the card:

    The school offered him a great opportunity but he _____ the project __ knowing far too little about VBA.
    and the answer on the other side of the card:

    The school offered him a great opportunity but he took the project on knowing far too little about VBA.

    While this is actually not a great cloze sentence, it does illustrate what I need to accomplish and also nicely describes my predicament. I have had a fair amount of experience programming but that was long, long ago (Cobol, basic, etc) and I know little about VBA. I'm still comfortable writing programs, however, and was hoping someone on this forum could give me some suggestions/tips.

    At the moment my not-yet-clozed sentences are stored in a word document in the second column of a table, and I have already highlighted the words I would like "clozed" in yellow, eg:

    The school offered him a great opportunity but he took the project on knowing far too little about VBA.

    Note: As you will notice, I have used a red font to indicate where, in Word, I have highlighted the text yellow. This is because I unfortunately can't figure out how to highlight text yellow on this message board!

    My thinking was to add two empty columns to the table and then write a macro that would do the following:

    1) For each element in the table, copy the text in the 2nd Column to the 3rd Column.

    2) Search the text in the 3rd Column, finding any and all words that are highlighted yellow and surrounding them with the html code necessary to produce a yellow highlight. The text in the 3rd column would end up looking something like this (I don't know very much about html either):

    The school offered him a great opportunity but he <span style="color:#ffff00;">took</span> the project <span style="color:#ffff00;">on</span> knowing far too little about VBA.

    3) Copy the text in the 3rd Column to the 4th column, this time finding any and all words that are highlighted yellow and replacing each non-space character with an underscore. The text in the 4th column would end up looking something like this:

    The school offered him a great opportunity but he <span style="color:#ffff00;">____</span> the project <span style="color:#ffff00;">__</span> knowing far too little about VBA.

    After this I could convert the table to text, save the file as *.txt and transfer it to my flash card program.

    Any suggestions you might have to actually code this would be greatly appreciated.

    Thanks,

    Trip





  2. #2
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,197

    Re: Macro to write Cloze Text

    I have previously written a large number of such educational programs and there are ,as always, a large number of ways to do this.

    so questions are :

    Do you print these flash cards or display then on an intranet or computer based system?
    If they are on a machine do you want them to be interactive?
    Do you want some kind of marking scheme or data collection?

    would you like to discuss any other learner processes or support matterials?

    had you considered simply formatting the words ( more info if needed )

    oh ... what if the flash card program you refer to?

    here to help

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    5

    Re: Macro to write Cloze Text

    Hi Incidentals,

    Thanks so much for your quick reply.

    I'm using Anki for the flash cards and my students will be accessing them via their PCs, MACs, smart phones and/or on-line. (If any of them want hard copy, they can learn another language!)

    Over the years my classes have input more or less the entire Cambridge Dictionary of Phrasal verbs into Word, so all the necessary definitions and example sentences are ready to go. My main concern is getting the text into Anki.

    Although Anki does have a "Cloze" function, the current version cannot handle non-contiguous words, so creating the Cloze sentences on Anki would be a pain. Plus, I'm just more comfortable keeping the primary material in Word and using Anki as a back end.

    The 'problem' is that Anki can only import plain text files (*.txt/UTF-8) so I've got to add the html coding manually. Hence the glossary I described in my first post. But I'm not married to that idea if you think there's a better way.

    Thanks again for your help,

    Trip

  4. #4
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,197

    Re: Macro to write Cloze Text

    I had a quick look and if you need to use html you will need to pad with non-braking spaces or underscores..

    thats a pity because you can do it based on colouring and underline styling...

    anyway nice and easy, really ( famous last words )

    I think you would be better not using word document as storage if possible, the table construct is not the nicest or most predictable thing to play with.

    are you sure that you have identified the cloze candidates?

    do you sent the whole table or just some columns?

  5. #5
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,197

    Re: Macro to write Cloze Text

    i get a copy of anki

    it appears that your file format is cloze,complete,study tag

    is that right?

    can you supply the original document as text with study tag then the system can be built up for you...

    description of how to do it and some code if thats what you need

  6. #6

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    5

    Re: Macro to write Cloze Text

    Anki will automatically take care of almost all of the card layout and formatting. The only html I need to send it is the coding to turn on and off the highlighting on the flash cards:

    [span style="color:#ffff00;"] [/span]

    I've got to specify this coding 'manually' because the staring and ending positions are located at arbitrary points in the middle of each sentence. The trick, I guess, will be getting the coding in the right place :-)

    Is it not possible to seach for a string of characters that are marked with a specific attribute, such as highlighting? I thought this might be easy since seaching for highlighted text is an option in the regular Word Search box. But I could use underlining or another attribute instead if you thought that would be easier.

    I could also take the text out of the table, although that might be painful.

    I will send you a sample document and screen shots of the Anki output.

    Thanks so much for your help.

    Trip

  7. #7
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,197

    Re: Macro to write Cloze Text

    the highlight stuff is connected to each charater and is not findable using normal find and replace.

    i have a code that can make changes based on the highlight colour, but it is painfully slow..

    i am converting you file to different format that will make this a whole lot easier!

    back soon

  8. #8

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    5

    Re: Macro to write Cloze Text

    I'm not sure what you mean by a different format. Would it help if I marked the cloze text with a Word style? I'm at work until late this evening so unfortunately I cannot be of much help until after 9:00. But the project needs to stay in Word.

  9. #9
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,197

    Re: Macro to write Cloze Text

    in word is not the issue its the markup you have used thats the problem... the process begain at earlier today some time around 10 1 suppose and is now about have way through... ther is little milage i using this process as it depends on a very slow solution!

    re-marking the the cloze candidates with a character that will never appear in the text is the best option. I am allowing the process to put [] around the cloze candidate.

    I have looked at the guts of the document the xml part and I think there is a faster way to do the markup and possiblt the final solution.

    But if you transfered the stuff into excell it would be substantially easier for you in the long run (that's what it looks like at present).

    I will get this done later tonight, and we can catch up then.

    here to talk

  10. #10

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    5

    Re: Macro to write Cloze Text

    The characters '[]' already appear in the text so these will not work. In general, the text in the document will be printed out for other purposes so weird non-printing characters are not the best option.

    The project must stay in Word.

    Can you search for a Word style?

    In haste,

    Trip

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.