<commit_before>#

require 'grape'
require 'okura/serializer'

module OkuraWeb
  OKURA_DICDIR = './app/okura-dic'

  class API < Grape::API
    prefix 'okura'
    format :json
    default_format :json

    helpers do
      def tagger
        @tagger ||= Okura::Serializer::FormatInfo.create_tagger OKURA_DICDIR
      end
    end

    resource :morph do
      post do
        return [] unless params[:text]
        nodes = tagger.parse params[:text]
        a = []
        nodes.mincost_path.map do |node|
          word = node.word
          {:surface => "#{word.surface}",
           :text => "#{word.left.text.split /,/}"}
        end
      end
    end

    resource :wakati do
      post do
        return [] unless params[:text]
        tagger.wakati params[:text]
      end
    end
  end

end

# EOF<commit_msg>eliminate unused var and reformat.<commit_after>#

require 'grape'
require 'okura/serializer'

module OkuraWeb
  OKURA_DICDIR = './app/okura-dic'

  class API < Grape::API
    prefix 'okura'
    format :json
    default_format :json

    helpers do
      def tagger
        @tagger ||= Okura::Serializer::FormatInfo.create_tagger OKURA_DICDIR
      end
    end

    resource :morph do
      post do
        s = params[:text]
        return [] unless s
        nodes = tagger.parse params[:text]
        nodes.mincost_path.map do |node|
          word = node.word
          {surface: "#{word.surface}", text: "#{word.left.text.split /,/}"}
        end
      end
    end

    resource :wakati do
      post do
        return [] unless params[:text]
        tagger.wakati params[:text]
      end
    end
  end

end

# EOF
{'fraction_non_alphanumeric': 0.10593998775260258, 'fraction_numerical': 0.0, 'mean_word_length': 1.998165137614679, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2161081', 'n_tokens_mistral': 550, 'n_tokens_neox': 539, 'n_words': 136}