Guest
Private paste!

PhraseCount

By: a guest | May 1st, 2010 | Syntax: VB.NET | Size: 0.99 KB | Hits: 108 | Expires: Never
Copy text to clipboard
  1. Imports System
  2. Imports System.Collections.Generic
  3. Imports System.Text
  4.  
  5. Namespace BayesClassifier
  6.  
  7.     Public Class ExcludedWords
  8.         Shared enu_most_common As String() = {"the", "to", "and", "a", "an", "in", _
  9.          "is", "it", "you", "that", "was", "for", _
  10.          "on", "are", "with", "as", "be", "been", _
  11.          "at", "one", "have", "this", "what", "which"}
  12.         Private m_Dict As Dictionary(Of String, Integer)
  13.         Public Sub New()
  14.             m_Dict = New Dictionary(Of String, Integer)()
  15.         End Sub
  16.         Public Sub InitDefault()
  17.             Init(enu_most_common)
  18.         End Sub
  19.         Public Sub Init(ByVal excluded As String())
  20.             m_Dict.Clear()
  21.             For i As Integer = 0 To excluded.Length - 1
  22.                 m_Dict.Add(excluded(i), i)
  23.             Next
  24.         End Sub
  25.         Public Function IsExcluded(ByVal word As String) As Boolean
  26.             Return m_Dict.ContainsKey(word)
  27.         End Function
  28.     End Class
  29.  
  30. End Namespace