At 8:16 PM +0900 1/2/2000, Nicolas R Cueto wrote:
>Hello.
>
>When a user clicks on a word in a sentence (not a cr-line but a
>grammatical sentence), how could I find out the number of that sentence?
>I'd like to create sound files for each of the sentences in a paragraph,
>and then label each sound file with a corresponding number. For example,
>I'd want sound file "2.au" to be played when the user clicks anywhere
>within the second sentence of this paragraph:
>
>This is the first sentence. "However this," she said,
>"is the second sentence." Is this, then, the third sentence?
>
>I've consulted clickChunk, clickChar, etc., and thought about playing
>with the itemDelimiter (there's no such thing as a lineDelimiter, is
>there?) but can't figure out anything, elegant or ugly.
>
Hi Nicolas
Some sweat and tears are needed I think.
I'm sure there's no way to accurately identify an English sentence
through a script unless you can doctor your text in some way with
your own delimeters. (Double spaces between sentences and only
between sentences, for example.)
Failing that, I think you will have to manually record the character
positions of the ends (and possibly starts if not all text in the
field is linked to a sound) of all the sentences. You could then
store these positions, one per line, in a custom property and have a
parallel custom property that stores a reference to the corresponding
sound. Then use the clickChunk to get the clicked character position,
and run down the custom property until you find the first stored
position higher than the clicked character. Then play the
corresponding sound.
Possible gotcha: If memory serves correctly, a click on a space
between words does not return the character position of the space. (I
think it returns char 0 to 0, or something like that.) To include
clicking on spaces, you need to apply the group style to all the text
in the sentence (more work). The clickChunk then returns the entire
group. If you do this, be sure the space between sentences does not
have the group style applied, otherwise the clickchunk will return
the same wherever you click.
If you have a lot to do, it may be worth making a little tool that
automates this a little. For example, select the sentence, click a
button that records the relevant chracter positions and sets the
group style all in one go.
Hope that helps some.
Cheers
Dave Cragg
_____________________________________________
The LACS Centre (Business English Training Resources)
29 Falcon Gardens (1F2), Edinburgh EH10 4AR, UK
Tel/fax +44 131 466 5227
mailto:[EMAIL PROTECTED]
http://www.lacscentre.co.uk
_____________________________________________
This is the MetaCard mailing list.
Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm