<commit_before>package MediaWords::Controller::Api::V2::Wc;
use Modern::Perl "2013";
use MediaWords::CommonLibs;

use MediaWords::DBI::StorySubsets;
use MediaWords::Controller::Api::V2::MC_Action_REST;
use strict;
use warnings;
use base 'Catalyst::Controller';
use JSON;
use List::Util qw(first max maxstr min minstr reduce shuffle sum);
use Moose;
use namespace::autoclean;
use List::Compare;
use Carp;
use MediaWords::Solr;

=head1 NAME

MediaWords::Controller::Media - Catalyst Controller

=head1 DESCRIPTION

Catalyst Controller.

=head1 METHODS

=cut

=head2 index 

=cut

BEGIN { extends 'MediaWords::Controller::Api::V2::MC_Controller_REST' }

use MediaWords::Tagger;

sub list : Local : ActionClass('+MediaWords::Controller::Api::V2::MC_Action_REST')
{
}

sub list_GET : Local : PathPrefix( '/api' )
{
    my ( $self, $c ) = @_;

    my $q  = $c->req->parameters->{ 'q' };
    my $fq = $c->req->parameters->{ 'fq' };
    my $l  = $c->req->parameters->{ 'l' };
    
    # no remote parameter prevents loop of server calling itself via MediaWords::Solr::WordCounts::_get_remote_word_counts
    my $nr = $c->req->parameters->{ 'nr' };

    my $languages = [ split( /\W/, $l )  ];

    my $words = MediaWords::Solr::count_words( $q, $fq, $languages, $nr );

    $self->status_ok( $c, entity => $words );
}

1;<commit_msg>fix undef error for l param<commit_after>package MediaWords::Controller::Api::V2::Wc;
use Modern::Perl "2013";
use MediaWords::CommonLibs;

use MediaWords::DBI::StorySubsets;
use MediaWords::Controller::Api::V2::MC_Action_REST;
use strict;
use warnings;
use base 'Catalyst::Controller';
use JSON;
use List::Util qw(first max maxstr min minstr reduce shuffle sum);
use Moose;
use namespace::autoclean;
use List::Compare;
use Carp;
use MediaWords::Solr;

=head1 NAME

MediaWords::Controller::Media - Catalyst Controller

=head1 DESCRIPTION

Catalyst Controller.

=head1 METHODS

=cut

=head2 index 

=cut

BEGIN { extends 'MediaWords::Controller::Api::V2::MC_Controller_REST' }

use MediaWords::Tagger;

sub list : Local : ActionClass('+MediaWords::Controller::Api::V2::MC_Action_REST')
{
}

sub list_GET : Local : PathPrefix( '/api' )
{
    my ( $self, $c ) = @_;

    my $q  = $c->req->parameters->{ 'q' };
    my $fq = $c->req->parameters->{ 'fq' };
    my $l  = $c->req->parameters->{ 'l' } || '';

    # no remote parameter prevents loop of server calling itself via MediaWords::Solr::WordCounts::_get_remote_word_counts
    my $nr = $c->req->parameters->{ 'nr' };

    my $languages = [ split( /\W/, $l ) ];

    my $words = MediaWords::Solr::count_words( $q, $fq, $languages, $nr );

    $self->status_ok( $c, entity => $words );
}

1;
{'fraction_non_alphanumeric': 0.16810506566604128, 'fraction_numerical': 0.00975609756097561, 'mean_word_length': 4.758099352051836, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4213699', 'n_tokens_mistral': 1017, 'n_tokens_neox': 941, 'n_words': 236}