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

Re: Junk NOT words

by davis (Vicar)
on Oct 30, 2002 at 17:27 UTC ( #209158=note: print w/ replies, xml ) Need Help??


in reply to Junk NOT words

Quick, ill-considered node before I dash off home:

Why not measure the letter distribution of the sample being tested. I.e, count the number of 'a's, 'b's and so on. You could then compare the calculated distribution with one appropriate for your language, tables of which could almost certainly be found by googling, and if the actual result is within acceptable bounds, then assume it's ok.

A little further explanation: if the input's random(ish), then the letter distribtion should be fairly close to random (ignoring keyboard patterns). Real, written english (at least) has a much higher proportion of 'e's, 't's, and 's's.

cheers
davis
Is this going out live?
No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist


Comment on Re: Junk NOT words
Re: Re: Junk NOT words
by FamousLongAgo (Friar) on Oct 30, 2002 at 17:56 UTC
    I have had some success using letter pair frequencies as a language identifier for OCR'd text -- letter pair distribution is a much better metric than just letter distribution. Pick out all of the two-letter pairs in your string, and compare the ten most frequent pairs against some pairs you got from analyzing a training text ( just remember to take out the whitespace from the training text first ). If it exceeds some similarity threshold, it is 'real' text, otherwise gibberish.

    For example, my own values for most common letter pairs in English are these:

    English => ['he','th','in','er','an','ou'],

    I have found that a better than 50% match is a pretty reliable indicator

    Be aware that the path you are going down quickly leads to AI-complete problems in natural language processing. This is another one of those programming tasks that seems very easy until you try to do it on real data.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://209158]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2014-12-26 14:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls