concordance of RR stack

J. Landman Gay jacque at hyperactivesw.com
Mon Feb 23 21:05:34 EST 2004


On 2/23/04 5:20 PM, n.thieberger at linguistics.unimelb.edu.au wrote:

> I am writing to ask if anyone has built, or is interested  in buidling, 
> a concordance tool for RR. I have a tool (called Audiamus) built in RR 
> that links a set of transcripts to their media at the sentence level. I 
> would very much like to have a concordance of the transcripts, but have 
> no idea how to create a concordance that works as  quickly and neatly as 
> FreeText did.

There is a script offered in the MetaCard IDE that does part of what I 
think you want, and is very fast. A little modification and you'd be set.

on mouseUp
   put empty into field "result"
   answer file "Select a text file for input:"
   if it is empty then exit mouseUp
# let user know we're working on it
   set the cursor to watch
   put it into inputFile
   open file inputFile for read
   read from file inputFile until eof
   put it into fileContent
   close file inputFile
# wordCount is an associative array, its indexes are words
# with the contents of each element being number of times
# that word appears
   repeat for each word w in fileContent
     add 1 to wordCount[w]
   end repeat
# copy all the indexes that is in the wordCount associative array
   put keys(wordCount) into keyWords
# sort the indexes -- keyWords contains a list of elements in array
   sort keyWords
   repeat for each line l in keyWords
     put l & tab & wordCount[l] & return after displayResult
   end repeat
   put displayResult into field "result"
end mouseUp


Instead of adding 1 to each instance of the word, you could collect a 
word count reference or whatever data you want, and collect that info in 
the array. In the repeat loop, use something like this:

  put 0 into theWordNum
  repeat for each word w in fileContent
     add 1 to theWordNum
     put comma & theWordNum after wordCount[w]
  end repeat

This would give you a list of words containing a comma-delimited list of 
numerical references for each word.


-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the use-livecode mailing list