Thread View: news.software.readers
9 messages
9 total messages
Started by Ian Zimmerman
Fri, 14 Aug 1998 00:00
[slrn] those darned regexps again
Author: Ian Zimmerman
Date: Fri, 14 Aug 1998 00:00
Date: Fri, 14 Aug 1998 00:00
28 lines
1271 bytes
1271 bytes
I tried to add a score entry to match articles with subjects all in uppercase. (We know what they usually are :) I tried the following: a/ Subject: ^[^:]+: [^a-z]*$ b/ Subject: ^[^a-z]*$ c/ Subject: [^a-z]*$ None of them does what I want. My questions: 1/ does the string matched in scoring include the header name (e.g., "Subject: ")? 2/ does the "^" anchor match at the beginning of a header string? 3/ what the h*ll else am I doing wrong? 4/ now does anybody see why I pine for GNU/Emacs regexps? -- Ian T Zimmerman <itz@rahul.net> I came to the conclusion that what was wrong about the guillotine was that the condemned man had no chance at all, absolutely none. Albert Camus, _The Outsider_
Re: [slrn] those darned regexps again
Author: Dawn Owens-Nicholson
Date: Fri, 14 Aug 1998 00:00
Date: Fri, 14 Aug 1998 00:00
48 lines
2660 bytes
2660 bytes
Ian Zimmerman wrote: > I tried to add a score entry to match articles with subjects all in > uppercase. I suggest reading the SCORE_FAQ which should have come with your slrn distribution in the doc/ directory. The question "11. How do I score subject headers that contain only uppercase characters?" would seem to apply. In case you can't find this document, you can get the slrn distribution from ftp://space.mit.edu/pub/davis/slrn/slrn0.9.5.2.tar.gz. [Since none of the cited regular expressions did what the poster wanted and since the FAQ lists regular expressions that work, there's no point in going over where the cited regular expressions fail.] > 1/ does the string matched in scoring include the header name (e.g., > "Subject: ")? Yes, but not in the portion you have to worry about. The header is listed in your scorefile to tell slrn what header you're matching against (in this way, you still have to supply the header), the content is the part you write the regex for. > 2/ does the "^" anchor match at the beginning of a header string? Yes. > 3/ what the h*ll else am I doing wrong? Not reading the SCORE_FAQ and getting one way to do it from there. There are other ways, but since the one listed there works... > 4/ now does anybody see why I pine for GNU/Emacs regexps? Actually, not for any of the problems you're having. However, for reasons not germane to this discussion, I could see why a more flexible & powerful regex engine would be desirable. For instance, I wish S-lang's regex engine had alternation, grouping, and the kind of customization found in Python's regex engine (at least, according to what I read in Friedl's "Mastering Regular Expressions". I don't keep up with Python, so I don't know how current his comments are). > Ian T Zimmerman <itz@rahul.net> Is itz@rahul.net where you prefer mail to be sent? itz@kronstadt.boxmail.com is where your From: address pointed and I don't see any header pointing me to itz@rahul.net.
Re: [slrn] those darned regexps again
Author: Ian Zimmerman
Date: Fri, 14 Aug 1998 00:00
Date: Fri, 14 Aug 1998 00:00
39 lines
2131 bytes
2131 bytes
> From: bluemoon@ux6.cso.uiuc.edu (Dawn Owens-Nicholson) > Newsgroups: news.software.readers > Date: 14 Aug 1998 19:40:40 GMT > > Ian Zimmerman wrote: > > I tried to add a score entry to match articles with subjects all > > in uppercase. > > 3/ what the h*ll else am I doing wrong? > Not reading the SCORE_FAQ and getting one way to do it from there. > There are other ways, but since the one listed there works... > You're right, but the answer I'd have given would me more like "read in the FAQ about case sensitivity". I thought I made it clear in my article that I wasn't just looking for something that works, but also for the reason _why_ it works and what I'd tried doesn't. Thanks anyway! > > Ian T Zimmerman <itz@rahul.net> > Is itz@rahul.net where you prefer mail to be sent? > itz@kronstadt.boxmail.com is where your From: address pointed and I > don't see any header pointing me to itz@rahul.net. It is an antijunk device, the 2 addresses are equivalent. The (shaky) assumption is that junk-bots will only look in the headers for victim addresses and not in the body, including the signature. Anyways, because I prefer _not_ to receive email answers to Usenet queries (isn't that still the default?) it did its job this time :-) Best, -- Ian T Zimmerman <itz@rahul.net> I came to the conclusion that what was wrong about the guillotine was that the condemned man had no chance at all, absolutely none. Albert Camus, _The Outsider_
Re: [slrn] those darned regexps again
Author: Heikki Kantola
Date: Fri, 14 Aug 1998 00:00
Date: Fri, 14 Aug 1998 00:00
22 lines
1691 bytes
1691 bytes
Dawn Owens-Nicholson <bluemoon@ux6.cso.uiuc.edu> informed news.software.readers with the following: >Ian Zimmerman wrote: >> I tried to add a score entry to match articles with subjects all in >> uppercase. > >I suggest reading the SCORE_FAQ which should have come with your slrn >distribution in the doc/ directory. The question "11. How do I score >subject headers that contain only uppercase characters?" would seem to >apply. In case you can't find this document, you can get the slrn >distribution from ftp://space.mit.edu/pub/davis/slrn/slrn0.9.5.2.tar.gz. There's also HTML version of it at <URL:http://www.math.ohio-state.edu/ %7Elahvak/software/slrn/scoring_faq.html>. -- Heikki "Hezu" Kantola, <Heikki.Kantola@IKI.FI> L�hett�m�ll� mainoksia tai muuta asiatonta s�hk�postia yll� olevaan osoitteeseen sitoudut maksamaan oikolukupalvelusta FIM500 alkavalta tunnilta.
Re: [slrn] those darned regexps again (long)
Author: Dawn Owens-Nicholson
Date: Sat, 15 Aug 1998 00:00
Date: Sat, 15 Aug 1998 00:00
124 lines
7221 bytes
7221 bytes
Warning: the following article is lengthy and might not be interesting to
people who want to read general slrn discussion. It's late as I type this,
but I think it's all technically correct and understandable with a small
level of regex experience.
Ian Zimmerman <itz@kronstadt.boxmail.com> wrote:
> I thought I made it clear in my article that I wasn't just looking for
> something that works, but also for the reason _why_ it works and what I'd
> tried doesn't.
The SCORE_FAQ explains why the regular expressions listed therein work. I'll
try explaining why yours don't work. For more info, I recommend Jeffrey
E.F. Friedl's _Mastering Regular Expressions_. I've read his book and I
think it's an excellent reference (even if it is largely for perl regular
expressions).
Getting back to your regex situation, you really only have two regular
expressions here (the third is the same as the first minus the attempt to
match the header name), and both have two major problems:
(1) "*" matches more (but is satisfied with less) than most people think.
The asterisk metacharacter means 0 or more repetitions of the previous
character (also known as "\{0,\}"); it is okay for the asterisk to match 0
times. It will /try/ to match more, but if it has to give up everything
it matched so some other part of the regex can match, that's okay. This
means "[^a-z]*" will match *everything*, even the null string.
(2) Slrn scorefile regular expressions are case-insensitive by default,
just like using grep with the 'i' option. "[^a-z]" (no lowercase alpha)
is seen as "[^a-zA-Z]" (no alpha). The score documentation and SCORE_FAQ
talk about "\c" (turn on case sensitivity) and "\C" (turn off case
sensitivity). Just to be crystal clear on these case-sensitivity
switches: you don't need to switch case sensitivity back on in another
regex. Each regex in your scorefile is case-insensitive unless you say
otherwise. You need "\C" in case you want to say something like:
Subject: \cRe: \Cwacky warehouse mall
which treats "Re: " in a case-sensitive manner ("re: ", "rE: " and "RE: "
are not matched) and the rest of the line in a case-insensitive manner.
I'll assume you wanted to match all-caps Subject: headers and kill them.
From <slrn6t8s6m.uoq.itz@kronstadt.rahul.net>:
> Subject: ^[^:]+: [^a-z]*$
I'm going to ignore the "^[^:]+: " part because it appears that you're
trying to match the header name (and header-content separator) here, which
you don't do in slrn scorefiles.
In addition to the two issues noted above, "[^a-z]*$" is anchored at the end
of the line. Because of the lack of "\c", "[^a-z]*$" is treated like
"[^a-zA-Z]*$". So, you're asking for Subject: headers that have 0 or more
non-alphabetic characters at the end of the line. If there are 0 non-alpha
characters at the end of the line, it's a match; if there are 200 non-alpha
characters at the end of the line, it's a match. But really, this isn't
getting at what you're interested in matching.
For example, if the Subject: header were "Subject: B" and you used "Subject:
[^a-z]*$", the regex engine would treat it the same as "Subject:
[^a-zA-Z]*$" and step right past the ``B'', get the null string between the
``B'' and the end of the line to match "[^a-zA-Z]*" then match the end of
the line. Result: a match!
> Subject: ^[^a-z]*$
This is largely the same as the previous regex, so the same two main
problems apply, except this regex is also anchored to the beginning of the
Subject: header content. This additional anchoring means the *entire*
Subject: header content has to have 0 or more non-alphabetic characters, as
opposed to just having any number of non-alpha characters at the end of the
line.
Put another way, when you use "^" and "$", what lies between them describes
the *entire* Subject: header content. Therefore, if there's *one* alpha
character in the header content, there is no match ("[^a-zA-Z]*" wants
*NON*-alpha characters).
For example, if the Subject: header were "Subject: B" and you used "Subject:
^[^a-z]*$", you'd essentially have "Subject: ^[^a-zA-Z]*$". The regex
engine matches the first caret (beginning of line anchor) and tries to match
the character class "[^a-z]*" (0 or more non-alpha characters). There are 0
non-alpha characters between the beginning of line and the ``B'', so
"[^a-z]*" (a.k.a. "[^a-zA-Z]*") matches. Moving on, the engine tries to
match the "$" (end of line anchor) and it can't because the end of line
doesn't follow the null string matched by the character class "[^a-z]*";
there's ``B'' in the way. This `B'' needs to be dealt with in the regex,
but there's no more regex left. Result: not a match.
> Subject: [^a-z]*$
This is a repeat of the first regex.
Neither regex works because neither addresses the issue at hand. The first
regex (anchored at the end) matches "Subject: BLAH" but also matches
"Subject: blah", something you don't want to happen. The second regex
(anchored at both ends) matches neither "Subject: BLAH" nor "Subject: blah"
so it is obviously useless at identifying the Subject: headers you want.
Neither regex is targeting the issue of excluding all-caps headers because
neither is focused on matching all-caps headers or looking for a lowercase
alpha (to declare a non-match).
Before I move to the next topic in your follow-up, I want to suggest you
alter the last SCORE_FAQ scorefile entry in the following manner: Use
"Score: =-9999" instead of "Score: -9999". I think it's a good idea to not
use -9999 (without the equal sign) to kill articles because the equal sign
insures a killed article as opposed to merely subtracting 9,999 points from
the article's score. After all, the article is only killed if it ends up
with kill_score points (-9,999 by default). The equal sign stops processing
and assigns whatever score follows.
> Anyways, because I prefer _not_ to receive email answers to Usenet queries
> (isn't that still the default?) it did its job this time :-)
I don't know if you consider copies of follow-ups e-mail answers, but to
attempt to observe your wishes, I will not send you a copy of this post. You
should consider adding a header to make your position on courtesy copies
clear (I've forgotten what the header name and content is, but I'm sure
someone on n.s.r knows) since you dislike e-mail responses to Usenet
queries.
Hope this helps!
[slrn] Scoring snafus (was: Re: [slrn] those darned regexps again)
Author: Dawn Owens-Nicholson
Date: Sun, 16 Aug 1998 00:00
Date: Sun, 16 Aug 1998 00:00
33 lines
2755 bytes
2755 bytes
Stefan Haller <stk@snafu.de> wrote: > Last I checked, "Score: =-9999" and "Score: -9999" do exactly the same. > -9999 is a special value that implies the meaning of the equal sign. Ah, then I think that's a bad thing; in my opinion, the kill score should not be special in *that* way; I should be able to subtract 9,999 (or kill_score) points from an article's score in a single score without killing it. The article should only be killed (or marked as read or marked high) if the article's score matches the kill_score (or score below max_low_score or score at or above min_high_score, respectively) *after* processing is complete for that article. If people want to stop processing of an article's score before the end of the scorefile, they should have to use `=' followed by that score (for instance "=-9999") no matter what the value of the score. After all, for all the scoring routine knows, I've carefully constructed my scorefile so some articles will end up with a score of -9,999 after all the scores in my scorefile are processed, thus killing those articles. That careful construction might involve a series of additions and subtractions, one of which might be "-9999", in which case, if "-9999" and "=-9999" mean the same thing, slrn might kill an article I wanted marked read or even marked high in some later score. I can rewrite my scorefile to get what I want done, but I still see this "=-9999"/"-9999" equivalence as an unnecessary inconsistency. I'm in favor of making the scoring system as simple as possible without sacrificing scoring power. A similar "magic value" limit happens regarding the Expires:, Lines: and Score: keywords--since they match real or possible Usenet article headers, how does one score for arbitrary values based on those headers? I suspect few people (if any) want to score with them beyond what's documented in slrn's doc/score.txt, I'm just curious.
scoring: slrn vs. strn/trn4 (was: Re: [slrn] those darned regexps again (long))
Author: Kim DeVaughn
Date: Sun, 16 Aug 1998 00:00
Date: Sun, 16 Aug 1998 00:00
17 lines
1370 bytes
1370 bytes
In article <slrn6tbmdu.1te.bluemoon@ux6.cso.uiuc.edu>, Dawn Owens-Nicholson <bluemoon@ux6.cso.uiuc.edu> wrote: | | The SCORE_FAQ explains why the regular expressions listed therein work. Does anyone know how applicable the scoring rules/faq/mechanism for slrn are for strn (and thus for trn4, which is what I use, but haven't done much with scoring per se, due to a lack of documentation)? Thanks ...! /kim ================================================ "Fast, good, cheap. Pick any two." --Unknown
Re: [slrn] those darned regexps again (long)
Author: Stefan Haller
Date: Sun, 16 Aug 1998 00:00
Date: Sun, 16 Aug 1998 00:00
19 lines
1396 bytes
1396 bytes
Dawn Owens-Nicholson <bluemoon@ux6.cso.uiuc.edu> wrote: > Before I move to the next topic in your follow-up, I want to suggest you > alter the last SCORE_FAQ scorefile entry in the following manner: Use > "Score: =-9999" instead of "Score: -9999". I think it's a good idea to not > use -9999 (without the equal sign) to kill articles because the equal sign > insures a killed article as opposed to merely subtracting 9,999 points from > the article's score. Last I checked, "Score: =-9999" and "Score: -9999" do exactly the same. -9999 is a special value that implies the meaning of the equal sign. -- Stefan Haller Berlin, Germany http://www.snafu.de/~stk/
Re: scoring: slrn vs. strn/trn4 (was: Re: [slrn] those darned regexps again (long))
Author: Heikki Kantola
Date: Fri, 21 Aug 1998 00:00
Date: Fri, 21 Aug 1998 00:00
25 lines
2102 bytes
2102 bytes
Kim DeVaughn <kimdv@best.com> informed news.software.readers with the following: >In article <slrn6tbmdu.1te.bluemoon@ux6.cso.uiuc.edu>, > Dawn Owens-Nicholson <bluemoon@ux6.cso.uiuc.edu> wrote: >| The SCORE_FAQ explains why the regular expressions listed therein work. > >Does anyone know how applicable the scoring rules/faq/mechanism for slrn >are for strn (and thus for trn4, which is what I use, but haven't done >much with scoring per se, due to a lack of documentation)? The actual syntax and score mechanisms are AFAIK (I haven't really used trn) somewhat different, but the same basic ideas (what header to match to score certain things and what the regexps[1] should be) should apply. [1] Granted that Slang regexps[2] which Slrn uses have bit different syntax than the more usual regexp system used by eg. trn. [2] See <URL:http://www.math.ohio-state.edu/%7Elahvak/software/slang/ regexps.html> for details. -- Heikki "Hezu" Kantola, <Heikki.Kantola@IKI.FI> L�hett�m�ll� mainoksia tai muuta asiatonta s�hk�postia yll� olevaan osoitteeseen sitoudut maksamaan oikolukupalvelusta FIM500 alkavalta tunnilta.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads