question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Position of a node

See original GitHub issue

Hi Goodman.

Does the penman library have a method to return the position of each node in the graph? Ex. (w / want-01 :ARG0 (b / boy) :ARG1 (g / go-01 : ARG0 b)) want-01 - 0 boy - 0.0 go-01 - 0.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
goodmamicommented, May 6, 2020

Ok, I’ve reconsidered this and changed Tree.positions() to Tree.walk() which yields paths to branches. That is, it should yield one pair for every branch in the tree structure. This is still not exactly the same as the alignment annotations, but this is more general and should be able to be applied to alignment annotation conversion. Here’s an example:

>>> import penman
>>> t = penman.parse('''
... # ::tok I swam in the lake .
... (s / swim-01~e.1
...    :ARG0 (i / i~e.0)
...    :location~e.2 (l / lake~e.4))''')
>>> for path, branch in t.walk():
...     print(path, branch)
... 
(0,) ('/', 'swim-01~e.1')
(1,) (':ARG0', ('i', [('/', 'i~e.0')]))
(1, 0) ('/', 'i~e.0')
(2,) (':location~e.2', ('l', [('/', 'lake~e.4')]))
(2, 0) ('/', 'lake~e.4')

Note that the top node doesn’t have an index, because these are indices of branches. They are 0-based but the concept is included as a branch, so it looks like 1-based indices. Here’s an example of how you could get most of the way to the alignment metadata format:

>>> from penman.tree import is_atomic
>>> for path, branch in t.walk():
...     if is_atomic(branch[1]):
...         if path[-1] == 0:
...             path = path[:-1]
...         path = '.'.join(map(str, (1,) + path))
...         print(path, branch[1])
... 
1 swim-01~e.1
1.1 i~e.0
1.2 lake~e.4

To get the rest of the way would require parsing the alignment info from the roles or concepts. The AlignmentMarker.from_string() function would help here. Also one would need to consider role alignments on branches whose target is not atomic.

@rafaelanchieta does this look better?

0reactions
rafaelanchietacommented, May 8, 2020

It’s great. I’ll close the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Position Node — Blender Manual
Position node. The Position node outputs a vector of each point of the geometry the node is connected to. The node can work...
Read more >
Position Node - Foundry Learn
The Position node outputs position information in 3D space. Using the 3D node on its own is not useful as it only shows...
Read more >
17.2.1 Nodes and node positions
There are two basic kinds of satellite nodes: geostationary and non-geostationary satellite nodes. In addition, terminal nodes can be placed on the Earth's ......
Read more >
Find Level wise positions of given node in a given Binary Tree
Perform level order traversal of given Binary Tree using Queue. Keep track of level count and the count of nodes from left to...
Read more >
Setting the position of a node - IBM
Use the IBM® Integration API to set the position of a node on the canvas in the Application Development view. Set the position...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found