Create Word list
Page 1 of 1

Author:  Matze [ 2014-10-15 05:44:33 ]
Post subject:  Create Word list

Hi there nise people,

is there a word list macro, that works with german text in a german version of Nisus Writer?
I need a macro, that counts each word of a document and displays the number of occurences.

Best regards, Matze

Author:  Matze [ 2014-10-15 06:35:12 ]
Post subject:  Re: Create german Word list

Stupid me. I should have read the other Subjects first ...
capvideo has created a Perl-Script, which I just had to translate here and there.

For any german Nisus User, who needs this script as well:

# Get the current document
$document =

# Get all the text (but not headers or tables)
$text = $document.text

# Count them
$words = ''
Begin Perl
   #sort subroutine to sort by frequency in descending order
   sub byFrequency {
      $words{$b} <=> $words{$a};

   #break text into individual words
   @words = $text =~ /(\w+(?:'\w+)*)/g;

   #count each occurence in hash
   foreach $word (@words) {
      #normalize text
      $word = lc($word);
      #increment frequency count for this word

   #sort the words
   @words = keys %words;
   @sortedWords = sort byFrequency @words;

   #construct the frequency table
   foreach $word (@sortedWords) {
      $frequency = $words{$word};
      $words .= "$word:\t$frequency\n";

#create new document with frequency table
$frequency = Document.newWithText $words

#format table
Bearbeiten:Auswählen:Alles Auswählen
Tabelle:In Tabelle konvertieren
Tabelle:An Inhalte anpassen

$emptyEdges = LineAttributes.newInvisible
$table = $frequency.tableSelection
$table.applyLineAttributesToEdges $emptyEdges, "All"

#deselect table
Select Start

A big THANK YOU capvideo!!


Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group