Results 1 to 11 of 11

Thread: Word patterns

  1. #1
    Join Date
    Sep 2003
    Location
    London, England
    Posts
    52

    Unanswered: Word patterns

    How would you make a function that returned the pattern of a word?

    If the word was all different letters like MUSIC then f(MUSIC) = 12345 but if there were repeated letters then the numbers would be repeated accordingly so that f(SORROW) = 123324, f(ACROSS) = 123455 and f(ICICLE) = 121234. The function only needs to work for up to 10 different letters in the word, so that f(TRAMPOLINE) = 1234567890 and f(IMPERISHABLE) = 123451678904 but f(PERSONALITY) = #.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    examine some of the phonics based encoding approaches such as Soundex, Double metanome and so on.
    Double Metanome may be a better bet as Soundex was primarily designed for Anglo saxon surnames used in the US bureau of Census,
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Sep 2003
    Location
    London, England
    Posts
    52

    Red face Really?

    Thank you for replying, Healdem, but I don’t think these approaches are related to my question. I am not trying to encrypt my data as such but just to find patterns relating to crossword puzzles.
    Last edited by JLR; 02-08-12 at 08:53. Reason: adding an explanation

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so if those phonics encoding systems don't work then you'd need to write your own function that applied your encoding logic.

    from what you have shown so far I haven't got a clue what your encoding methodology is trying to do beyond obfuscating the underlying data.

    Sindho, IIRC, has already provided an example of you to apply your previous encoding system, it shouldn't be too complex to rewrite his suggestion for your revised encoding structure
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Sep 2003
    Location
    London, England
    Posts
    52
    Yesterday Sinndho gave me an excellent reply to an unrelated substitution coding problem.
    I am hoping for similarly brilliant help with this question.

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what Sindho gave you can be modified to do what you now want to do.
    why not give it a try?
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Sep 2003
    Location
    London, England
    Posts
    52
    I have tried but I'm afraid that I lack the expertise to rewrite his function. Is there any chance you might at least point me in the right direction?

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    this should get you close enough to where you want
    Code:
    Option Compare Database
    Option Explicit 'alwasy include this unless you want to tear you hair out with unitialised variables and chasing phantom errors
    
    Private Sub cmdEncode_Click()
    If Not IsNull(tbText) And Len(tbText) > 0 Then 'only will do soemthign if the suplied text is at loeast one character
      tbEncodedText = EncodeTextNumerically(tbText)
    Else
      tbEncodedText = "" 'clear the encoded control
    End If
    End Sub
    'If the word was all different letters like MUSIC then f(MUSIC) = 12345 but if there were repeated letters then the numbers would be repeated accordingly so that f(SORROW) = 123324, f(ACROSS) = 123455 and f(ICICLE) = 121234. The function only needs to work for up to 10 different letters in the word, so that f(TRAMPOLINE) = 1234567890 and f(IMPERISHABLE) = 123451678904 but f(PERSONALITY) = #.
    Private Function EncodeTextNumerically(ThisText As String) As String
    Dim SymbolIndex As New Collection
    Dim ThisSymbol As String
    EncodeTextNumerically = ""
    'this is only designed to work on the first 9 characters, anymore then just chop the string to length
    If Len(ThisText) > 9 Then ThisText = Left(ThisText, 9)
    Dim strPointer As Integer
    For strPointer = 1 To Len(ThisText)
      ThisSymbol = Mid$(ThisText, strPointer, 1) 'extract the next symbol to process
      'find the index for this symbol, and append it to the current return value
      EncodeTextNumerically = EncodeTextNumerically & GetSymbolIndex(SymbolIndex, ThisSymbol)
    Next strPointer
    End Function
    
    Private Function GetSymbolIndex(ByRef CurrentSymbols As Collection, ThisSymbol As String) As String
    Dim ThisItem As Variant
    Dim ThisIndex As Integer
    'looks for the specified symbol in our current index collection
    'if its found return the index of that position
    'if its not found then add this symbol to the index collection AND return the value
    ThisIndex = 1
    For Each ThisItem In CurrentSymbols
      If ThisItem = ThisSymbol Then 'we've founf it
        GetSymbolIndex = CStr(ThisIndex)
        Exit Function 'we've found the symbol, so return that value
      Else
        ThisIndex = ThisIndex + 1
      End If
    Next ThisItem
    'if we get to here then we didn't find the symbol
    GetSymbolIndex = CStr(ThisIndex)
    CurrentSymbols.Add (ThisSymbol)
    End Function
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    cmdencode is a frfagment of code from a testharness form
    tbtext is the plaintext
    tbencodedtext is the resultant string
    I'd rather be riding on the Tiger 800 or the Norton

  10. #10
    Join Date
    Sep 2003
    Location
    London, England
    Posts
    52
    Gosh, Healdem, how very kind of you. I would never have been able to write that function myself.
    Thank you.

  11. #11
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by JLR View Post
    Gosh, Healdem, how very kind of you. I would never have been able to write that function myself.
    Thank you.
    the only way you prove that either way is to dip you toes into the water and see what happens

    in my books there's a few key things to comprehend when writing software
    1) you need to have a clear idea about what you need to do
    2) you need to a way of translating that into steps or processes
    3) you need to have enough of an idea of how a computer language could do things (ie It would be nice if I could chop a variable into bits), then taking that requirement into a search engine of help system find what the language can offer. to any English speaking individual that should be a breeze in Access, there's precious few bizziarely named functions in Access.
    4) an ability to translate from your idea of the process into code
    5) an ability to thoroughly test the resultant code to make certain it does everything it shoudl, does nothing it shouldn't

    outside of 5 and possibly 4 there is nothing magical or mysterious. most of it it down to the developer being of an enquiring mind and prepared to take a few hits whilst expanding their knowledge. I have yet to do any training or formal skills development in Access, VB, VBA and so on.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •