Huey
Huey

Reputation: 5220

How do I pluralize or singularize multiple nouns?

I'm using the excellent nlp-compromise module for NLP.

I'm stuck at what should be a rather straightforward process: pluralizing or singularizing all nouns.

So far, I've got this:

let a = nlp("apples, oranges, pears")
a.nouns().toSingular()
a.out("text")

However, this returns

apple, oranges, pears

Whilst what I really want is

apple, orange, pear

Runkit here

Upvotes: 0

Views: 952

Answers (2)

spencercooly
spencercooly

Reputation: 6636

this was a bug that just got fixed in v10.6.0.

https://runkit.com/spencermountain/595e48ab230e340012e1d314

(especially) with the commas, they are indeed three nouns, which all now inflect individually.

thanks for your help.

Upvotes: 1

Huey
Huey

Reputation: 5220

I've poured over the limited documentation without much success. However, I've stumbled upon a workaround of sorts:

a.match("#Noun").nouns().toSingular()

This appears to match all the nouns, instead of just the first one, returning

apple, orange, pear

Runkit here

Upvotes: 1

Related Questions