sls-spellchecker
所属分类:FaaS/Serverless
开发工具:Java
文件大小:14KB
下载次数:0
上传日期:2022-11-16 01:50:19
上 传 者:
sh-1993
说明: 无服务器拼写检查器
(A Serverless Spell Checker)
文件列表:
.travis.yml (14, 2020-09-22)
LICENSE (1062, 2020-09-22)
pom.xml (4808, 2020-09-22)
serverless.yml (584, 2020-09-22)
sls-spellchecker.iml (8757, 2020-09-22)
src (0, 2020-09-22)
src\main (0, 2020-09-22)
src\main\java (0, 2020-09-22)
src\main\java\com (0, 2020-09-22)
src\main\java\com\isahb (0, 2020-09-22)
src\main\java\com\isahb\slsspellchecker (0, 2020-09-22)
src\main\java\com\isahb\slsspellchecker\Handler.java (4081, 2020-09-22)
src\main\java\com\isahb\slsspellchecker\model (0, 2020-09-22)
src\main\java\com\isahb\slsspellchecker\model\ApiGatewayResponse.java (3399, 2020-09-22)
src\main\java\com\isahb\slsspellchecker\model\Response.java (402, 2020-09-22)
src\main\java\com\isahb\slsspellchecker\model\SpellCheckResult.java (3447, 2020-09-22)
src\main\resources (0, 2020-09-22)
src\main\resources\log4j2.xml (429, 2020-09-22)
src\test (0, 2020-09-22)
src\test\java (0, 2020-09-22)
src\test\java\com (0, 2020-09-22)
src\test\java\com\isahb (0, 2020-09-22)
src\test\java\com\isahb\slsspellchecker (0, 2020-09-22)
src\test\java\com\isahb\slsspellchecker\HandlerTest.java (1812, 2020-09-22)
# sls-spellchecker
**A Lambda wrapper of [LanguageTool](https://languagetool.org/).**
[![Build Status](https://travis-ci.org/isahb/sls-spellchecker.svg?branch=master)](https://travis-ci.org/isahb/sls-spellchecker)
Limit set to max 1024 character texts. (`com.isahb.slsspellchecker.Handler.CHARACTER_LIMIT`)
The sample uses `AmericanEnglish` but others can be included easily by adding the necessary dependency in the pom.xml, for example for German language spoken in Germany:
org.languagetool
language-de
4.8
In the `Handler`:
private JLanguageTool langTool = new JLanguageTool(new GermanyGerman());
Serverless Framework is used for deployment and an API Gateway stack with `checkSpelling` resource is created.
To build:
> mvn clean install
To deploy with Servlerless Framework in Frankfurt region:
> sls deploy --region eu-central-1
CURL (replace `api-gateway-id` with your generated id after stack is deployed)
``
curl --location --request POST 'https://[api-gateway-id].execute-api.eu-central-1.amazonaws.com/dev/checkSpelling' \
--header 'Content-Type: application/json' \
--data-raw '{
"text": "Please not that this sentence has erors"
}'
``
** Request/Response format**
```
{
"text": "Please not that this sentence has erors"
}
```
```
{
"error": null,
"spellCheckSuggestions": [
{
"startPos": 7,
"endPos": 10,
"message": "Did you mean
note?",
"shortMessage": "Possible typo",
"type": "Other",
"suggestedReplacements": [
"note"
],
"suggestionMeta": {
"categoryId": "TYPOS",
"categoryName": "Possible Typo",
"correctExamples": [],
"incorrectExamples": [
{
"example": "Please
not that saying “Open Source” does not mean very much.",
"corrections": [
"note"
]
}
]
}
},
{
"startPos": 34,
"endPos": 39,
"message": "Possible spelling mistake found.",
"shortMessage": "Spelling mistake",
"type": "Other",
"suggestedReplacements": [
"errors",
"Eros",
"errs"
],
"suggestionMeta": {
"categoryId": "TYPOS",
"categoryName": "Possible Typo",
"correctExamples": [
{
"example": "This
sentence contains a spelling mistake."
}
],
"incorrectExamples": [
{
"example": "This
sentenc contains a spelling mistake.",
"corrections": [
"sentence"
]
}
]
}
}
]
}
```
**American English tests**
Cold starts for American English with a 2GB configuration take up to 10s.
A warm lambda takes a few hundred milliseconds but never under 200 milliseconds in my tests.
近期下载者:
相关文件:
收藏者: