Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"a" modifier doesn't account for cases like "useful" #32

Open
serin-delaunay opened this issue Feb 16, 2017 · 4 comments
Open

"a" modifier doesn't account for cases like "useful" #32

serin-delaunay opened this issue Feb 16, 2017 · 4 comments

Comments

@serin-delaunay
Copy link

In this grammar:

{
	"start": "#noun_phrase.a#",
	"noun_phrase": "useful tool like Tracery"
}

The expected output from start would be "a useful tool like Tracery", but instead we get "an useful tool like Tracery". I haven't tried Tracery 2, but looking at its altered a function I think the problem would remain (since the third letter isn't i).

The most reliable function I've found to do this job is in inflect.py, although its regex usage isn't especially readable.

@Discordanian
Copy link

Regex could be expanded to use an "a" instead of an "an" for any /use.*/g match.

@serin-delaunay
Copy link
Author

The issue is slightly wider than the use prefix; "usable", "usurping", "usual", "uninformed", "unintelligent", "uninspected", "uninteresting" are all (probably, I'm on my phone) unaccounted for in the present scheme.

@mycaule
Copy link

mycaule commented Dec 2, 2017

The rule to check if first letter is vowel or not is wrong but cover most of cases as mentioned in the Stack Exchange question. Choosing between a and an depend on the pronunciation rather that the spelling.

a house
a unique
a US dollar
an FBI agent

Basically you have to implement your own language modifier if you want to have specific language features in your app.

You can't cover the complexity of the English language rules in just a few lines of code, the modifier in this repo is just a template.

I forked the project and I am working on extracting the modifiers stuff to let people build their own. See https://github.com/mycaule/epures/tree/master/modifiers

The methodology should be to write lots of unit tests to make sure the language rules you want --but sadly not every rules-- are covered by the code.

@mycaule
Copy link

mycaule commented Dec 6, 2017

In JS language rules are implemented in the library natural for example. See "stemmers"
https://github.com/NaturalNode/natural/tree/master/lib/natural/stemmers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants