2011-12-30 4 views
0

나는 이안 바버 스 Naive Bayes 분석 클래스를 사용하여 학교 프로젝트에 대한 문장의 감정을 분석합니다. 내 자신의 긍정 중성 및 네거티브 데이터 세트를 만들었습니다. 내 문제는 중립적 인 것들을 구현하고 그것을 발견 할 수있는 수업을받는 방법에 대한 단서가 없다는 것입니다. 아래의 링크는 내가 그럼 Opinion 클래스는 이미 새로운 "감정 클래스"를 추가하기위한 매우 유연Naive Bayes Neutrals 확인하기 PHP

http://phpir.com/bayesian-opinion-mining

답변

2

을 사용하고있는 PHP 클래스입니다. classify 메서드는 "이전"정적 계산을 구현했습니다. 그러나 쉽게 대체 할 수 있습니다 foreach :

private $classes = array('pos', 'neg', 'neutr'); 
private $classTokCounts = array('pos' => 0, 'neg' => 0, 'neutr' => 0); 
private $classDocCounts = array('pos' => 0, 'neg' => 0, 'neutr' => 0); 
private $prior = array('pos' => 1.0/3.0, 'neg' => 1.0/3.0, 'neutr' => 1.0/3.0); 

public function classify($document) { 
    // remove those: 
    //$this->prior['pos'] = $this->classDocCounts['pos']/$this->docCount; 
    //$this->prior['neg'] = $this->classDocCounts['neg']/$this->docCount; 
    // add this: 
    foreach($this->classes as $class) { 
     $this->prior[$class] = $this->classDocCounts[$class]/$this->docCount; 
    } 

    // the rest is fine 
+0

그 덕분에! –

관련 문제