Search code examples
qttreepyqtnlpqtreeview

Representing a Syntax Tree with QTreeview


I'm studying on my master thesis and I'm to implement an application finding deep syntactic relations (in future we hope to use these to generate semantic relations) for Turkish texts.

I've prepared an interface with PyQt for our application and we need a visualization module representing a syntax tree for each sentence in our corpus, in a specified format.

A hand drown example syntax tree with morphological features for each word is:

https://i.sstatic.net/Zhj7D.png

Since already using Qt gui toolkit, I think, a quick way can be making use of Qtreeview for this purpose. But apperently, classic Qtreeview for filesystem needs some customizations.

Minimum expectations for tree items are:

  1. a label for each connection to a node (if not possible, this can be added in node icons)
  2. an icon for each intermediate node and root node
  3. (an icon + a morphological features box) for each leave node

My question is how it can be implement such a representation with QTreeview. Especially for leave nodes, how can we generate a morphological features box?

If you have an idea guys, and give a small example, I'd be happy ^_^ Thanks for everyone read and think about this question...


Solution

  • I don't think this is possible with QTreeView.

    Look into QGraphicsScene and QGraphicsView. These classes should be a very good solution for what you intend to do.

    The Diagram Scene Example will be helpful.