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

Error stemming in Dutch and Spanish #18

Closed
mateonunez opened this issue Jul 16, 2022 · 1 comment · Fixed by #25
Closed

Error stemming in Dutch and Spanish #18

mateonunez opened this issue Jul 16, 2022 · 1 comment · Fixed by #25
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mateonunez
Copy link
Collaborator

mateonunez commented Jul 16, 2022

Describe the bug
When using the PorterStemmerNl and PorterStemmerEs, natural module can't resolve the following methods: postlude() and isVowel().

PorterStemmerNl:

 TypeError: Cannot read property 'postlude' of undefined

      51 |   }
      52 |
    > 53 |   return input.map(stemmer.stem);
         |                ^
      54 | }
      55 |

postule() returns the word in lowercase

PorterStemmerEs:

    TypeError: Cannot read property 'isVowel' of undefined

      51 |   }
      52 |
    > 53 |   return input.map(stemmer.stem);
         |                ^
      54 | }
      55 |

To Reproduce
Steps to reproduce the behavior:

  1. Create a new test
  2. Add the following code:

PorterStemmerNl:

  it("Should stem correctly in dutch", async () => {
    // some words in dutch
    const input: string[] = ["banken"];

    // the expected output
    const expected = ["bank"];

    const output = stemArray(input, "dutch");

    expect(output).toEqual(expected);
  });

PorterStemmerEs:

  it("Should stem correctly in spanish", async () => {
    // some words in spanish
    const input: string[] = ["avenida"];

    // the expected output
    const expected = ["aven"];

    const output = stemArray(input, "spanish");

    expect(output).toEqual(expected);
  });

Desktop (please complete the following information):

  • OS: Windows 11
  • Environment: Jest
  • Node: v18.6.0
  • pnpm: v7.5.1
  • Lyra: v0.0.1-beta-10

Possible solution

I was testing some solutions for this issue, and I've found that the error is caused when the stemArray method passes the reference of the stem method to the input.map()

return input.map(stemmer.stem);

Fixing typos, and extending the map to force the execution of stem method, the stem method works as expected.

I've published a repo with the possible solution and the stemmer tests.

@micheleriva
Copy link
Member

Thank you so much for the report, I'll look into that!

@micheleriva micheleriva added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants