Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I'm starting to work on a rather big project, which involves converting some 18.000 HTML documents of sometimes dubious quality to w3.org-validatable, accessible HTML 4.01. The client is a city government in Austria that wants to / has to comply to Level A of the W3 WAI specifications. (http://www.w3.org/WAI/). Most of this work will be done by a HTML::Parser based parser.

Currently, the most tricky part seems to be language detection, and therefor I seek some wisdom:

The content is basically in German. But it is interspersed with some foreign words, mostly English. E.g.: "email". All foreign words should be marked using something like <span lang='en'>. The reason for this is that browsers with voice output need to know if a word should be pronounced the standard way (i.e. german) or somewhat differently (i.e. english)

E.g: if you pronounce "email" as if it was a german word, it sounds like the german word for "enamel", which is "Email" (btw, enamel is this stuff: http://www.artlex.com/ArtLex/e/enamel.html

So, how can I decide if a given word is German, English, French or Italian?

My best idea so far is to find some dictionary files for each language and check if the word is in one of those. For performance reasons, I'm planning to put the dicts into a SQL-Database (or maybe a DB-file? - but I know SQL better, so..) and maybe implement some caching.

I couldn't find anything suited for this task on CPAN ..

I can probably also use some sort of non-Perl solution, as long as it's free and runs on Linux.

Any pointers/comments about

  • some useful software/libraries
  • my general approach
would be very appreciated.
-- #!/usr/bin/perl for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}

In reply to detecting the language of a word? by domm

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (7)
    As of 2014-09-21 22:15 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (176 votes), past polls