🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
17 messages
17 total messages Started by Matthias Jordan Wed, 21 Jul 1999 00:00
Threading algorithm
#50009
Author: Matthias Jordan
Date: Wed, 21 Jul 1999 00:00
17 lines
1193 bytes
Hi, folks!

I�m working on a newsreader for PalmPilots (GPL project, BTW). At the
moment it works really great so I decided to implement threading. I
hacked a quick-and-dirty algorithm together but it has complexity
O(n^2) (where n is the number of articles already in the newsgroup).
As I said, the newsreader runs on a palmtop so performance is really
an issue.
Because I didn�t find a better algorithm I wanted to ask if someone
could give me a hint for a better one.

Bye!
Matthias



Re: Threading algorithm
#50012
Author: Matthias Jordan
Date: Wed, 21 Jul 1999 00:00
22 lines
1388 bytes
Hi, Curt!

>> moment it works really great so I decided to implement threading. I
>> hacked a quick-and-dirty algorithm together but it has complexity
>It would really help if you told us what the algorithm did.


It sorts newsgroup articles by thread. In this particular case by use
of the References header line. My current algorithm works like this:

For every new article to insert into a newsgroup do this: If the new
article has a References line, see whether there is the original
article the new article refers to. If so, insert the new article
behind the original one.

Bye!
Matthias




Re: Threading algorithm
#50022
Author: Curt Welch
Date: Wed, 21 Jul 1999 00:00
60 lines
3550 bytes
"Matthias Jordan" <mjordan@sensenet.wirepool.free.de> wrote:
> Hi, Curt!
>
> >> moment it works really great so I decided to implement threading. I
> >> hacked a quick-and-dirty algorithm together but it has complexity
> >It would really help if you told us what the algorithm did.

Oh, I see :).  For some reason I thought "threading" meant process
treads of some type.  And now after sticking my foot in my mouth
I guess I have to answer you :)...

> It sorts newsgroup articles by thread. In this particular case by use
> of the References header line. My current algorithm works like this:
>
> For every new article to insert into a newsgroup do this: If the new
> article has a References line, see whether there is the original
> article the new article refers to. If so, insert the new article
> behind the original one.

Threading is a bit more complex than that.  You have to deal with missing
articles.  For example, articles B and C both refer to A, but A is gone.
In this case, B and C should still end up together (even if they have
different subjects).

Also, do you just use the last ID on the References: line or do you
use all of them?  You should use all of them.  i.e., if the last one
doesn't turn up a thread to attach the current article to, then try
the next one, etc.

So are you doing something gross like a linear search of the current
list to find the old article?  If, so I could see where that would kill
you.

You either build a big list of message IDs and sort it with a real
sort algorithm (n log n instead of n^2), or you build some type of
structure to index the message-ids quckly back to the threads they
are associated with.  Something like a hashed array of linked lists
is what I like to use.  Various types of b-trees work fine as well.

For each article, you take all the message-IDs in the references
and the articles own message-ID and look them up in this index to
see if any of the ids are allready associated with one or more threads.

If more than one thread comes up, then you need to combine the two
threads together.  If nothing comes up, then you start a new thread.

But in all cases you add all the message-ids from this new article
to the index if they are not already there.

If you have enough memory to do all this and create the right index
then it behaves more like O(n) to do the threading where n is the number of
Message-IDs you have to deal with - then you have to sort the threads
(internally and externally), and those are a bunch of standard n log n
sorts.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/

Re: Threading algorithm
#50031
Author: Curt Welch
Date: Wed, 21 Jul 1999 00:00
19 lines
1533 bytes
"Matthias Jordan" <mjordan@sensenet.wirepool.free.de> wrote:
> Hi, folks!
>
> I�m working on a newsreader for PalmPilots (GPL project, BTW). At the
> moment it works really great so I decided to implement threading. I
> hacked a quick-and-dirty algorithm together but it has complexity
> O(n^2) (where n is the number of articles already in the newsgroup).
> As I said, the newsreader runs on a palmtop so performance is really
> an issue.
> Because I didn�t find a better algorithm I wanted to ask if someone
> could give me a hint for a better one.

It would really help if you told us what the algorithm did.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/

Re: Threading algorithm
#50035
Author: Erland Sommarskog
Date: Thu, 22 Jul 1999 00:00
29 lines
2253 bytes
Curt Welch (curt@kcwc.com) writes:
>Threading is a bit more complex than that.  You have to deal with missing
>articles.  For example, articles B and C both refer to A, but A is gone.
>In this case, B and C should still end up together (even if they have
>different subjects).

