FreeHAL

 view release on metacpan or  search on metacpan

AI/FreeHAL/Engine.pm  view on Meta::CPAN


            #my $type_str =
            #$line == 1 ? 'vt'
            #: $line == 2 ? 'n,'
            #: $line == 3 ? 'adj'
            #: $line == 4 ? 'n,'
            #: $line == 5 ? 'fw'
            #: $line == 6 ? 'prep'
            #: $line == 7 ? 'inter'
            #:              'q';

            $part_of_speech_memory->{$word}->{'type'} = undef
              if $part_of_speech_memory->{$word}->{'type'} eq 'q';

            #if ( $part_of_speech_memory->{$word}->{'type'} eq 'q'
            #|| $part_of_speech_memory->{$word}->{'type'} eq 'nothing' ) {

            #$part_of_speech_memory->{$word}->{'type'} = $type_str;
            #}
            #if ( $part_of_speech_memory->{$word}->{'type'} eq 'q'
            #|| $part_of_speech_memory->{$word}->{'type'} eq 'nothing' ) {

            #$part_of_speech_memory->{$word}->{'type'} = 'perhaps_n';
            #}

            my $type_str = pos_of( $CLIENT_ref, $word );
            my ${is_noun} = ( $type_str == $data->{const}{NOUN} );

            if ( LANGUAGE() eq 'en' ) {
                $part_of_speech_memory->{$word}->{'genus'} ||= q{perhaps_s};
            }
            elsif ( ucfirst $word eq $word || $data->{lang}{is_noun} ) {
                pos_prop( $CLIENT_ref, ucfirst lc $word );
                $part_of_speech_memory->{ lc $word }->{'genus'} ||=
                  $part_of_speech_memory->{ ucfirst lc $word }->{'genus'};
            }
            alarm(0);
        };

        if ( $l % 200 == 0 && $data->{modes}{batch} ) {
            alarm(0);
            upload_memory();
        }

    }
    alarm(0);
    part_of_speech_write( file => $data->{intern}{dir} . 'lang_'
          . LANGUAGE()
          . '/word_types.memory' );
    alarm(0);

    ### tagger end

    # close
    close $source;

    $i = 0;

    my $cpu_limit = 100;

    open my $preferences, '<', '../../global_prefs_override.xml'
      or say "Preferences not found!";
    while ( defined( my $line = <$preferences> ) ) {
        if ( $line =~ /cpu_usage_limit/ ) {
            $line =~ m/[>](.*?)\./;
            $cpu_limit = $1 if $1;
            say $line;
        }
        if ( $line =~ /max_ncpus_pct/ ) {
            $line =~ m/[>](.*?)\./;
            $cpu_limit = $1 if $1;
            say $line;
        }
        say $line;
    }
    close $preferences;

    say "CPU LIMIT: ", $cpu_limit;

    # $cpu_limit /= 2;

    foreach my $key ( keys %lines_to_write ) {
        while ( @{ $lines_to_write{$key} } ) {
            process_template_lines(
                $CLIENT_ref,
                $pro_file,
                \$i,
                $key,
                splice(
                    @{ $lines_to_write{$key} },
                    0,
                    ( -f '/novo.txt' ) ? 40
                    : $cpu_limit < 80  ? $cpu_limit * 2
                    : $data->{modes}{batch}         ? 25000
                    : 500
                )
            );
        }
    }

    if ( time() > $data->{batch}{batch_timeout} && $data->{modes}{batch} ) {
        say "Timeout.";
        exit(0);
    }
    if ($data->{modes}{batch}) {
        open my $target, '<', $pro_file;
        while (<$target>) {
            print STDERR $_;
        }
        close $target;

        open my $prot, '>', $prot_file;

        foreach my $j ( 1 .. 4 ) {
            $ua->timeout(5);

            # Create a request
            my $sock = new IO::Socket::INET(
                PeerAddr => "de.wikipedia.org",
                PeerPort => 80,
                Proto    => 'tcp'



( run in 1.276 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )