Imports System
Imports System.Collections.Generic
Imports System.Linq
' A stopwords list is a collection of commonly used words in a language
' that are often removed during text processing tasks.
Class StopwordRemover
Private Shared ReadOnly stopWords As HashSet(Of String) = New HashSet(Of String) From {
"i", "me", "my", "myself", "we", "our", "ours", "ourselves", "you", "your",
"yours", "yourself", "yourselves", "he", "him", "his", "himself", "she",
"her", "hers", "herself", "it", "its", "itself", "they", "them", "their",
"theirs", "themselves", "what", "which", "who", "whom", "this", "that",
"these", "those", "am", "is", "are", "was", "were", "be", "been", "being",
"have", "has", "had", "having", "do", "does", "did", "doing", "a", "an",
"the", "and", "but", "if", "or", "because", "as", "until", "while", "of",
"at", "by", "for", "with", "about", "against", "between", "into", "through",
"to", "from", "in", "out", "on", "off", "over", "further", "then", "here",
"there", "when", "where", "why", "how", "all", "any", "both", "each", "few",
"more", "most", "other", "some", "such", "no", "nor", "not", "only", "own",
"so", "than", "too", "very", "can", "will", "just", "don", "should", "now"
}
Private Shared Function RemoveStopWords(ByVal words As List(Of String)) As String
Return String.Join(" ", words.Where(Function(word) Not stopWords.Contains(word)))
End Function
Private Shared Function SplitWords(ByVal input As String) As List(Of String)
Return input.Trim().Split({" "c}, StringSplitOptions.RemoveEmptyEntries).ToList()
End Function
Public Shared Sub Main()
Dim input As String = "a vb.net and java to python a we if c# then a and aa"
Console.WriteLine("Original: " & input)
Dim words As List(Of String) = SplitWords(input)
Dim filtered As String = RemoveStopWords(words)
Console.WriteLine("Filtered: " & filtered)
End Sub
End Class
' run:
'
' Original: a vb.net and java to python a we if c# then a and aa
' Filtered: vb.net java python c# aa
'