No, if they have different subject lines, they shouldn't. At least
not mandadory. There might be a user-configurable option to get
such threading. Readers that thread umpteen unrelated subjects into
one big mega-thread just because the threads split off from some 
common thread two months ago are virtually useless. 

The best behaviour is probably that if you have a bunch of unread
articles, and they can be threaded on Message-ID to a common entry point 
*among the unread articles themselves*, these articles should be one
thread, even if they contain a change of Subject. If there are more
than one entry point with the same Subject, those entry points 
should all be in one thread. (Even if they don't a have Message-ID
in References in common.)

But entry points with different subject lines should probably 
not be threaded together, unless an article further in the subthread
shifts back on one of the other subject lines. 
-- 
Erland Sommarskog, Stockholm, sommar@algonet.se
When it comes to Swedish summers there's only one thing you can rely on, and
that is that they are completely unreliable.

Re: Threading algorithm
#50037
Author: Jeroen Scheerder
Date: Thu, 22 Jul 1999 00:00
31 lines
2269 bytes
Erland Sommarskog <sommar@algonet.se>:

> >Threading is a bit more complex than that.  You have to deal with missing
> >articles.  For example, articles B and C both refer to A, but A is gone.
> >In this case, B and C should still end up together (even if they have
> >different subjects).
> 
> No, if they have different subject lines, they shouldn't. At least
> not mandadory. There might be a user-configurable option to get
> such threading.

Nothing about threading is mandatory. :-)

Anyway, a subject change may very well signal thread straying.  And it
may not.  Strictly, descendants B and C are in the same thread, even if
there has been thread digression on one; but it may be a nice idea for
user software to take such matters into account.

