rita icon indicating copy to clipboard operation
rita copied to clipboard

RiTa.hasWord() should return true for plurals and conjugations

Open dhowe opened this issue 4 years ago • 8 comments

RiTa.hasWord('dog')  // is true
RiTa.hasWord('dogs') // is false, should be true

would also be nice to add an isStem(input) function, which returns true if stemming a word in the dictionary return the input word

dhowe avatar Jun 14 '21 13:06 dhowe

+1 for isStem(input) which should, it seems, just have the current behavior of hasWord()

shadoof avatar Jun 14 '21 14:06 shadoof

hmm not sure if this is the best way but I did this: RiTa.hasWord(word) will call RiTa.lexicon().hasWord(word, true, false) which now take three parameters: word, fatal, strict, strict is newly added, if true, will not allow plurals and conjugations isStem(word) will return true if 1. word is in the dictionary (with strict mode) & 2. it is the same after stemming

Real-John-Cheung avatar Jun 15 '21 14:06 Real-John-Cheung

@Real-John-Cheung this seems problematic to me:

RiTa.isStem(RiTa.stem("change")) // returns false

dhowe avatar Jun 16 '21 03:06 dhowe

maybe we can do something like this https://github.com/dhowe/ritajs/blob/141ad6c6f2cf454e79c5fed023deddd1593014ba/src/conjugator.js#L208 for isStem() too...

Real-John-Cheung avatar Jun 16 '21 12:06 Real-John-Cheung

@Real-John-Cheung status?

dhowe avatar Aug 23 '21 03:08 dhowe

@dhowe not sure if I get the idea correctly... So now we have hasWord() that returns true when the base form of the input is in the dictionary and isStem() should have the behavior that returns true when the input is the result of stem(aWordInTheDictionary)? e.g isStem(RiTa.stem(change)) should return true and isStem("change")should return false

Real-John-Cheung avatar Aug 23 '21 12:08 Real-John-Cheung

hasWord(word, opts) should return true if the word is in the dictionary OR it is a derivation of a dictionary word, unless opts.noDerivations is set to true

isStem(word) should return true if calling stem() on some dictionary word, or its derivation, returns that word

isStem('chang') -> true because calling stem('change') -> 'chang' and 'change' is in the dictionary

isStem('change') -> false because there is no word W for which calling stem(W) returns 'change'

Note: it is not clear to me how to implement isStem() in a correct/efficient way

dhowe avatar Aug 23 '21 16:08 dhowe

isStem() now available via RiTa.lexicon().isStem(word)

dhowe avatar Sep 05 '21 14:09 dhowe