Hi folks.
I am trying to figure out how to separate some words in a string 'complexgrammar' so I can print Complex Grammar.
looking for solutions, I find Tokenish, a class that does nothing with no comment.
I think it may be a former colleague of mine.
fwiw, here is what I came up with.
If anybody knows an elegant way to do this, much appreciated.
|str f l r|
str := 'complexgrammar'.
f := (str from: 1 to:(str findSubstring: 'grammar' in:str startingAt: 1 matchTable: ( String classPool at: #CaseSensitiveOrder)) -1).
l := (str from: (str findSubstring: 'grammar' in:str startingAt: 1 matchTable: ( String classPool at: #CaseSensitiveOrder)) to:(str size)).
r := (f capitalized) , ' ' , (l capitalized) .
r inspect
---- On Mon, 18 Sep 2023 09:16:02 -0400 gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org wrote ---
Hi folks.
I am trying to figure out how to separate some words in a string 'complexgrammar' so I can print Complex Grammar.
looking for solutions, I find Tokenish, a class that does nothing with no comment.
I think it may be a former colleague of mine.
Well, Tokenish isn't a class, it's a class variable containing a list of all the characters considered 'tokenish' (see Character>>#tokenish).
You really shouldn't find yourself using constructions like
String classPool at: #CaseSensitiveOrder
.. to do so implies some pretty serious misunderstanding somewhere along the line.
If you want to find a substring you really ought to use String>>#findString:startingAt:caseSensitive: if you need to control the case sensitivity, or just String>>#findString:startingAt: if the default of true is ok.
Assuming your problem is a bit more general in that you need to split two-word phrases that have been agglomerated, we might try
|input firstOne| input := 'complexgrammar'. firstOne := 'complex'.
^String streamContents: [:strm| strm nextPutAll: firstOne capitalized. strm space. strm nextPutAll: (input allButFirst: firstOne size) capitalized]
Note that this doesn't do any checking of the existence of anything after the firstOne string, or even that firstOne exists within input.
On 2023-09-18, at 6:33 AM, gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org wrote:
fwiw, here is what I came up with.
If anybody knows an elegant way to do this, much appreciated.
|str f l r| str := 'complexgrammar'. f := (str from: 1 to:(str findSubstring: 'grammar' in:str startingAt: 1 matchTable: ( String classPool at: #CaseSensitiveOrder)) -1). l := (str from: (str findSubstring: 'grammar' in:str startingAt: 1 matchTable: ( String classPool at: #CaseSensitiveOrder)) to:(str size)). r := (f capitalized) , ' ' , (l capitalized) . r inspect
---- On Mon, 18 Sep 2023 09:16:02 -0400 gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org wrote ---
Hi folks.
I am trying to figure out how to separate some words in a string 'complexgrammar' so I can print Complex Grammar.
looking for solutions, I find Tokenish, a class that does nothing with no comment.
I think it may be a former colleague of mine.
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Calm down -- it's only ones and zeros.
Hi Tim
Those constructions are in the method comments of ByteString for that method.
"
' ' findSubstring: 'abc' in: 'abcdefabcd' startingAt: 1 matchTable: CaseSensitiveOrder 1
' ' findSubstring: 'abc' in: 'abcdefabcd' startingAt: 2 matchTable: CaseSensitiveOrder 7
' ' findSubstring: 'abc' in: 'abcdefabcd' startingAt: 8 matchTable: CaseSensitiveOrder 0
' ' findSubstring: 'abc' in: 'abcdefABcd' startingAt: 2 matchTable: CaseSensitiveOrder 0
' ' findSubstring: 'abc' in: 'abcdefABcd' startingAt: 2 matchTable: CaseInsensitiveOrder 7
"
Regarding "not a class, but a class variable"
I open a browser and search for the class Tokenish.
It shows up in Category Unknown as a sub-class of Object
Object subclass: #Tokenish
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Unknown'
so I am unsure what you are referring to here. Maybe squeak has evolved in the year or so I have been busy with menial labor work.
Thank you for your time.
cordially
t
---- On Mon, 18 Sep 2023 12:39:04 -0400 Tim Rowledge tim@rowledge.org wrote ---
Well, Tokenish isn't a class, it's a class variable containing a list of all the characters considered 'tokenish' (see Character>>#tokenish).
You really shouldn't find yourself using constructions like
String classPool at: #CaseSensitiveOrder
.. to do so implies some pretty serious misunderstanding somewhere along the line.
If you want to find a substring you really ought to use String>>#findString:startingAt:caseSensitive: if you need to control the case sensitivity, or just String>>#findString:startingAt: if the default of true is ok.
Assuming your problem is a bit more general in that you need to split two-word phrases that have been agglomerated, we might try
|input firstOne| input := 'complexgrammar'. firstOne := 'complex'.
^String streamContents: [:strm| strm nextPutAll: firstOne capitalized. strm space. strm nextPutAll: (input allButFirst: firstOne size) capitalized]
Note that this doesn't do any checking of the existence of anything after the firstOne string, or even that firstOne exists within input.
On 2023-09-18, at 6:33 AM, gettimothy via Squeak-dev mailto:squeak-dev@lists.squeakfoundation.org wrote:
fwiw, here is what I came up with.
If anybody knows an elegant way to do this, much appreciated.
|str f l r| str := 'complexgrammar'. f := (str from: 1 to:(str findSubstring: 'grammar' in:str startingAt: 1 matchTable: ( String classPool at: #CaseSensitiveOrder)) -1). l := (str from: (str findSubstring: 'grammar' in:str startingAt: 1 matchTable: ( String classPool at: #CaseSensitiveOrder)) to:(str size)). r := (f capitalized) , ' ' , (l capitalized) . r inspect
---- On Mon, 18 Sep 2023 09:16:02 -0400 gettimothy via Squeak-dev mailto:squeak-dev@lists.squeakfoundation.org wrote ---
Hi folks.
I am trying to figure out how to separate some words in a string 'complexgrammar' so I can print Complex Grammar.
looking for solutions, I find Tokenish, a class that does nothing with no comment.
I think it may be a former colleague of mine.
tim
On 2023-09-18, at 11:21 AM, gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org wrote:
Hi Tim
Those constructions are in the method comments of ByteString for that method.
" ' ' findSubstring: 'abc' in: 'abcdefabcd' startingAt: 1 matchTable: CaseSensitiveOrder 1
Yes, and they're fine because they are within the class(es) that 'own' that class variable. Use the scope, Luke!
Regarding "not a class, but a class variable"
I open a browser and search for the class Tokenish.
It shows up in Category Unknown as a sub-class of Object
That.... is weird. I don't see it in my 22709 update squeak 6 image. I wouldn't expect to see it.
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Mommy! The cursor's winking at me!
Squeak6.1alpha
latest update: #22721
Image format 68533 (64 bit)
Preferred bytecode set: SistaV1
---- On Mon, 18 Sep 2023 15:25:12 -0400 Tim Rowledge tim@rowledge.org wrote ---
On 2023-09-18, at 11:21 AM, gettimothy via Squeak-dev mailto:squeak-dev@lists.squeakfoundation.org wrote:
Hi Tim
Those constructions are in the method comments of ByteString for that method.
" ' ' findSubstring: 'abc' in: 'abcdefabcd' startingAt: 1 matchTable: CaseSensitiveOrder 1
Yes, and they're fine because they are within the class(es) that 'own' that class variable. Use the scope, Luke!
Regarding "not a class, but a class variable"
I open a browser and search for the class Tokenish.
It shows up in Category Unknown as a sub-class of Object
That.... is weird. I don't see it in my 22709 update squeak 6 image. I wouldn't expect to see it.
tim
As it's categorized as Unknown, I would guess that you have created it by yourself by accident. This can happen when you do-it/print-it MyUnknownGlobal and confirm the automatic undeclared variable dialog to create a new class. Is that possible? You could validate that hypothesis by locating the class def in your changes file or your change set. [Image]
________________________________ From: gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org Sent: Monday, September 18, 2023 10:18:36 PM To: The general-purpose Squeak developers list squeak-dev@lists.squeakfoundation.org Cc: gettimothy gettimothy@zoho.com Subject: [squeak-dev] Re: Tokenish a class that does nothing with no comment!
Squeak6.1alpha latest update: #22721
Image format 68533 (64 bit) Preferred bytecode set: SistaV1
---- On Mon, 18 Sep 2023 15:25:12 -0400 Tim Rowledge tim@rowledge.org wrote ---
On 2023-09-18, at 11:21 AM, gettimothy via Squeak-dev <squeak-dev@lists.squeakfoundation.orgmailto:squeak-dev@lists.squeakfoundation.org> wrote:
Hi Tim
Those constructions are in the method comments of ByteString for that method.
" ' ' findSubstring: 'abc' in: 'abcdefabcd' startingAt: 1 matchTable: CaseSensitiveOrder 1
Yes, and they're fine because they are within the class(es) that 'own' that class variable. Use the scope, Luke!
Regarding "not a class, but a class variable"
I open a browser and search for the class Tokenish.
It shows up in Category Unknown as a sub-class of Object
That.... is weird. I don't see it in my 22709 update squeak 6 image. I wouldn't expect to see it.
tim -- tim Rowledge; tim@rowledge.orgmailto:tim@rowledge.org; http://www.rowledge.org/tim Mommy! The cursor's winking at me!
Hi Tim, List,
On Mon, Sep 18, 2023, 07:16 gettimothy via Squeak-dev < squeak-dev@lists.squeakfoundation.org> wrote:
Hi folks.
I am trying to figure out how to separate some words in a string 'complexgrammar' so I can print Complex Grammar.
Do you just need to split only those two words? or words in general?
If it's words in general, I can port a program I wrote and offer it up to Trunk.
Ithandlescompletesentencesthatlackspaces,andwilldoitsbestincaseofambiguity.
I used the BSD system dictionary for repairing english, but any word list works.
Hi Lauren
On 2023-09-19, at 7:49 AM, Lauren P drurowin@gmail.com wrote:
If it's words in general, I can port a program I wrote and offer it up to Trunk.
Ithandlescompletesentencesthatlackspaces,andwilldoitsbestincaseofambiguity.
I used the BSD system dictionary for repairing english, but any word list works.
Very definitely sometihng I'd like to see the code for. If nothing else, package it and add to SqueakMap!
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Strange OpCodes: POI: Power Off Intermittently
hi Laurenthank you for the offer.I used SQL to update the table with those values, so no need ---- On Tue, 19 Sep 2023 10:49:31 -0400 drurowin@gmail.com wrote ----Hi Tim, List,On Mon, Sep 18, 2023, 07:16 gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org wrote:Hi folks.I am trying to figure out how to separate some words in a string 'complexgrammar' so I can print Complex Grammar.Do you just need to split only those two words? or words in general?If it's words in general, I can port a program I wrote and offer it up to Trunk.Ithandlescompletesentencesthatlackspaces,andwilldoitsbestincaseofambiguity.I used the BSD system dictionary for repairing english, but any word list works.
squeak-dev@lists.squeakfoundation.org