Fwd: Re[3]: programming unlimited "categories" in python ?

Lucio Torre lucio at movilogic.com
Tue Oct 23 12:49:40 EDT 2001


>Date: Tue, 23 Oct 2001 13:49:03 -0300
>To: Gabriel Ambuehl <gabriel_ambuehl at buz.ch>
>From: Lucio Torre <lucio at movilogic.com>
>Subject: Re[3]: programming unlimited "categories" in python ?
>
>At 06:29 PM 23/10/2001 +0200, you wrote:
>>-----BEGIN PGP SIGNED MESSAGE-----
>>
>>Hello Lucio,
>>
>>Tuesday, October 23, 2001, 6:08:48 PM, you wrote:
>>
>> > i think the key in what he is asking is that he is not talking
>> > about ONE tree.
>>
>>So he want's to have like relational trees? Sounds like serious fun
>>to
>>implement.
>>
>> > what if i have the followinf:
>>
>> > region:
>> > 1- africa
>> > 1.1 mozambique
>> > 1.1.1 capital
>>
>> > severity
>> > 1. deadly
>> > 1.1 next 5 hours
>> > 1.2 next ten days
>>
>> > and you want a query like '5 hours deadly in africa'
>>
>>You still need a link between the two, else you haven't got any
>>chance
>>to match them anyway so why not just build the region tree and store
>>all the data under it? then you query for africa first and fetch only
>>the results which have got the attribute deadly in 5 hours?
>
>
>you can match them using intersections. you get all the children for every 
>node in all the categories you want, then intersect them all.
>
>that way you have unlimited categories, with unlimited depth. one tree per 
>category.
>
>
>
>> > problems with this:
>> > a) the categorization is not stored in the object, but in the tree
>> > that points at it. not so big a deal in SQL (you can select from
>> > all_trees where objectid = self), but what about python? how would
>> > you implement it?
>>
>>I wasn't thinking about the implementation itself but mostly about
>>suitable approaches. IMHO, you should try to squeeze your data model
>>into ONE tree and the problem is almost solved.
>
>so you do this tree:
>
>africa
>-> mozambique
>-- > capital
>----> deadly
>------> really deadly
>------> not so deadly
>---> deadly
>-----> really deadly
>-----> not so deadly
>--> deadly
>----> really deadly
>----> not so deadly
>-> deadly
>---> really deadly
>---> not so deadly
>
>but suppose you suddently have cases of a kinda deadly thing. you have to 
>edit the whole tree!
>
>maybe you can add the deady category only to the leaves of the region 
>tree, but the problem persist.
>
>> > b) africa can be pretty big. shouldnt i be able to get/(build?) the
>> > region tree under any node of the others? something like olap.
>>
>>
>>Uuh? Of course you can have africa as a subtree of some other tree if
>>you use some sort of generic tree class like:
>>
>>class tree
>>       [some class] data
>>       list childs
>>       (pointer to parent)
>>       (pointer to next sibling)
>
>
>but you can have that if you hard code the tree. but what if you have some 
>subset (really deadly, or spooky deadly.. or whatever, in the query you 
>are doing) and want to find out the africa tree?
>
>
>
>lucio





More information about the Python-list mailing list