Generate grammatical mistakes in natural language text.
Article - Errgent - Grammatical Error Generator.
Before you begin, ensure you have met the following requirements:
- You have Java 11 installed.
- You have the necessary prerequisites for Errant4J.
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>
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.
To contribute to Errgent, follow these steps:
- Fork this repository.
- Create a branch:
git checkout -b <branch_name>
. - Make your changes and commit them:
git commit -m '<commit_message>'
- Push to the original branch:
git push origin <project_name>/<location>
- Create the pull request.
Alternatively see the GitHub documentation on creating a pull request.
Thanks to the following people who have contributed to this project:
If you want to contact me you can reach me at guy.manzurola@gmail.com.
This project uses the following license: MIT.