Question

I am trying to implement TSurgeon on a standford parse tree (from the core-nlp api). What my intended action will do is add a prefix to the node that I find (e.g. the node found is NN and I would like to rename it to Skip-NN)

What I am trying is this:

TsurgeonPattern surgery = Tsurgeon.parseOperation("relabel target Skip-target");
for (TregexPattern pat : patterns) {
    Tsurgeon.processPattern(pat, surgery, tree).pennPrint();
}

An example of one the TregexPattern's used would be NP << NP=target

Although as you might of guessed the result is similar to:

NP -> "Skip-target" instead of NP -> "Skip-NP"

I am quite new to using TSurgeon and am unsure as to where to look for information regarding an issue like this.

EDIT: Essentially what I'm asking; is there a way to use the current label of a node when relabeling it.

Was it helpful?

Solution

You should be able to use regexes for this. Something like

relabel target /^(.*)$/Skip-$1/

Though you will have to be careful with your pattern, it will have to ignore nodes beginning with Skip-.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top