=begin comment
#==============================================================================
#
#   Classification Workflows Russian DSL actions in Raku (Perl 6)
#   Copyright (C) 2020  Anton Antonov
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
#   Written by Anton Antonov,
#   ʇǝu˙ɐʇɐpopuǝɔɔɐ@ǝqnɔuouoʇuɐ,
#   Windermere, Florida, USA.
#
#==============================================================================
#
#   For more details about Raku (Perl6) see https://raku.org/ .
#
#==============================================================================
=end comment

use DSL::Entity::MachineLearning::Actions::WL::System;

class DSL::English::ClassificationWorkflows::Actions::Russian::Standard
        is DSL::Entity::MachineLearning::Actions::WL::System {

    # Top
    method TOP($/) { make $/.values[0].made; }

    # workflow-command-list
    method workflow-commands-list($/) { make $/.values>>.made.join(";\n"); }

    # workflow-command
    method workflow-command($/) { make $/.values[0].made; }

	# Load data
	method data-load-command($/) { make $/.values[0].made; }
	method load-data-table($/) { make 'загрузить данные: ' ~ $<data-location-spec>.made; }
	method data-location-spec($/) { make '\"' ~ $/.Str ~ '\"'; }
	method use-data-table($/) { make 'использовать данные: ' ~ $<variable-name>.made; }

    # Split command
	method split-data-command($/) { make $/.values[0].made; }
    method split-data-simple($/) {
        if $<split-fraction> {
          make 'разделить данные на пропорцию ' ~ $<split-fraction>.made;
        } else {
          make 'разделить данные на пропорцию 0.75';
        }
    }

    method split-data-spec($/) { make 'разделить данные с ' ~ $<split-data-element-list>.made; }

    method split-data-element-list($/) { make $<split-data-element>>>.made.join(', '); }
    method split-data-element($/) { make $/.values[0].made; }

    method split-training-fraction($/)   { make 'тренировочная часть ' ~ $<number-value>.made; }
    method split-validation-fraction($/) { make 'валидационная часть ' ~ $<number-value>.made; }
    method split-method($/) {
        if $<proportional-adjective> {
            make 'метод пропорционального деления';
        } else {
            make 'метод случайного разделения';
        }
    }
    method split-class-label-column($/) { make 'колонка с метками ' ~ $<variable-name>.made; }

    # Data summary command
    method data-summary-command($/) { make $/.values[0].made; }
    method data-summary-simple($/){ make 'сводка данных'; }

    # Reduce dimension command
    method dimension-reduction-command($/) { make $/.values[0].made; }
    method dimension-reduction-simple($/){ make 'уменьшить размерность'; }

    # Make classifier command
    method make-classifier-command($/) { make $/.values[0].made; }
    method make-classifier-simple-command($/){
        if $<classifier-method-spec> {
            make 'обучить классификатор методом: ' ~ $<classifier-method-spec>.Str;
        } else {
            make 'обучить классификатор';
        }
    }
    method classifier-method-spec($/) { make $/.values[0].made; }

    # Classifier info command
    method classifier-info-command($/) { make $/.values[0].made; }
    method classifier-info-simple($/){ make 'показать информацию о классификаторе'; }

    # Classifier measurements command
    method classifier-measurements-command($/) { make $/.values[0].made; }
    method classifier-measurements-simple($/){ make 'показать метрики классификатора'; }

    # Classifier testing command
    method classifier-testing-command($/) { make $/.values[0].made; }
    method classifier-testing-simple($/) {
        make 'показать показатели класификатора';
    }
    method accuracies-by-variable-shuffling($/) { make 'найти показатели точности, перетасовывая переменные'; }
    method test-results($/) {
        if $<test-measures-list> && $<test-classification-threshold> {
            make "вычислить точность классификатора {$<test-measures-list>.made.join(',')} используя пороговое значение{$<test-classification-threshold>.made}";
        } elsif $<test-classification-threshold> {
            make "вычислить точность классификатора, используя пороговое значение {$<test-classification-threshold>.made}";
        } elsif $<test-measures-list> {
            make "вычислить следующие показатели классификатора: {$<test-measures-list>.made.join(',')}";
        } else {
            make "вычислить показатели классификатора";
        }
    }
    method test-classification-threshold($/){
        make $<class-label>.made ~ ' -> ' ~ $<threshold>.made;
    }
    method test-measures-list($/) {
        make $<entity-classifier-measurement-name>>>.made.join(', ');
    }

    # ROC plots command
    method roc-plots-command($/) { make $/.values[0].made; }
    method roc-curves-command($/) { make $/.values[0].made; }
    method roc-curves-simple($/){ make 'показать диаграмму рабочих характеристик приемника (RХП)'; }
    method roc-diagrams-command($/){ make 'показать диаграмму рабочих характеристик приемника (RХП)'; }

    ## Setup code
    method setup-code-command($/) {
        make 'SETUPCODE' => '';
    }
}
