This is ITO（takahi_i）from ATL.
Last time when I introduced RedPen, its version was 0.6. Now, the version 1.2 has been released with many big improvements.
In this article I will try to cover the features of RedPen server.
RedPen was designed to use only command line when it was released, but now we put more emphasis into development of server features. RedPen server provides REST API in addition to Web UI. By using REST API, users can check documents without installing RedPen into a local environment. Therefore, one of the features of RedPen server API is customizable settings. Users can validate documents that need to adhere to a writing standard (configuration file). RedPen server can be built with a few clicks by using the Heroku button. I will talk about how to build the server in a later part.
RedPen server Web UI
You can try the latest RedPen server at the following URL.
The following is the current Web UI of RedPen server.
When you access to the URL, you will see a sample text in the left box, which includes some mistakes. The errors are detected by RedPen, and the errors are shown with red underline. In the left bottom box, the explanation of errors is shown. Try to enter a document in the left upper box, so you will see the validation result. The document pasted to the box is editable. RedPen server automatically starts detecting when the document gets edited.
Moreover, in the right box, you can set RedPen; a Validator and a Symbol. Please refer to the RedPen manual for more setting information.
RedPen Server REST API
RedPen server provides REST API. By making use of REST API, users can use RedPen features without installing it to a local environment. Now, RedPen server API provides 3 features.
Validate a document along with user’s settings, and returns the result.
The feature is the same as /document/validate, but this setting is in JSON format.
Validate a document by RedPen set by each language in advance. This feature cannot validate a document on a different adhered writing standard by users’ and groups’. So, I cannot recommend using Red Pen with a version 1.2 and later. Please refer to the RedPen manual for more feature information. Let’s use /document/validate now.
Sample：REST API (/doument/validate)
/document/validate contains the following parameters.
- document specifies an input document.
- documentParser specifies a document format; PLAIN, MARKDOWN, and WIKI are supported.
- lang specifies a language for an input document; ja(Japanese) and en (English) are supported.
- format specifies an output format.
- config specifies the RedPen configuration file; this is the context of RedPen settings.
Let’s get started with the features now. Use the English configuration file (redpen-conf-en.xml) in RedPen for this time. You can see the contents of the configuration file below.
<property name="max_len" value="100"/>
<property name="max_char_num" value="2000"/>
<validator name="Contraction" />
<validator name="DoubledWord" />
<validator name="SuccessiveWord" />
<validator name="EndOfSentence" />
<validator name="SpaceBeginningOfSentence" />
Then, validate a short sample sentence (“Twas brillig and the slithy toves did gyre and gimble in the wabe”) with RedPen server. The sentence and the setting are thrown to RedPen with the following commands.
curl --data document="Twas brillig and the slithy toves did gyre and gimble in the wabe"
--data lang=en --data format=PLAIN2
--data config="`cat redpen-conf-en.xml`"
Line: 1, Offset: 0
Sentence: Twas brillig and the slithy toves did gyre and gimble in the wabe
Spelling: Found possibly misspelled word "brillig".
Spelling: Found possibly misspelled word "slithy".
Spelling: Found possibly misspelled word "toves".
Spelling: Found possibly misspelled word "gyre".
Spelling: Found possibly misspelled word "gimble".
"and".querying the input
As you can see the results, the RedPen server reports some errors in the sentence.
Building RedPen server with the Heroku button
In the example above, I used the deployed server on Heroku. Your PC environment, however, may not be efficient enough for most of you to use this server. If you want to use RedPen server comfortably with less response time, you can install RedPen server (war file) into your environment. The file for RedPen server (redpen.war) is a self-executing file, and it runs only with “java -jar redepn.war” in the environment where Java8 is installed. Even if it is easy to activate RedPen server, you need to keep the server maintained by yourself. So, RedPen supports the Heroku button. Just with a few clicks, you can build a RedPen server on Heroku. The Heroku button is in the RedPen source URL.
When you click the bottom, you will see the following page.
When you click the Deploy for Free button in the page, the RedPen server build will finish after a few minutes.