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

Is toNumbers supposed to mutate data? #1113

Open
spencermountain opened this issue Jun 4, 2024 Discussed in #1112 · 2 comments
Open

Is toNumbers supposed to mutate data? #1113

spencermountain opened this issue Jun 4, 2024 Discussed in #1112 · 2 comments

Comments

@spencermountain
Copy link
Owner

Discussed in #1112

Originally posted by scpedicini June 3, 2024
I think I'm doing something wrong with the newer compromise/three. termList/out/etc. works great, but if I use them in conjunction with toNumbers the data seems to mutate in place.

Trying to do this:

const text_1 = "There are twenty-four apples and 12000 oranges on the table.";
const nat = nlp(text_1);

const number_of_numerical_values = nat.values().length;
// shows a length of two which is what we would expect so far so good

const termList_1 = nat.values(0).toNumber().termList();
console.log(termList_1);
// termList_1 has converted the number "twenty-four" to "24" but also has
// `"apples", "and", "12000", "oranges", "on", "the", "table"` in array

// rerun exact same command
const termList_2 = nat.values(0).toNumber().termList();
console.log(termList_2);
// termList_2 now has the expected array of just "3" 
// converted to numerical

I basically want to go through each numerically recognized "group" hence using the .values() command and use the toNumbers() command to reduce them down to the numerical number.

Picture to help indicate the issue:

CleanShot 2024-06-03 at 21 55 07@2x

@scpedicini
Copy link

@spencermountain Thanks for taking a look. Just wanted to add some information around this as well - near as I can tell it happens pretty consistently with out, json, termList, etc.

const nat = nlp('There were 24 apples and 12000 oranges on the table.');

CleanShot 2024-06-04 at 12 29 44@2x

@spencermountain
Copy link
Owner Author

hey, i think this has been fixed in 14.14.0 - can you update and take a look?
Will keep this open, cheers.

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

No branches or pull requests

2 participants