Update 2:

Here is a first simple solution. Anybody needs a starting point:

#!/usr/bin/env perl use strict; use warnings; use feature qw(say); use Data::Dump; use Lingua::Stem qw(stem); undef $/; my $text = <DATA>; say $text; $text = lc $text; $text =~ s/\n+/ /g; say $text; $text =~ s/[:;'!?.,]+//g; say $text; my @words = split / /, $text; dd \@words; Lingua::Stem::set_locale('de'); say Lingua::Stem::get_locale; my $stems = stem(@words); dd $stems; my %vocabulary = map {$_ => 1} @$stems; dd \%vocabulary; say scalar keys %vocabulary; __DATA__ Ich Bin Der Geist, Der Stets Verneint! Und Das Mit Recht; denn alles, was entsteht, Ist wert, daß es zugrunde geht; Drum besser wär's, daß nichts entstünde. So ist denn alles, was ihr Sünde, Zerstörung, kurz, das Böse nennt, Mein eigentliches Element.

It isn't so easy as one might think: Simply counting the words with wc doesn't return the vocabulary. And Lingua::Stem thinks that Ist and ist are different stems for example. And how to filter out the real text from sources which contain a preface, index, bla? And so on.

Some may ask why i waste my time with this issue. It has to do with politics. As this isn't a forum about politics i skip the details.

I was a little bit inspired by what Jill Lepore analogously wrote about facts in her splendid book These Truths: A History of the United States about facts: "Show me yours and i'll show you mine." Basically the same game that we played with our cousins when we were nasty little boys. Discussion later.

«The Crux of the Biscuit is the Apostrophe»


In reply to Re: How to count the vocabulary of an author? by karlgoethebier
in thread How to count the vocabulary of an author? by karlgoethebier

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.