inukshuk / anystyle

Fast citation reference parsing
https://anystyle.io
Other
1.05k stars 90 forks source link

Using multiple Training models in the same application #147

Open dominic01 opened 4 years ago

dominic01 commented 4 years ago

I am trying to create a different model for German references. Couple of years back (#72 )I had checked here but did not use it. Kindly let me know how to do it in the latest version?

inukshuk commented 4 years ago

You can create different parser instances, based on different models, normalizers, etc. AnyStyle::Parser.new model: './german.mod'

dominic01 commented 4 years ago

In my current setup I have a simple service running. Is it a correct way of creating a parser instance and using it. Sorry I am not a ruby person and I am learning.

enparser = AnyStyle::Parser.new model: './en.mod'
deparser = AnyStyle::Parser.new model: './de.mod'

loop through the list
        dataset = enparser.parse("my english reference here", format: :wapiti)
        puts dataset.to_xml;

        dataset = enparser.parse("my german reference here", format: :wapiti)
        puts dataset.to_xml;
end loop

If I have the AnyStyle::Parser inside the loop, then does it create the parser instance every time.

inukshuk commented 4 years ago

This looks good. The .new call creates a new parser instance.