yzhangcs / parser

:rocket: State-of-the-art parsers for natural language.
https://parser.yzhang.site/
MIT License
832 stars 141 forks source link

Partial Parsing #130

Closed James-Decatur closed 11 months ago

James-Decatur commented 1 year ago

Hello,

I've noticed that you have partial training and partial evaluation, but not partial prediction. I have a treebank/corpus with partially completed trees, with labels and arcs I know are right, and I want the parser to work from there and predict the rest. Is this possible?

Thanks, James

yzhangcs commented 1 year ago

@James-Decatur Hi, it's indeed possible. You just need to populate the scores of incorrect arcs/rels with -INF. Unfortunately, I can't add this to the pkg for the consistency of API interfaces (we can't access the gold annotations during prediction). You can impl it by yourself with just a few lines of code :)

TIPS: you could still get partial annotated rels by [self.REL.vocab[rel] for rel in batch.sentences[0].rels] and the same applies to arcs.

James-Decatur commented 3 weeks ago

Hello again,

I'm having the hardest of time figuring out how to pass the gold annotations to the Training and Prediction processes. Can you tell me where the parameters that are getting passed to Eval, Training, and Prediction are coming from? I just want to give the processes everything and go from there.

parser/supar/models/dep/biaffine/parser.py

def predstep(self, batch: Batch) -> Batch: words, , *feats, arcs, rels = batch

Where are the gold annotations? What's the file name and location? What is stopping them from being passed?