Title: Re-attaching a node both in the basic tree and in the enhanced graph · Issue #112 · udapi/udapi-python · GitHub
Open Graph Title: Re-attaching a node both in the basic tree and in the enhanced graph · Issue #112 · udapi/udapi-python
X Title: Re-attaching a node both in the basic tree and in the enhanced graph · Issue #112 · udapi/udapi-python
Description: 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 th...
Open Graph Description: 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 condi...
X Description: 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 condi...
Opengraph URL: https://github.com/udapi/udapi-python/issues/112
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Re-attaching a node both in the basic tree and in the enhanced graph","articleBody":"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:\r\n\r\n```python\r\n def reattach(self, node, parent, deprel):\r\n \"\"\"\r\n Changes the incoming dependency relation to a node. Makes sure that the\r\n same change is done in the basic tree and in the enhanced graph.\r\n \"\"\"\r\n if node.deps:\r\n # If the enhanced graph contains the current basic relation, remove it.\r\n # Note that the enhanced deprel may contain subtypes that are not in the basic deprel.\r\n orig_n_deps = len(node.deps)\r\n node.deps = [x for x in node.deps if x['parent'] != node.parent or re.sub(r':.*', '', x['deprel']) != node.udeprel]\r\n # Add the new basic relation to the enhanced graph only if the original one was there.\r\n if len(node.deps) \u003c orig_n_deps:\r\n node.deps.append({'parent': parent, 'deprel': deprel})\r\n node.parent = parent\r\n node.deprel = deprel\r\n```\r\n\r\nWould it make sense to have something similar in the core code, as a method of Node?","author":{"url":"https://github.com/dan-zeman","@type":"Person","name":"dan-zeman"},"datePublished":"2023-02-13T18:06:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/112/udapi-python/issues/112"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:893e75f0-10f5-c0aa-a295-cbb5d26c3b65 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C758:18D1D3:87E2CE6:B2E02C5:696DE127 |
| html-safe-nonce | 93b0fdc8d716a50cd29d1d64f39c6a2e00eed8a44c7b95dd84c6457a7c793f27 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzU4OjE4RDFEMzo4N0UyQ0U2OkIyRTAyQzU6Njk2REUxMjciLCJ2aXNpdG9yX2lkIjoiMTYyNjU0Nzc4Nzk5MTQ3NDQ3MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 720e08581d23ed6f0a85d85ab1dcfd40691e5c3c528be1bbfc8ca561415999cb |
| hovercard-subject-tag | issue:1582819685 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/udapi/udapi-python/112/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4b039dfe793480c11970c5f2f13e675ad0927910553513b7c66449779beb0827/udapi/udapi-python/issues/112 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4b039dfe793480c11970c5f2f13e675ad0927910553513b7c66449779beb0827/udapi/udapi-python/issues/112 |
| og:image:alt | 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 condi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dan-zeman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4922b452d03cd8dbce479d866a11bc25b59ef6ee2da23aa9b0ddefa6bd4d0064 |
| turbo-cache-control | no-preview |
| go-import | github.com/udapi/udapi-python git https://github.com/udapi/udapi-python.git |
| octolytics-dimension-user_id | 19330164 |
| octolytics-dimension-user_login | udapi |
| octolytics-dimension-repository_id | 58709861 |
| octolytics-dimension-repository_nwo | udapi/udapi-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 58709861 |
| octolytics-dimension-repository_network_root_nwo | udapi/udapi-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7e5ae23c70136152637ceee8d6faceb35596ec46 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width