Re: Error in Tree Structure

2016-02-29 Thread subhabangalore
On Saturday, February 27, 2016 at 9:43:56 PM UTC+5:30, Rustom Mody wrote: > On Saturday, February 27, 2016 at 2:47:53 PM UTC+5:30, subhaba...@gmail.com > wrote: > > I was trying to implement the code, > > > > import nltk > > import nltk.tag, nltk.chunk, itertools > > def

Re: Error in Tree Structure

2016-02-27 Thread Rustom Mody
On Saturday, February 27, 2016 at 2:47:53 PM UTC+5:30, subhaba...@gmail.com wrote: > I was trying to implement the code, > > import nltk > import nltk.tag, nltk.chunk, itertools > def ieertree2conlltags(tree, tag=nltk.tag.pos_tag): > words, ents = zip(*tree.pos()) > iobs = [] > prev

Re: Error in Tree Structure

2016-02-27 Thread Steven D'Aprano
On Sat, 27 Feb 2016 08:17 pm, subhabangal...@gmail.com wrote: > Is it any error in Python part or in NLTK part? Neither. Any time you think there is an error in Python, it is 99.9% sure that the error is in your code, not Python. If the error is a SyntaxError, that is 99.9%. > If any one

Error in Tree Structure

2016-02-27 Thread subhabangalore
I was trying to implement the code, import nltk import nltk.tag, nltk.chunk, itertools def ieertree2conlltags(tree, tag=nltk.tag.pos_tag): words, ents = zip(*tree.pos()) iobs = [] prev = None for ent in ents: if ent == tree.node: iobs.append('O')

Re: Tree structure

2011-07-26 Thread Marco Nawijn
On Jul 26, 6:53 am, Bevan Jenkins beva...@gmail.com wrote: Hello, I am trying to create a tree structure for use with a PyQt QTreeView. But first I need to get my head around how to create the tree structure.  I have a dictionary (for testing purposes) but I will later use a table via

Re: Tree structure

2011-07-26 Thread Peter Otten
Bevan Jenkins wrote: Hello, I am trying to create a tree structure for use with a PyQt QTreeView. But first I need to get my head around how to create the tree structure. I have a dictionary (for testing purposes) but I will later use a table via sqlalchemy. The use case is hydrology

Re: Tree structure

2011-07-26 Thread Bevan Jenkins
On Jul 26, 8:46 pm, Peter Otten __pete...@web.de wrote: Bevan Jenkins wrote: Hello, I am trying to create a tree structure for use with a PyQt QTreeView. But first I need to get my head around how to create the tree structure.  I have a dictionary (for testing purposes) but I

Tree structure

2011-07-25 Thread Bevan Jenkins
Hello, I am trying to create a tree structure for use with a PyQt QTreeView. But first I need to get my head around how to create the tree structure. I have a dictionary (for testing purposes) but I will later use a table via sqlalchemy. The use case is hydrology, so I would like to have

Re: Is there a standard name for this tree structure?

2010-04-06 Thread egbert
On Sun, Apr 04, 2010 at 12:10:02PM +, Steven D'Aprano wrote: I can implement this tree using a flat dict: root = object() data = {root: ['Mammal', 'Reptile'], What is the advantage, or thougth behind, using an instance of object as the root of your flat tree ? egbert -- Egbert

Re: Is there a standard name for this tree structure?

2010-04-06 Thread Steven D'Aprano
On Tue, 06 Apr 2010 19:16:05 +0200, egbert wrote: On Sun, Apr 04, 2010 at 12:10:02PM +, Steven D'Aprano wrote: I can implement this tree using a flat dict: root = object() data = {root: ['Mammal', 'Reptile'], What is the advantage, or thougth behind, using an instance of object as

Re: Is there a standard name for this tree structure?

2010-04-06 Thread Lie Ryan
On 04/07/10 14:18, Steven D'Aprano wrote: I could have used None, or root, or this is a magic value that probably won't clash with an entry in the tree, or -1 as a sentinel instead, but they all risk accidental clashes with tree entries. Especially when you want to consider the possibility

Is there a standard name for this tree structure?

