This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach $i (keys %WikiDic) { #等しいハッシュ値を探す | |
if ($length == $i) { #同じハッシュが存在した | |
foreach $j (@{$WikiDic{"$i"}}) { | |
if ($title eq $j) { #同じタイトル名が存在した | |
$check =0; #追加せずに離脱 | |
last; | |
} | |
} | |
if ($check) { #ハッシュ内に対応する文字列は無かった |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for ($i =0; $i < @$lineList; $i++) { | |
foreach $list (@attr) { #示唆単語それぞれについて | |
$j =1; #ベクトル未追加フラグ | |
foreach $line (@{$list}) { | |
if ($$lineList[$i] =~ /$line/) { | |
push @{$vector[$i]}, 1; | |
$j =0; | |
last; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for ($i =0; $i < $K; $i++) { #遷移確率を求める | |
for ($j =0; $j < $K; $j++) { | |
$t0 =0; | |
$t1 =0; | |
for ($u =0; $u < @state -1; $u++) { #個数を数える | |
if ($state[$u] == $i) { | |
$t0++; | |
if ($state[$u +1] == $j) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#隠れ状態から属性を推定する | |
for ($i =0; $i < $K; $i++) { #状態0から順に処理 | |
@attr = (0, 0, 0, 0); #各行の示唆ベクトルを足し合わせていく | |
$t0 =0; | |
for ($j =0; $j < @$lineList; $j++) { | |
if ($state[$j] == $i) { | |
$t0++; #推定状態の数 | |
for ($u =0; $u < @attr; $u++) { #対応するベクトルの要素を足す |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for ($i =1; $i < @$lineList; $i++) { | |
if (${$trans[$state[$i -1]]}[$state[$i]] <0.4) { #遷移確率が低かったら修正 | |
if ($pk[$state[$i -1]] <0.4) { #遷移前の出現確率も低かったら修正 | |
for ($j =0; $j < @{$vector[$i]}; $j++) { | |
if ((${$vector[$i]}[$j]) && ($j != $stateAttr[$state[$i -1]] -1)) { | |
push @estAttr, $j +1; | |
last; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub chromHMM { | |
@lineList = @{$_[0]}; | |
$alpha = 0.02; | |
$K = 5; #分ける状態数 | |
for ($i =0; $i < @lineList; $i++) { | |
foreach $list (@attr) { #示唆単語それぞれについて | |
$j =1; #ベクトル未追加フラグ | |
foreach $line (@{$list}) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open ATTR, "<attribute.txt" or die "open: $!"; | |
@attr = (); | |
$i =0; | |
while ($line = <ATTR>) { #属性示唆単語読込み | |
if ($line =~ /^#/) { | |
next; | |
} | |
elsif ($line eq "\n") { | |
$i++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@vector.each_with_index do |attrVector, i| | |
attrVector.each do |line| #属性ごとに行を呼び出す | |
chunkFeasible.each do |chunk, value| | |
if line[0] =~ /#{chunk}/ && !chunkTemp[i].include?(chunk) | |
chunkTemp[i][chunk] = value #行にチャンクが含まれて、そのチャンクがまだ存在していなければ追加 | |
end | |
end | |
end | |
end | |
#作成された新チャンクリストの内容検証 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
from pylab import * | |
def XDiff(x, y, a): | |
return -a * x + y #Griffithモデル | |
def YDiff(x, y, b): | |
return x **2/ (1.0+ x **2) - b * y | |
def XNull(x, a): #xヌルクライン |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
from pylab import * | |
def XDiff(x, y, a): | |
return -x + a * y + y * x **2 #Sel'kovモデル | |
def YDiff(x, y, a, b): | |
return b - a * y - y * x **2 | |
def XNull(x, a): #xヌルクライン |
OlderNewer