jhylands

find the word types of a sentence

Jan 25th, 2012
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.14 KB | None | 0 0
  1. Module Module1
  2.  
  3.     Sub Main()
  4.         Dim sentence() As String
  5.         Do
  6.             sentence = Split(Console.ReadLine(), " ")
  7.             For i = 0 To sentence.GetLength(0) - 1
  8.                 sentence(i) = wordtype(sentence(i))
  9.             Next
  10.             Console.WriteLine(Join(sentence, " ") & ".")
  11.         Loop
  12.     End Sub
  13.     Public Function GetPageHTML(ByVal URL As String) As String
  14.         Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(URL)
  15.         Dim response As System.Net.HttpWebResponse = request.GetResponse()
  16.         Dim sr As New System.IO.StreamReader(response.GetResponseStream)
  17.         GetPageHTML = sr.ReadToEnd
  18.     End Function
  19.     Public Function wordtype(ByVal word As String) As String
  20.         Dim type As String
  21.         Dim page As String = GetPageHTML("http://dictionary.reference.com/browse/" & word)
  22.         type = Mid(page, InStr(page, "<span class=" & Chr(34) & "pg" & Chr(34) & ">") + 17)
  23.         type = Mid(type, 1, InStr(type, "<") - 1)
  24.         If InStr(type, ",") <> 0 Then
  25.             type = Mid(type, 1, InStr(type, ",") - 1)
  26.         End If
  27.         wordtype = type
  28.     End Function
  29. End Module
Advertisement
Add Comment
Please, Sign In to add comment