peniscake / simplenlg

Automatically exported from code.google.com/p/simplenlg
0 stars 0 forks source link

Getting a word from the lexicon, then adding a feature, causes that feature to be present if the same word is then got from the lexicon again. #17

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
WordElement tree1 = lexicon.getWord("tree");
System.out.println(realiser.realise(tree1));  // tree

tree1.setFeature(Feature.NUMBER, NumberAgreement.PLURAL);
System.out.println(realiser.realise(tree1)); // trees

WordElement tree2 = lexicon.getWord("tree");
System.out.println(realiser.realise(tree2)); // trees

The solution would be to make a copy of the word when retrieving from the 
lexicon, rather than use the original. Note that this isn't picked up in the 
unit tests because the lexicon is created fresh for each test, rather than 
recycled. 

Original issue reported on code.google.com by o...@steamshift.net on 28 Feb 2012 at 6:17

GoogleCodeExporter commented 8 years ago
I'm not entirely sure what your context is, but in general if you want to set 
features, you should use InflectedWordElement,  That is, create an 
InflectedWordElement from the WordElement, and then set features on the 
InflectedWordElement.  Do not change a WordElement, for exactly the reason 
mentioned above

Original comment by ehud.rei...@gmail.com on 7 Mar 2012 at 8:28

GoogleCodeExporter commented 8 years ago
Thanks for the reply. I've been converting simplenlg to Actionscript and have 
set it up to reuse the lexicon, to avoid having to reparse it each time its 
called (also Actionscript doesn't support synchronous loading of data so the 
unit tests couldn't be run that way).

When running the unit tests with this setup, some of the tests fail due to the 
problem I described above. So, from what you're saying, this is a problem with 
the unit tests, rather than with the engine?

Original comment by o...@steamshift.net on 7 Mar 2012 at 9:49