Skip to content

Unexpected Verb Normalization Behavior Inside .forEach() Loop #1171

@rossroma

Description

@rossroma

When using normalize verbs within a .forEach() loop, the output is not as expected. Specifically, the term 'are' in the phrase 'books are not' becomes 'books be not' after normalization inside the loop, whereas the same normalization outside the loop works correctly and returns 'be'.

Version 14.4.4

Steps to reproduce:

  1. Run the following code:
const nlp = require('compromise');

nlp('books are not').terms().forEach(word => {
  const result = word.normalize({
    verbs: true
  }).text();
  console.log('forEach output =>', result);
});

const result = nlp('are').normalize({
  verbs: true
}).text();
console.log('single output => ', result);
  1. Observe the output:
    • forEach output => books
    • forEach output => books be not
    • forEach output => not
    • single output => be

Expected Behavior:

The normalization inside the .forEach() loop should return the expected normalized verb form (e.g., 'be'), similar to how it behaves when called directly outside the loop.

Actual Behavior:

When normalize() is applied inside the .forEach() loop, the result is 'books be not', which is not the expected behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions