?
Solved

urgent String logic

Posted on 2004-08-26
11
Medium Priority
?
157 Views
Last Modified: 2010-05-02
Hi
In Sapi 5.1 I m dealing with two events

Private Sub RecoContext_Hypothesis(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal Result As SpeechLib.ISpeechRecoResult)

and return a string
list1.additem  = Result.PhraseInfo.GetText

it runs many time and as in end I want to know how many items are in list group by same items
for example

this is
this is simple
this is
this is soft
this is simple
this is simple

and results must be like this

this is 2 times
this is simple 3 times
this is soft 1 time
and over all same word like
this 6 times
is 6 times
this is 6 times

plz take some time to solve this.
I tried many ways but can not
thanks

 
0
Comment
Question by:SCS_SU
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
11 Comments
 
LVL 9

Expert Comment

by:dancebert
ID: 11908454
create a collection.  For each phrase (e.g. "this is"), check to see if there is a member already in the collection with the phrase as the key.  If it's already there, increment the member by one.  If it's not there, add a new member and set it's value to one.

To determine the count for the individual words, do the same thing as above for each word instead of each phrase.
0
 

Expert Comment

by:kirshan
ID: 11908512
can  u plz write codes
I got u but today due to lot of work I can not code these.
I tried but can not and I need solution as soon as posible to move other sides.

plz
thanks
0
 
LVL 11

Accepted Solution

by:
coopzz earned 120 total points
ID: 11909704
Option Explicit

'you'll need a reference to Microsoft Scripting Runtime
Private m_oColl As Scripting.Dictionary

Private Sub Command1_Click()
    Randomize
    Dim sNew As String
    Select Case (Int((5 - 1 + 1) * Rnd + 1))
        Case 1: sNew = "this is"
        Case 2: sNew = "this was"
        Case 3: sNew = "this can be"
        Case 4: sNew = "this saw"
        Case 5: sNew = "this believed"
    End Select
   
    Dim n As Integer
    If (m_oColl.Exists(sNew)) Then
        m_oColl.Item(sNew) = m_oColl.Item(sNew) + 1
    Else
        m_oColl.Add sNew, 1
    End If
   
    displayResult
End Sub

Private Sub displayResult()
    Dim i As Variant
    List1.Clear
    For Each i In m_oColl
        List1.AddItem i & ": " & m_oColl.Item(i) & " times"
    Next i
End Sub

Private Sub Form_Load()
    Set m_oColl = New Scripting.Dictionary
End Sub

Hope it helps..
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Expert Comment

by:kirshan
ID: 11911134
thanks I will chk it and let u know results.
thanks


0
 
LVL 7

Expert Comment

by:OHDev2004
ID: 11918597
why not using the Precios "Instr" function :P

here's How:
'=========================================
Private Function CountItems (StringtoFind as String , ListtoSearch as Listbox) as Long
Dim Xloop as Long
For Xloop = 0 to ListtoSearch.Listcount - 1
If Instr (1, ListtoSearch.List(Xloop), StringtoFind) <> 0 Then CountItems = CountItems + 1
Next Xloop
End Function
'=========================================

and now to test the Function :
let's say you want to count the "this is" from a Combobox called "List1"
msgbox CountItems("this is", List1)

Cheers
OHDev
0
 
LVL 7

Expert Comment

by:OHDev2004
ID: 11918600
"let's say you want to count the "this is" from a COMBOBOX called "List1" "
sorry i meant Listbox not Combobox :P ...
OHDev
0
 
LVL 11

Expert Comment

by:coopzz
ID: 12295629
?¿ so did this help ¿? or Not.
0
 
LVL 11

Expert Comment

by:coopzz
ID: 12519444
I think my comment deserved some of the points.. it did give a solution after some code was asked for.

but if you read the whole it's a bit strange how it started with scs_su then was getting author type comments from krishan  hmmm...
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question