Lingua-NATools

 view release on metacpan or  search on metacpan

lib/Lingua/NATools.pm  view on Meta::CPAN

    $self->{conf}->param("csize"     => $ops->{csize} || 70000);

    if (@langs) {
        $self->{conf}->param("source-language"          => $langs[0]);
        $self->{conf}->param("target-language"          => $langs[1]);
        $self->{conf}->param("noLanguageIdentification" => 1);
    }

    $self->{conf}->write($self->{conf}->param("cfg"));

    return bless $self => $class
}



sub load {
    my ($class, $dir) = @_;

    return undef unless $dir && -d $dir;

    my $self;
    my $conf = catfile $dir, "nat.cnf";

    if (-f $conf) {
        $self->{conf} = Lingua::NATools::Config->new($conf);
        return bless $self => $class;
    }

    print STDERR "Couldn't open config file [$conf]\n";
    return undef;
}

sub _new_logger {
    my ($verbose, $file) = @_;

    $verbose and return sub {

lib/Lingua/NATools/Client.pm  view on Meta::CPAN

=back

=cut

sub new {
  my $class = shift;
  my $self = { PeerAddr => '127.0.0.1',
               PeerPort => '4000',
               Proto    => 'tcp' };

  $self = bless {%$self, @_} => $class;

  $self->{local} = $self->{Local} if (exists($self->{Local}));
  $self->{localDumper} = $self->{LocalDumper} if (exists($self->{LocalDumper}));

  if (exists($self->{local})) {
    Lingua::NATools::corpus_info_open($self->{local});
		$self->{localcfg} = Lingua::NATools->load($self->{local})->{conf};
  }

  if (exists($self->{localDumper})) {

lib/Lingua/NATools/Config.pm  view on Meta::CPAN

            chomp;
            next if m!^\s*$!;
            next if m!^\s*#!;
            next if m!^\[!;
            my ($l,$r) = m!^([^=]+?)\s*=\s*(.*?)\s*$!;
            $self->{$l} = $r;
        }
        close I;
    }

    return bless $self => $class # amen
}

=head2 C<param>

This is the accessor method for any configuration parameter. Pass it
just one argument and you'll get that parameter value. Pass a second
argument and you are setting the parameter value.

   # get value for key "foo"
   $val = $cnf->param("foo");

lib/Lingua/NATools/Corpus.pm  view on Meta::CPAN


sub new {
    my ($class, $filename) = @_;
    die "Corpus.pm, old new called" unless $class eq "Lingua::NATools::Corpus";
    return undef unless -f $filename;

    my $id = Lingua::NATools::corpus_open($filename);
    return undef if $id < 0;

    my $self = {id => $id};
    return bless $self => $class #amen
}

sub sentences_nr {
    my $self = shift;

    if (!$self->{nrsentences}) {
        $self->{nrsentences} = Lingua::NATools::corpus_sentences_nr_xs($self->{id});
    }

    return $self->{nrsentences}

lib/Lingua/NATools/Lexicon.pm  view on Meta::CPAN


=cut

sub new {
    my ($class, $filename) = @_;
    return undef unless -f $filename;

    my $wlid = Lingua::NATools::wlopen($filename);
    return undef if $wlid < 0;

    return bless +{ id => $wlid } => $class # amen
}

=head2 C<save>

This method saves the current lexicon object in the supplied file:

   $lexicon->save("/there/lexicon.lex");

=cut

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.839 second using v1.00-cache-2.02-grep-82fe00e-cpan-503542c4f10 )