Skip to content

A Java library for generating grammatical mistakes in natural language text.

License

Notifications You must be signed in to change notification settings

manzurola/errgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Errgent - Grammatical Error Generation Toolkit 🤖

maven

Generate grammatical mistakes in natural language text.

Article - Errgent - Grammatical Error Generator.

Prerequisits

Before you begin, ensure you have met the following requirements:

  • You have Java 11 installed.
  • You have the necessary prerequisites for Errant4J.

Installing Errgent

Add this to the dependencies section of your pom.xml:

<dependency>
  <groupId>io.github.manzurola</groupId>
  <artifactId>errgent</artifactId>
  <version>0.3.0</version>
</dependency>

Using Errgent

To use Errgent in code, follow these steps:

// Create a spacy instance (from spaCy4j)
SpaCy spacy = SpaCy.create(CoreNLPAdapter.forEnglish());

// Instantiate a new Errgent for English
Generator errgent = Errgent.forEnglish(spacy);

// Generate a specific grammatical error in the target doc. Since a
// sentence can contain multiple errors at once, all such possible
// errors are returned.
List<GeneratedError> generatedErrors = errgent.generateErrors(
    "If I were you, I would go home.",
    GrammaticalError.REPLACEMENT_SUBJECT_VERB_AGREEMENT
);

// Print out the results. The markedText() method retrieves the
// erroneous text with the error marked by an asterisk on both sides.
// We can also access the char offsets of the error using charStart
// and charEnd methods of GeneratedError.
for (GeneratedError generatedError : generatedErrors) {
    String text = generatedError.markedText();
    System.out.printf(
        "%s, %s%n",
        text,
        generatedError.error()
    );
}

Errgent is currently available only for English.

Contributions

To contribute to Errgent, follow these steps:

  1. Fork this repository.
  2. Create a branch: git checkout -b <branch_name>.
  3. Make your changes and commit them: git commit -m '<commit_message>'
  4. Push to the original branch: git push origin <project_name>/<location>
  5. Create the pull request.

Alternatively see the GitHub documentation on creating a pull request.

Contributors

Thanks to the following people who have contributed to this project:

Contact

If you want to contact me you can reach me at guy.manzurola@gmail.com.

License

This project uses the following license: MIT.