Perlを使って表記ゆれ対策(自然言語処理)

WindowsストアからUbuntuをインストールしたらPerlが入っていた。
WindowsでPerlを使いたければ直接インストールするよりも楽だと思う。


Rの「tm」パッケージ「stemDocument」はうまくいかないので自力で。

while(<>){

s/studies/study/ig;
s/mortalities/mortality/ig;
s/therapies/therapy/ig;
s/injuries/injury/ig;
s/nephropathies/nephropathy/ig;

s/kidneys/kidney/ig;
s/diseases/disease/ig;
s/patients/patient/ig;
s/risks/risk/ig;
s/treatments/treatment/ig;
s/groups/group/ig;
s/factors/factor/ig;

s/\b\d+\b//ig;

print;
}
perl stem.pl Absts_0920.txt > post_Absts_0920.txt

補足

「i」オプション

大文字、小文字を区別しない

「g」オプション

繰り返し

エスケープが必要な文字

\ * + . ? { } ( ) [ ] ^ $ - | /