GrammaticalFramework / gf-ud

Functions to analyse and manipulate dependency trees, as well as conversions between GF and dependency trees. The main use case is UD (Universal Dependencies), but the code is designed to be completely generic as for annotation scheme. This repository replaces the old gf-contrib/ud2gf code. It is also meant to be used in the 'vd' command of GF and replace the supporting code in gf-core in the future.
Other
7 stars 15 forks source link

Feature request: pattern matching also on XPOS and MISC #28

Closed harisont closed 2 years ago

anka-213 commented 2 years ago

XPOS should be very easy to support by adding a line like this one: https://github.com/GrammaticalFramework/gf-ud/pull/20/commits/4341c191a0242ef2982fa2097c7fac8613ade712#diff-12651df4054da1b029e0811529affcce8cb4276ec21bc4c9d55f28f1e9c99a17R501-R502 (The above fix is only for UD2GF. A little bit of additional work would be needed for gf2ud.)

MISC might require some new syntax, since a MISC item can contain multiple sub-attributes and you might want to match against just a subset of them. The simplest solution I can think of would be to put a "MISC-" prefix on each such attribute and then match against them like any other attribute/feature.

E.g., For the example from here, we could match it with head[MISC-CORRECTION=deep]. Does that sound good?

Do you need support for both the gf2ud and the ud2gf direction or just one?

harisont commented 2 years ago

For the example from here, we could match it with head[MISC-CORRECTION=deep]. Does that sound good?

Indeed! I was thinking myself of something similar (and I guess I can try to implement this myself some time next week).

Do you need support for both the gf2ud and the ud2gf direction or just one?

I'm not sure what you mean here, doesn't pattern matching apply only to UD trees? How does it relate to the conversion?

anka-213 commented 2 years ago

doesn't pattern matching apply only to UD trees?

You're probably right. I'm not very familiar with how gf2ud works, so I just wanted make sure I'm not missing anything important. (I was thinking if the feature tags you would write in a labels file would be used to generate feature tags in ud when running gf2ud)

harisont commented 2 years ago

Now that I look at this in depth (sorry for the delay! something came up), I realize there has been a misunderstanding.

I refer to pattern matching as in gf-ud pattern-match PATTERN (see README), which requires changes mostly (only?) here.

This explains why you asked me what "direction" I needed and why the question sounded strange to me.

Also, now that I think about it, when I say pattern matching I really mean both pattern matching and pattern replacement, even though right now I only need the former.

But again, if you want I can try and implement this myself as soon as I have some time, which I should next week if not already in the weekend.

anka-213 commented 2 years ago

Ah, I see! I wasn't aware of that feature, hence the confusion.

anka-213 commented 2 years ago

I've added the feature to pattern matching in that branch now. You can test it out again

harisont commented 2 years ago

Perfect, thanks :)