Skip to content

Instantly share code, notes, and snippets.

@dallarosa
Created January 17, 2011 20:07
Show Gist options
  • Save dallarosa/783378 to your computer and use it in GitHub Desktop.
Save dallarosa/783378 to your computer and use it in GitHub Desktop.
# encoding: utf-8
$KCODE="U"
require 'ftools'
require 'jcode'
require 'environment.rb' #環境に関する変数
require 'settings.rb' #タスクの設定
require "01morph.rb" #形態素解析のソースファイル
require "02freq.rb" #頻度計算のソースファイル
require "03sort.rb" #ソーティングのソースファイル 
require "04mk_matrix.rb" #行列計算のソースファイル
require "05prcomp.rb" #主成分解析のソースファイル
require "06reg.rb" #回帰解析
class TextAnalysis < Struct.new #テキスト処理のスクリプトのラッパーとなるテキスト処理クラス。
# TODO: 設定ファイルの定数を直接に使うより、インスタンスを作った時そういう設定を読み込んだ方がいいのでは?
def perform
morph_analysis() # 形態素解析を行う
frequency(RANGE, BLOCK, CORE_TERM) # 頻度計算を行う
if(SINGLE==1) # 単独
sort("single") # ソーティング
make_matrix("single", SINGLE_NUM_NODE, SINGLE_MIN_FREQ) #行列計算
prcomp("single") # 主成分解析
reg("single",SAMPLE_PRICE,NUM_VAR) # 回帰解析
end
if(JACCARD==1) #ジャッカード
sort("jaccard")
make_matrix("jaccard", JACCARD_NUM_NODE, JACCARD_MIN_FREQ)
prcomp("jaccard")
reg("jaccard",SAMPLE_PRICE,NUM_VAR)
end
if(COOCUR==1) # 共起
sort("coocur")
make_matrix("coocur", COOCUR_NUM_NODE, COOCUR_MIN_FREQ)
prcomp("coocur")
reg("coocur",SAMPLE_PRICE,NUM_VAR)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment