Class: AnalysisController

Inherits:
ApplicationController show all
Defined in:
app/controllers/analysis_controller.rb

Overview

形態素解析リクエストを処理します。

Instance Method Summary collapse

Instance Method Details

#parsevoid

This method returns an undefined value.

指定されたテキストを MeCab を使用して解析します。

Parameters:

  • text (String)

    解析対象のテキスト (params 経由で渡されます)。



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/analysis_controller.rb', line 9

def parse
  text = params[:text]
  result = MecabParser.execute(text)

  if result.success?
    render json: { payload: result.payload }, status: :ok
  else
    render json: { message: result.error }, status: :internal_server_error
  end
end