2010-04-04 Thread Steven D'Aprano
I have a hierarchical structure something like a directory tree or a nested tree structure: Mammal +-- Ape : +-- Chimpanzee : +-- Gorilla : +-- Human +-- Carnivore : +-- Cat : +-- Tiger Reptile +-- Lizard +-- Snake +-- Cobra +-- Python This is a forest because each top

Re: Is there a standard name for this tree structure?

2010-04-04 Thread Alf P. Steinbach
* Steven D'Aprano: I have a hierarchical structure something like a directory tree or a nested tree structure: Mammal +-- Ape : +-- Chimpanzee : +-- Gorilla : +-- Human +-- Carnivore : +-- Cat : +-- Tiger Reptile +-- Lizard +-- Snake +-- Cobra +-- Python This is a forest

Re: Is there a standard name for this tree structure?

2010-04-04 Thread Duncan Booth
Steven D'Aprano st...@remove-this-cybersource.com.au wrote: I have a hierarchical structure something like a directory tree or a nested tree structure: Mammal +-- Ape : +-- Chimpanzee : +-- Gorilla : +-- Human +-- Carnivore : +-- Cat : +-- Tiger Reptile +-- Lizard

Re: Is there a standard name for this tree structure?

2010-04-04 Thread Stefan Behnel
Steven D'Aprano, 04.04.2010 14:10: I have a hierarchical structure something like a directory tree or a nested tree structure: Mammal +-- Ape : +-- Chimpanzee : +-- Gorilla : +-- Human +-- Carnivore : +-- Cat : +-- Tiger Reptile +-- Lizard +-- Snake +-- Cobra +-- Python

Re: Is there a standard name for this tree structure?

2010-04-04 Thread Patrick Maupin
On Apr 4, 9:06 am, Duncan Booth duncan.bo...@invalid.invalid wrote: Do you have any carniverous apes? If so it's a directed acyclic graph. Well, since he has a root node, he's really only described the *use* of this data structure implementation for a rooted tree. As you point out, the

Re: Is there a standard name for this tree structure?

