![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Build a tag list of a database column Hello, I have a column called newstext in an access database. I would like to build a Tag list that consist of most words in a textfile. I would like to count how many times they occur, and maybe how many times they occur in relations to another tag. Do anybody have any tips for how to proceed on this one? -- -- HAL07, Engineering Services, Norway |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Build a tag list of a database column HAL07 wrote: Quote: > Hello, I have a column called newstext in an access database. > > I would like to build a Tag list that consist of most words in a textfile. > I would like to count how many times they occur, and maybe how many times > they occur in relations to another tag. > > Do anybody have any tips for how to proceed on this one? uniqueness. The key value would be the case insensitive word, the item value would be the number of occurrences. Perhaps something similar to: =========== Set objWordList = CreateObject("Scripting.Dictionary") objWordList.CompareMode = vbTextCompare strText = "This is a test consisting of a few lines" _ & vbCrLf & "of words. Words are delimited by spaces," _ & vbCrLf & "punctuation, and carriage returns. There are" _ & vbCrLf & "many possible punctuation marks, so it is" _ & vbCrLf & "important to account for all possibilities." _ & vbCrLf & "The expected result is a count of how many times" _ & vbCrLf & "Each word occurs in the text." ' Create array of lines delimited by carriage returns. arrLines = Split(strText, vbCrLf) ' Enumerate lines. For Each strLine In arrLines ' Remove punctuation. strLine = Replace(strLine, ".", "") strLine = Replace(strLine, ",", "") strLine = Replace(strLine, ";", "") strLine = Replace(strLine, ":", "") strLine = Replace(strLine, "?", "") strLine = Replace(strLine, "-", "") strLine = Replace(strLine, "!", "") ' Create array of words delimited by spaces. arrWords = Split(strLine, " ") ' Enumerate words in the line. For Each strWord In arrWords ' Check if the word has been encountered before. If (objWordList.Exists(strWord) = True) Then ' Increment count for this word by one. objWordList(strWord) = objWordList(strWord) + 1 Else ' Add this word to the dictionary object with a count of one. objWordList(strWord) = 1 End If Next Next ' Enumerate all words and their counts in parentheses. For Each strWord In objWordList.Keys Wscript.Echo strWord & " (" & objWordList(strWord) & ")" Next ======== You might want to make all words lower case. Then you could add: strLine = LCase(strLine) -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Build a tag list of a database column Richard Mueller [MVP] wrote: Quote: > HAL07 wrote: > Quote: >> Hello, I have a column called newstext in an access database. >> >> I would like to build a Tag list that consist of most words in a textfile. >> I would like to count how many times they occur, and maybe how many times >> they occur in relations to another tag. >> >> Do anybody have any tips for how to proceed on this one? > In VBScript I would use a dictionary object. The Exists method ensures > uniqueness. The key value would be the case insensitive word, the item value > would be the number of occurrences. Perhaps something similar to: > =========== > Set objWordList = CreateObject("Scripting.Dictionary") > objWordList.CompareMode = vbTextCompare > > strText = "This is a test consisting of a few lines" _ > & vbCrLf & "of words. Words are delimited by spaces," _ > & vbCrLf & "punctuation, and carriage returns. There are" _ > & vbCrLf & "many possible punctuation marks, so it is" _ > & vbCrLf & "important to account for all possibilities." _ > & vbCrLf & "The expected result is a count of how many times" _ > & vbCrLf & "Each word occurs in the text." > > ' Create array of lines delimited by carriage returns. > arrLines = Split(strText, vbCrLf) > ' Enumerate lines. > For Each strLine In arrLines > ' Remove punctuation. > strLine = Replace(strLine, ".", "") > strLine = Replace(strLine, ",", "") > strLine = Replace(strLine, ";", "") > strLine = Replace(strLine, ":", "") > strLine = Replace(strLine, "?", "") > strLine = Replace(strLine, "-", "") > strLine = Replace(strLine, "!", "") > ' Create array of words delimited by spaces. > arrWords = Split(strLine, " ") > ' Enumerate words in the line. > For Each strWord In arrWords > ' Check if the word has been encountered before. > If (objWordList.Exists(strWord) = True) Then > ' Increment count for this word by one. > objWordList(strWord) = objWordList(strWord) + 1 > Else > ' Add this word to the dictionary object with a count of one. > objWordList(strWord) = 1 > End If > Next > Next > > ' Enumerate all words and their counts in parentheses. > For Each strWord In objWordList.Keys > Wscript.Echo strWord & " (" & objWordList(strWord) & ")" > Next > ======== > You might want to make all words lower case. Then you could add: > > strLine = LCase(strLine) > -- -- HAL07, Engineering Services, Norway |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Wrong Addresses in "To" Column of List Pane | Live Mail | |||
| Is it possible in "computer" to view files from top to bottom in 1st column then same again in next column to the right etc? | Vista file management | |||
| Works database 2007 and Office database 2003 | .NET General | |||
| Vista Build 5744 doesn't want to upgrade build 5536 | Vista installation & setup | |||
| Vista public build 5384, nerds build 5472 | Vista General | |||