The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Text::Guess::Script - Guess script from text using ISO-15924 codes

Text-Guess-Script Coverage Status Kwalitee Score CPAN version

SYNOPSIS

  use Text::Guess::Script;
  print Text::Guess::Script->guess('Hello World'); # prints Latn

  print Text::Guess::Script->guesses('Hello World')->[0]->[0]; # Latn
  print Text::Guess::Script->guesses('Hello World')->[0]->[2]; # Latin

  print Text::Guess::Script->guesses('Hello World')->[1]->[0]; # Zyyy
  print Text::Guess::Script->guesses('Hello World')->[1]->[2]; # Common

  use Data::Dumper;
  print Dumper(Text::Guess::Script->guesses('Hello World'));
  $VAR1 = [
          [
            'Latn',
            '0.909090909090909',
            'Latin'
          ],
          [
            'Zyyy',
            '0.0909090909090909',
            'Common'
          ]
        ];

DESCRIPTION

Text::Guess::Script gets the script property for each character in the text and returns the code of the script with the most characters.

CONSTRUCTOR

new()

Creates a new object which maintains internal storage areas for the Text::Guess::Script computation. Use one of these per concurrent Text::Guess::Script->guess() call.

METHODS

guess($text)

Returns the script code with the most characters.

guesses($text)

Returns an array reference with an array, sorted descending by relative frequency for each script. Each entry is a triple of script code, relative frequency and script name:

  $guesses = [
    [ 'Latn', '0.909090909090909',  'Latin'  ],
    [ 'Zyyy', '0.0909090909090909', 'Common' ],
  ];

EXPORT

None by design.

STABILITY

Until release of version 1.00 the included methods, names of methods and their interfaces are subject to change.

Beginning with version 1.00 the specification will be stable, i.e. not changed between major versions.

SOURCE REPOSITORY

http://github.com/wollmers/Text-Guess-Script

AUTHOR

Helmut Wollmersdorfer <helmut@wollmersdorfer.at>

Kwalitee Score

COPYRIGHT

Copyright 2016-2021 Helmut Wollmersdorfer

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Locale::Codes::Script