2010-04-04 Thread Patrick Maupin
On Apr 4, 10:41 am, Patrick Maupin pmau...@gmail.com wrote: The primary differences between this structure and just haphazardly wiring up random objects into a directed graph are that (1) there may be some performance differences (but when the garbage collector has to figure out how to break

Re: Tree Structure

2009-10-10 Thread Shakeeb Alireza
Is there any python class to display the drive and folder structure as a tree(As you see in the windows explorer window)?? http://wiki.wxpython.org/TreeControls S -- http://mail.python.org/mailman/listinfo/python-list

Tree Structure

2009-10-09 Thread Girish
Hello, Is there any python class to display the drive and folder structure as a tree(As you see in the windows explorer window)?? Thanks, Girish.. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tree Structure

2009-10-09 Thread r
On Oct 9, 5:02 am, Girish girish@gmail.com wrote: Is there any python class to display the drive and folder structure as a tree(As you see in the windows explorer window)?? You could use a recursive function to print it out of course or you will need to use a GUI kit. wxPython has a tree

Tree structure consuming lot of memory

2009-07-06 Thread mayank gupta
Hi, I am creating a tree data-structure in python; with nodes of the tree created by a simple class : class Node : def __init__(self , other attributes): # initialise the attributes here!! But the problem is I am working with a huge tree (millions of nodes); and each

Re: Tree structure consuming lot of memory

2009-07-06 Thread Chris Rebert
On Mon, Jul 6, 2009 at 2:55 AM, mayank guptamooni...@gmail.com wrote: Hi, I am creating a tree data-structure in python; with nodes of the tree created by a simple class : class Node :    def __init__(self , other attributes):   # initialise the attributes here!! But

Re: Tree structure consuming lot of memory

2009-07-06 Thread mayank gupta
Thanks for the other possibilites. I would consider option (2) and (3) to improve my code. But out of curiosity, I would still like to know why does an object of a Python-class consume so much of memory (1.4 kb), and this memory usage has nothing to do with its attributes. Thanks Regards. On

Re: Tree structure consuming lot of memory

2009-07-06 Thread Simon Forman
On Mon, Jul 6, 2009 at 6:12 AM, mayank guptamooni...@gmail.com wrote: Thanks for the other possibilites. I would consider option (2) and (3) to improve my code. But out of curiosity, I would still like to know why does an object of a Python-class consume so much of memory (1.4 kb), and this

Re: Tree structure consuming lot of memory

2009-07-06 Thread Antoine Pitrou
mayank gupta mooniitk at gmail.com writes: After a little analysis, I found out that in general it uses about 1.4 kb of memory for each node!! How did you measure memory use? Python objects are not very compact, but 1.4KB per object seems a bit too much (I would expect more about 150-200

Re: Tree structure consuming lot of memory

2009-07-06 Thread mayank gupta
I worked out a small code which initializes about 1,000,000 nodes with some attributes, and saw the memory usage on my linux machine (using 'top' command). Then just later I averaged out the memory usage per node. I know this is not the most accurate way but just for estimated value. The kind of

Re: Tree structure consuming lot of memory

2009-07-06 Thread Chris Rebert
On Tue, Jul 7, 2009 at 1:28 AM, Antoine Pitrou solip...@pitrou.net wrote: mayank gupta mooniitk at gmail.com writes: After a little analysis, I found out that in general it uses about 1.4 kb of memory for each node!! How did you measure memory use? Python objects are not very compact,

Re: How to request data from a lazily-created tree structure ?

2008-08-02 Thread méchoui
On 17 juin, 13:53, méchoui [EMAIL PROTECTED] wrote: On Jun 17, 9:08 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: Yes, I need to make sure my requests are properly written so that the generic XPath engine does not need all the structure in memory. There are quite a few cases where

Re: How to request data from a lazily-created tree structure ?

2008-06-23 Thread méchoui
On Jun 17, 11:54 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Do you know if there is suchXPathengine that can be applied to a DOM- like structure ? No. But I toyed with the idea to write one :) One way would be to take anXPathengine from an existing XML engine (ElementTree, or any

Re: How to request data from a lazily-created tree structure ?

2008-06-20 Thread méchoui
On Jun 17, 10:54 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: Do you know if there is such XPath engine that can be applied to a DOM- like structure ? No. But I toyed with the idea to write one :) One way would be to take an XPath engine from an existing XML engine (ElementTree, or any

Re: How to request data from a lazily-created tree structure ?

2008-06-17 Thread Diez B. Roggisch
Yes, I need to make sure my requests are properly written so that the generic XPath engine does not need all the structure in memory. There are quite a few cases where you really don't need to load everything at all. /a/b/*/c/d is an example. But even with an example like /x/z[last()]/t, you

Re: How to request data from a lazily-created tree structure ?

2008-06-17 Thread méchoui
On Jun 17, 9:08 am, Diez B. Roggisch [EMAIL PROTECTED] wrote: Yes, I need to make sure my requests are properly written so that the generic XPath engine does not need all the structure in memory. There are quite a few cases where you really don't need to load everything at all. /a/b/*/c/d

Re: How to request data from a lazily-created tree structure ?

2008-06-17 Thread Diez B. Roggisch
Do you know if there is such XPath engine that can be applied to a DOM- like structure ? No. But I toyed with the idea to write one :) One way would be to take an XPath engine from an existing XML engine (ElementTree, or any other), and see what APIs it calls... and see if we cannot create

How to request data from a lazily-created tree structure ?

2008-06-16 Thread méchoui
Problem: - You have tree structure (XML-like) that you don't want to create 100% in memory, because it just takes too long (for instance, you need a http request to request the information from a slow distant site). - But you want to be able to request data from it, such has give me all nodes

Re: How to request data from a lazily-created tree structure ?

2008-06-16 Thread Diez B. Roggisch
méchoui schrieb: Problem: - You have tree structure (XML-like) that you don't want to create 100% in memory, because it just takes too long (for instance, you need a http request to request the information from a slow distant site). - But you want to be able to request data from it, such has

Re: How to request data from a lazily-created tree structure ?

2008-06-16 Thread méchoui
On Jun 16, 11:16 pm, Diez B. Roggisch [EMAIL PROTECTED] wrote: méchoui schrieb: Problem: - You have tree structure (XML-like) that you don't want to create 100% in memory, because it just takes too long (for instance, you need a http request to request the information from a slow