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.

Gorn Address of a Graph Triple

See original GitHub issue

I have some alignment code that iterates through the triples in a graph to find the alignments between nodes (or edges) and words. This generally works and I can easily add the surface alignments (ie ~e.3) to the epidata since I already have the triple in the iteration loop. The issue is in creating the metadata alignment string (using the ISI/LDC2020T02 format). To form the string I need the Gorn address that represents the triple. I’ve seen #74 and I adapted the code at the end to create a lookup for instances, edges and attributes, which then could be used to find triples. Something like…

def get_addrress_dicts(tree):
    node_dict = {}
    attr_dict = {}
    edge_dict = {}
    for path, branch in tree.walk():
        # Get the node and attribute addresses
        if is_atomic(branch[1]):
            address = '.'.join(map(str, path))
            concept = branch[1]
            if concept.startswith('"'):
                attr_dict[address] = concept
            else:
                node_dict[address] = concept
        # Get the edge addresses
        if is_atomic(branch[0]) and branch[0] != '/':
            address   = '.'.join(map(str, path))
            edge_name = branch[0]
            edge_dict[address] = edge_name
    return node_dict, attr_dict, edge_dict

BTW… the ISI convention for edges is to append a .r onto the address (ie… 7-1.2.1.r) and use the address of the node it’s attached to.

The issue is that edges and attributes names aren’t unique so a lookup here by name alone, isn’t sufficient. In addition, it seems like a lot of messy coding to take a graph, re-parse it into a tree, then walk it to create a bunch of dictionaries to get the addresses to match-up to the triple. Any suggestions on a better way to do this? Ideally I’d create two functions, triple_to_address() and address_to_triple() since eventually for test/eval I’ll probably need to take an alignment and get the triple it represents.

In a semi-related question… are the triples ordered and specific way? Right now I’m just looping through graph.triples when searching for alignments. However, the ordering will potentially impact my alignment code for instances when there’s more than one instance of a word. I think I need an ordering that follows (loosely) a depth first search.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bjascobcommented, Sep 21, 2020

Thanks for the great info. Getting the surface alignments by stripping the ~e.X should be fairly trivial so I don’t think we need to add code to the lib for that alone. I’ll try a few things and see where I end up and let you know. This part of some other work so it may be a little bit before I have something fully functional.

0reactions
goodmamicommented, Sep 23, 2020

Ok sounds good. And thanks for the link to amrlib. It looks nice!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Language Theoretic Properties of Graph Extension Languages
Input graph for running time experiments with c = 2,3. ... illustration every node has its Gorn address attached as a label in...
Read more >
Chapter 3. Basic graphing - Using the TI-84 Plus, Second ...
This chapter covers. How to graph functions and solve problems with graphs on your calculator; Finding minima, maxima, values, intercepts, zeroes, and more ......
Read more >
Deadlock Avoidance in Parallel Programs with Futures
Gorn —the implementation of KJ—outperforms standard deadlock avoidance based on cycle detection.2 Gorn verified a dataset of ∼2,300 student's homework ...
Read more >
Polynomial Graph Parsing with Non-Structural Reentrancies
We refer to the subtrees of a tree by their Gorn addresses. ... In Figure 4, we see three different graphs, all resulting...
Read more >
What is a triple? | Fundamentals with Oxford Semantic ...
Triples (also known as facts) are a way to express graph data. A triple consists of three components: A subject, a predicate, and...
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