If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Word patterns

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-08-12, 06:29
JLR JLR is offline
Registered User
 
Join Date: Sep 2003
Location: London, England
Posts: 46
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) = #.
Reply With Quote
  #2 (permalink)  
Old 02-08-12, 07:41
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 02-08-12, 07:47
JLR JLR is offline
Registered User
 
Join Date: Sep 2003
Location: London, England
Posts: 46
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 07:53. Reason: adding an explanation
Reply With Quote
  #4 (permalink)  
Old 02-08-12, 07:53
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #5 (permalink)  
Old 02-08-12, 07:59
JLR JLR is offline
Registered User
 
Join Date: Sep 2003
Location: London, England
Posts: 46
Yesterday Sinndho gave me an excellent reply to an unrelated substitution coding problem.
I am hoping for similarly brilliant help with this question.
Reply With Quote
  #6 (permalink)  
Old 02-08-12, 08:41
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #7 (permalink)  
Old 02-08-12, 08:45
JLR JLR is offline
Registered User
 
Join Date: Sep 2003
Location: London, England
Posts: 46
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?
Reply With Quote
  #8 (permalink)  
Old 02-08-12, 10:12
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #9 (permalink)  
Old 02-08-12, 10:13
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
cmdencode is a frfagment of code from a testharness form
tbtext is the plaintext
tbencodedtext is the resultant string
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #10 (permalink)  
Old 02-08-12, 10:32
JLR JLR is offline
Registered User
 
Join Date: Sep 2003
Location: London, England
Posts: 46
Gosh, Healdem, how very kind of you. I would never have been able to write that function myself.
Thank you.
Reply With Quote
  #11 (permalink)  
Old 02-08-12, 10:55
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
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 my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On