GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Re-attaching a node both in the basic tree and in the enhanced graph · Issue #112 · udapi/udapi-python

Re-attaching a node both in the basic tree and in the enhanced graph #112

New issue
Copy link
New issue
Copy link
Open
Open
Re-attaching a node both in the basic tree and in the enhanced graph#112
Copy link
Labels
enhancement

Description

@dan-zeman
dan-zeman
opened on Feb 13, 2023
Issue body actions

I have repeatedly encountered the following situation: A small change is needed for a batch of nodes, such as changing the DEPREL (or both the HEAD and the DEPREL) for a node that satisfies a condition. Typically I do it directly from the commandline, using udapy -s util.Eval node='if CONDITION: node.parent = X; node.deprel = Y'. Now if the treebank contains enhanced dependencies, the same change should (typically) be also made in the enhanced graph. I usually forget to do it properly but when I want to do it, it is not as simple as the change in the basic tree. I wrote the code below in some of my blocks where I had to do it but I don't like having to repeat the code in several blocks again and again, and can hardly use it in util.Eval from commandline:

    def reattach(self, node, parent, deprel):
        """
        Changes the incoming dependency relation to a node. Makes sure that the
        same change is done in the basic tree and in the enhanced graph.
        """
        if node.deps:
            # If the enhanced graph contains the current basic relation, remove it.
            # Note that the enhanced deprel may contain subtypes that are not in the basic deprel.
            orig_n_deps = len(node.deps)
            node.deps = [x for x in node.deps if x['parent'] != node.parent or re.sub(r':.*', '', x['deprel']) != node.udeprel]
            # Add the new basic relation to the enhanced graph only if the original one was there.
            if len(node.deps) < orig_n_deps:
                node.deps.append({'parent': parent, 'deprel': deprel})
        node.parent = parent
        node.deprel = deprel

Would it make sense to have something similar in the core code, as a method of Node?

Activity

  1. dan-zeman
    added
    enhancement
    on Feb 13, 2023
  2. dan-zeman commented on Feb 13, 2023

    @dan-zeman
    dan-zeman
    on Feb 13, 2023
    CollaboratorAuthor
    More actions

    Related but more specific: #47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.