Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 159
  • Last Modified:

urgent String logic

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
SCS_SU
Asked:
SCS_SU
  • 3
  • 2
  • 2
  • +1
1 Solution
 
dancebertCommented:
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
 
kirshanCommented:
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
 
coopzzCommented:
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
Independent Software Vendors: 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!

 
kirshanCommented:
thanks I will chk it and let u know results.
thanks


0
 
OHDev2004Commented:
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
 
OHDev2004Commented:
"let's say you want to count the "this is" from a COMBOBOX called "List1" "
sorry i meant Listbox not Combobox :P ...
OHDev
0
 
coopzzCommented:
?¿ so did this help ¿? or Not.
0
 
coopzzCommented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now