Of course, a true `thread breach' signaller has been proposed once, and
is described in son-of-1036; as I recall, that involves a `_-_'
substring before the `@' in the msgid.  I don't know how widely that's
used (but don't expect much), but it may be something to consider when
dealing with the issues surrounding threading and (sub)thread display.


-- J$
-- 
dash dash space
this is my .sig                                         it's not so .big

Re: Threading algorithm
#50054
Author: alex
Date: Thu, 22 Jul 1999 00:00
23 lines
1337 bytes
>Hi, folks!
>
>I�m working on a newsreader for PalmPilots (GPL project, BTW). At the
>moment it works really great so I decided to implement threading. I
>hacked a quick-and-dirty algorithm together but it has complexity
>O(n^2) (where n is the number of articles already in the newsgroup).
>As I said, the newsreader runs on a palmtop so performance is really
>an issue.
>Because I didn�t find a better algorithm I wanted to ask if someone
>could give me a hint for a better one.
>
>Bye!
>Matthias
>
>
You can store information about references in hash table, so the overall
time will be proportional to the number of references in the group and
we'll end with O(n).

Alex


Re: Threading algorithm
#50063
Author: J. Moreno
Date: Thu, 22 Jul 1999 00:00
25 lines
2160 bytes
Curt Welch <curt@kcwc.com> wrote:

> planb@newsreaders.com (J. Moreno) wrote:
> > Jeroen Scheerder <js@cwi.nl> wrote:
> > > Of course, a true `thread breach' signaller has been proposed once,
> > > and is described in son-of-1036; as I recall, that involves a `_-_'
-snip-
> > Nobody uses it as far as I know, although some programs (which skip my
> > mind at the moment) will generate it.
> 
> NewsReader.Com generates it.  But I still can't figure out why any program
> would choose to use it.  I suspect its intent was to help threading
> algorithms deal with subject changes without having to check the subjects
> of all the messages, but with XOVER in common use today, it's very unlikey
> that anyone would try to thread articles and not have the subjects
> avalable.

I suspect that it was considered a good option at the time with little
negative effect, but nobody has put it into practice beyond generating
it, and I doubt if anyone ever will.

-- 
John Moreno

Re: Threading algorithm
#50065
Author: J. Moreno
Date: Thu, 22 Jul 1999 00:00
44 lines
2981 bytes
Jeroen Scheerder <js@cwi.nl> wrote:

> Erland Sommarskog <sommar@algonet.se>:
> 
> > >Threading is a bit more complex than that.  You have to deal with missing
> > >articles.  For example, articles B and C both refer to A, but A is gone.
> > >In this case, B and C should still end up together (even if they have
> > >different subjects).
> > 
> > No, if they have different subject lines, they shouldn't. At least
> > not mandadory. There might be a user-configurable option to get
> > such threading.
> 
> Nothing about threading is mandatory. :-)
> 
> Anyway, a subject change may very well signal thread straying.  And it
> may not.  Strictly, descendants B and C are in the same thread, even if
> there has been thread digression on one; but it may be a nice idea for
> user software to take such matters into account.
> 
> Of course, a true `thread breach' signaller has been proposed once, and
> is described in son-of-1036; as I recall, that involves a `_-_'
> substring before the `@' in the msgid.  I don't know how widely that's
> used (but don't expect much), but it may be something to consider when
> dealing with the issues surrounding threading and (sub)thread display.

Nobody uses it as far as I know, although some programs (which skip my
mind at the moment) will generate it.

But even then, it's not a "true" thread breach signaller, as it only
shows a change in the Subject and there's no way to do it retroactively
(which is what you'd need IMO) to make it worthwhile, because while
"short string (was: extremely long string that is ugly" and "short
string" have different values (and hence would get twig a "breach") it's
not really a different subject.  Ditto for spelling corrections and
other minor (and sometimes major) changes.

Subject is entered and changed by people, as such it's not really
reliable enough to count on.

-- 
John Moreno

Re: Threading algorithm
#50076
Author: Curt Welch
Date: Fri, 23 Jul 1999 00:00
18 lines
1723 bytes
"Matthias Jordan" <mjordan@sensenet.wirepool.free.de> wrote:
> >You either build a big list of message IDs and sort it with a real
> >sort algorithm (n log n instead of n^2), or you build some type of
>
> I thought about this idea but this is also at complexity O(n^2) - just
> not in speed but in space consumption. Because I develop a newsreader
> for PalmPilots (average RAM at about 2 MB), quadratic space
> consumption is a /very/ bad idea. (And: How much time would it take to
> build up the data structure? I guess O(n^2).)

BTW, what type of language do you use to program a PalmPilot?  Is it
something real like C, or is it some type of interpretive language?

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/

Re: Threading algorithm
#50084
Author: Erland Sommarskog
Date: Fri, 23 Jul 1999 00:00
30 lines
2166 bytes
Jeroen Scheerder (js@cwi.nl) writes:
>Anyway, a subject change may very well signal thread straying.  And it
>may not.  

Yes. Say for instance that I would happen to insert a space in the 
Subject line of this article, so that it would now read 
"Threading  algorithm". In this case it is most likely to be
the same thread from the user's point of view. And yes, such 
things happens, whether it depends on user intervention, or
malfunctioning software.

If I were to write a newsreader (which I'm not) I would probably
investigate some sort of fuzzy rules for subject-line comparison.
That would probably include dropping all text that comes between
() at the end of the subject line. Maybe also some algorithm to
weed out localized "Re:" strings.

>Strictly, descendants B and C are in the same thread, even if
>there has been thread digression on one; but it may be a nice idea for
>user software to take such matters into account.

Thankfully several newsreaders does this: XNews, News Xpress, Agent (both
Free and Paid), to mention a few. 

-- 
Erland Sommarskog, Stockholm, sommar@algonet.se
When it comes to Swedish summers there's only one thing you can rely on, and
that is that they are completely unreliable.

Re: Threading algorithm
#50090
Author: Matthias Jordan
Date: Fri, 23 Jul 1999 00:00
33 lines
1692 bytes
Hi, Curt!

>Threading is a bit more complex than that.  You have to deal with
missing


Sure it is. But the simple algorithm is alread at O(n^2). If it should
deal with missing articles and stuff like that, it would be even
slower.

>You either build a big list of message IDs and sort it with a real
>sort algorithm (n log n instead of n^2), or you build some type of


I thought about this idea but this is also at complexity O(n^2) - just
not in speed but in space consumption. Because I develop a newsreader
for PalmPilots (average RAM at about 2 MB), quadratic space
consumption is a /very/ bad idea. (And: How much time would it take to
build up the data structure? I guess O(n^2).)

>(internally and externally), and those are a bunch of standard n log
n
>sorts.


How many? n? (Just kidding...)

Bye!
Matthias



Re: Threading algorithm
#50091
Author: Curt Welch
Date: Fri, 23 Jul 1999 00:00
23 lines
2093 bytes
planb@newsreaders.com (J. Moreno) wrote:
> Jeroen Scheerder <js@cwi.nl> wrote:
> > Of course, a true `thread breach' signaller has been proposed once, and
> > is described in son-of-1036; as I recall, that involves a `_-_'
> > substring before the `@' in the msgid.  I don't know how widely that's
> > used (but don't expect much), but it may be something to consider when
> > dealing with the issues surrounding threading and (sub)thread display.
>
> Nobody uses it as far as I know, although some programs (which skip my
> mind at the moment) will generate it.

NewsReader.Com generates it.  But I still can't figure out why any program
would choose to use it.  I suspect its intent was to help threading
algorithms deal with subject changes without having to check the subjects
of all the messages, but with XOVER in common use today, it's very unlikey
that anyone would try to thread articles and not have the subjects
avalable.

-- 
Curt Welch                                            http://CurtWelch.Com/
curt@kcwc.com                          Webmaster for http://NewsReader.Com/

Re: Threading algorithm
#50143
Author: Thorfinn
Date: Mon, 26 Jul 1999 00:00
20 lines
1959 bytes
In news.software.readers, on 23 Jul 1999 20:53:43 GMT
Curt Welch <curt@kcwc.com> wrote:
> BTW, what type of language do you use to program a PalmPilot?  Is it
> something real like C, or is it some type of interpretive language?

It's C.  And it's *decent* C, at that... none of this bloatware crap.
If your executable is more than a small number of K in size, you want
to know why. :)

Meep,

  Thorf

-- 
<a href = "http://netizen.com.au/~thorfinn/">thorfinn@netizen.com.au</a>
"... even had to open up the case and gaze upon the hallowed peace that
graced the helpdesk that day."
    -- MegaHal, trained on alt.sysadmin.recovery

Re: Threading algorithm
#50161
Author: greg
Date: Tue, 27 Jul 1999 00:00
25 lines
2092 bytes
In article <8E0B76A95Yazorman@news.algonet.se>,
sommar@algonet.se (Erland Sommarskog) wrote:
>Curt Welch <curt@kcwc.com> writes:

>> Threading is a bit more complex than that.  You have to deal with missing
>> articles.  For example, articles B and C both refer to A, but A is gone.
>> In this case, B and C should still end up together (even if they have
>> different subjects).

> No, if they have different subject lines, they shouldn't. At least
> not mandatory.

Well, I can see not hiding the change of subject behind the face of a
thread of a different subject, but I can see sorting these
subject-changing threads near the thread they spun off from rather than
sorting them as another entirely separate thread in another sorting method
(alphabetic, datetime, etc.).

-- 
Nine quadrillion, nine hundred ninety-nine trillion, nine hundred ninety-nine
billion, nine hundred ninety-nine million, nine hundred ninety-nine thousand,
three hundred ninety-two bottles of beer.  You take one down, pass it around,
nine quadrillion, nine hundred ninety-nine trillion, nine hundred ninety-nine

Re: Threading algorithm
#50542
Author: Douglas Cook
Date: Tue, 10 Aug 1999 00:00
5 lines
750 bytes
Whoops, not linear time, but O(1) time.  Sorry.



Re: Threading algorithm
#50545
Author: Douglas Cook
Date: Tue, 10 Aug 1999 00:00
56 lines
2854 bytes
You really need to use a hash table (also known as Maps or Dictionaries,
although there are minor variations between these) of some sort.  They take
a key (in this case, the messageID) and in approximately linear time
(assuming you know beforehand how many items will be in the hash table) tell
whether the key is in the hash table.  This is what my reader does:

root = value indicating that a child added at this point is not threaded;
while(there are more articles to read){
  get article;
  defaultAttachmentPoint = root;
  references = article's references;
  while((haven't found an attachmentPoint yet) && (references!="")){
    reference = the last messageID in references;
    references = references with its last messageID chopped off;
    if(an article matching reference is in hash table){
      defaultAttachmentPoint = the article pointed to by hash table;
      found an attachmentPoint = true;
    }
  }
  add article to tree view as child of defaultAttachmentPoint;
  add article's messageID to hash table, and have it hash to its position in
tree;
}

And as far as the NNTP specification says and what every newsreader I know
of does, the content of the Subject line should have nothing to do with
whether it is considered a thread, but by default a news reader should make
the subject of the response be "Re:" followed by the original subject,
unless the original subject already has a "Re:".  Check out RFC 977 if in
doubt.

Matthias Jordan wrote in message <37964124$0$217@nntp.ruhr.de>...
>Hi, Curt!
>
>>> moment it works really great so I decided to implement threading. I
>>> hacked a quick-and-dirty algorithm together but it has complexity
>>It would really help if you told us what the algorithm did.
>
>
>It sorts newsgroup articles by thread. In this particular case by use
>of the References header line. My current algorithm works like this:
>
>For every new article to insert into a newsgroup do this: If the new
>article has a References line, see whether there is the original
>article the new article refers to. If so, insert the new article
>behind the original one.
>
>Bye!
>Matthias
>
>
>



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