How to write perl code to implement letter unigram model? -
i have question solve , need help: implement letter unigram model, learns letter unigram probabilities training data. separate unigram model has learned each language.
apply models determine language each sentence in test file (that is, determine probability associated each sentence in test file, using each of 3 language models).
i have 3 files: first written in english, second written in french, , third written in italian; have test file , need write code determine language each sentence in file belongs.
sub unifreq { my($l,%h)=@_; @words= split / /, $l; $h{"<s>"}++; $h{"</s>"}++; foreach $w(@words){ $h{$w}++; } return %h; } %unienglish; open inp,"<c:\\users\\hanadi\documents\\langid.test."; %unienglish=(); while ($line=<inp>) { chomp($line); %unienglish=unifreq($line,%unienglish); } i wrote code couldn't finish it.
Comments
Post a Comment