Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Web server for language processing

NotificationsYou must be signed in to change notification settings

divvun/divvun-api

Repository files navigation

Starts a web server for accessing the Divvun spellcheck API.

Seehttps://divvun.github.io/divvun-api/index.html for installation and usage documentation instructions.

OpenAPI

The OpenAPI documentation is generated withReDoc and hosted athttps://divvun.github.io/divvun-api/redoc-static.html

To refresh the documentation, install theredoc-cli NPM package (npm i -g redoc-cli) and runredoc-cli bundle openapi.yml.This will generate aredoc-static.html file that needs to be placed in thedocs folder.

To refreshdocs/index.html,cd docs/ and runasciidoctor index.adoc.

Testing

Tests use the files intests/resources/data_files. The files need to be organized as follows before runningcargo test:

tests|--resources   |--data_files      |  se.zcheck      |  se.zhfst      |  smj.zcheck      |  smj.zhfst      |      |--grammar         |  se.zcheck      |--hyphenation         |  se.hfstol      |--spelling         |  se.zhfst

The basedata_files folder is expected to have bothse andsmjgrammar (.zcheck) and checker (.zhfst) files for the purposes of testing the file watcher, andthese files are also expected to be present in thespelling,hyphenation, andgrammar folders for testing loading of files at startup.

  • runcargo test

Deployment

Additional steps for deployment.

Requirements

  • Create a regular user with sudo privileges (default:ubuntu)
  • Create an API user with which the API will run (default:api)
  • Setup SSH access
  • Install python

Set theadmin_email variable to receive emails from Let's Encrypt when it's time to renew the HTTPS certificate.

Docker image

This project is built and pushed into a docker image. The docker images is deployed by thehttps://github.com/divvun/divvun-api-deploy/

You need to build the docker image on an x86 machine. An m1 mac won't do.

docker build -t divvun/divvun-api:v2 .

Now.. this image is not uploaded to a repository. It just sits there. You'll have to pack it yourself.

Crimes

Basic litmus tests for spellers and grammar

$ curl -X POST -H'Content-Type: application/json''https://api-giellalt.uit.no/speller/se' --data'{"text": "pahkat"}'{"text":"pahkat","results":[{"word":"pahkat","is_correct":false,"suggestions":[{"value":"páhkat","weight":15.301758},{"value":"páhkkat","weight":21.3018},{"value":"dahkat","weight":33.012695},{"value":"háhkat","weight":34.89453},{"value":"ráhkat","weight":38.691406},{"value":"čáhkat","weight":38.79785},{"value":"hahkát","weight":39.896484},{"value":"báhkat","weight":39.89746},{"value":"Ráhkat","weight":40.05078},{"value":"páhka","weight":40.301758}]}]$ curl -X POST -H'Content-Type: application/json''https://api-giellalt.uit.no/grammar/se' --data'{"text": "Danne lea politijuristtaide eanemus praktihkkalaččat vuogas dan dahkat Čáhcesullos."}'{"text":"Danne lea politijuristtaide eanemus praktihkkalaččat vuogas dan dahkat Čáhcesullos.","errs":[{"error_text":"politijuristtaide","start_index":10,"end_index":27,"error_code":"typo","description":"Ii leat sátnelisttus","suggestions":["politiijajuristtaide"],"title":"Čállinmeattáhus"},{"error_text":"praktihkkalaččat","start_index":36,"end_index":52,"error_code":"typo","description":"Ii leat sátnelisttus","suggestions":["praktihkalaččat","praktihkalat","praktihkalet","praktihkalit","praktihkalut"],"title":"Čállinmeattáhus"}]}%

Pack your image:

docker save divvun/divvun-api:v2| gzip> divvun-api-v2.tar.gz

Copy your image to the divvun-api server:

scp divvun-api-v2.tar.gz root@64.225.76.53:

Load your image up

% ssh root@64.225.76.53$ gunzip --stdout divvun-api-v2.tar.gz| docker load8553b91047da: Loading layer [==================================================>]  84.01MB/84.01MB22050e545130: Loading layer [==================================================>]  22.38MB/22.38MB16c60edfa394: Loading layer [==================================================>]    215kB/215kB86ffb3b2b27a: Loading layer [==================================================>]  80.01MB/80.01MBc642b882d7d8: Loading layer [==================================================>]  1.536kB/1.536kB0b38c186a861: Loading layer [==================================================>]  16.72MB/16.72MB75784fda3f36: Loading layer [==================================================>]   2.56kB/2.56kBLoaded image: divvun/divvun-api:v2

The default user is API. Switch to it, go to the deploy directory and change the docker-compose to use your new tag. The restart docker-compose and start tailing the newly started divvun-api container.

su api -s /bin/bashcd /home/api/distnano -w docker-compose.yml#change the image to use :v2docker-compose restartdocker logs -n10 -f dist_divvun_api_1

And then you rerun your litmus tests. Make sure to change the languages around so you're not testing.. something that would have worked anyway.And then you change your grammar packages around. And then you rerun the litmus tests.

Ultimately, you update thehttps://github.com/divvun/divvun-api-deploy/ repo and stop doing crimes.

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp