automatically turn "message," into "message/,"

Jun 26, 2013 at 6:33pm

automatically turn "message," into "message/,"

I’m hoping somebody can help me with a problem I’m having. I’m basically trying to route a whole bunch of text automatically downloaded from a web page and analyze it but I’ve run into a problem with commas. My objects automatically filter out the commas in the text as message separators. Now I know if you put a / before the comma it won’t be treated as a message separator, but is there some sort of combination of objects that would be able to do this automatically? I’m dealing with quite a large volume of text so I can’t afford to put all the / in myself.

#254207
Jun 27, 2013 at 1:44am

mayyybe there is something to do with [tosymbol] ? or with [regexp] eg [regepx \, @substitute \\\,] or [sprintf] ? but it’s hard to help you wihtout example, in particular : how do you download said text ? if the problem is directly out of an object that downloads the text it might be less easy….
edit : i doubt any of those tricks would work, because as soon as a message is parsed, it’s more than one message. maybe you’d have more luck with some zl magic, by reuniting the text obtained ?

#254222
Jun 27, 2013 at 2:06am

Ah, I had a look at regexp and it looked like it should have worked but it looks like the comma is gone the second it enters the inlet, here’s the part of my patch that downloads the text, followed by some objects that get rid of the of the html formatting and outputs each word individually as a long string of messages, if you execute the download then look at the text file the commas are there, but the second they go through another object they’re gone.

<code>

– Pasted Max Patch, click to expand. –

</code>

#254225
Jun 27, 2013 at 2:07am

in your example i’m not sure how you output the text from your [text]. If you use dump, at the end of the chain each string is separated…if that’s not the problem, then

[text]
|
[regexp , @substitute \\,]
|
[route set]
|…

should be enough to keep the comas at the end.
edit : actually you also need to connect the third outlet of regexp (unmatched) to output lines that don’t have comas in them.

#254226
Jun 27, 2013 at 2:38am

That’s right I’m using dump to output the text, I forgot to include it in the pasted patch as it’s part of a trigger involving other objects.

It seems like in theory your setup with the regexp should work, but I’m not getting anything, I think regexp is still treating the commas as message separators. Even if you tell it to look for them, it seems like it only tries to look for them after filtering them out.

Why would I need to connect the unmatched outlet of regexp?

I realised that if you have a [message,] and you manually put quotes around it ["message,"] it will turn it into [message\,] automatically, but if you try to use tosymbol which normally does this it won’t do it because it’s not a list input

At the moment it looks like something that may have to be addressed by c74 or it has no possible solution…

#254227
Jun 27, 2013 at 10:04am

I do not know for what you are looking exactly regarding your text processing, but in the attached patch you may find some hints.
Hope this helps
Helmuth
<code>

– Pasted Max Patch, click to expand. –

</code>

#254286
Jun 27, 2013 at 10:21am

or this…

– Pasted Max Patch, click to expand. –
#254289
Jun 27, 2013 at 7:25pm

Thanks, well one thing I figured out is that it’s supposed to be a \ and not a /

The second patch you pasted works on some text in lines 6 and 7, but this appears to be because they are enclosed in quotes, specifying that area of the text as a whole symbol, thus the regexp can do its thing but all commas not enclosed in quotes get lost as before. Maybe it’s worth trying to find a way to automatically enclose each entire line of the text in quotes, so the regexp can affect them and they can then go through [zl group 1] with the commas preserved. It doesn’t seem possible with the current text object as I can’t find a command that sets the pointer to the beginning of a line but maybe there’s some kind of external or other software that can affect the text file..

#254330
Jun 27, 2013 at 9:39pm

Well it looks like I found a workable solution using open source software called Auto Hot Key (http://www.autohotkey.com/) to quickly put quotes at the beginning and end of each line of the html file, allowing regexp to treat each line as a whole symbol and preserve the commas. Thanks for help with regexp!

<code>

– Pasted Max Patch, click to expand. –

</code>

#254336
Jun 28, 2013 at 2:01am

For anybody interested in my solution this is my end result

<code>

– Pasted Max Patch, click to expand. –

</code>

And this is my AHK script (just hold Q til you’re at the last line):

Q::
send {Home}
send ”
send {End}
send ”
send {NumpadDown}

#254355

You must be logged in to reply to this topic.