Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

/uber #3

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Docker

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

on:
schedule:
- cron: '19 18 * * *'
push:
branches: [ "uber" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "uber" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@f3c664df7af409cb4873aa5068053ba9d61a57b6 #v2.6.0
with:
cosign-release: 'v1.11.0'


# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max


# # Sign the resulting Docker image digest except on PRs.
# # This will only write to the public Rekor transparency log when the Docker
# # repository is public to avoid leaking data. If you would like to publish
# # transparency data even for private images, pass --force to cosign below.
# # https://github.com/sigstore/cosign
# - name: Sign the published Docker image
# if: ${{ github.event_name != 'pull_request' }}
# env:
# COSIGN_EXPERIMENTAL: "true"
# # This step uses the identity token to provision an ephemeral certificate
# # against the sigstore community Fulcio instance.
# run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }}
9 changes: 2 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
FROM java:8-jdk

RUN set -ex \
&& apt-get update \
&& apt-get install flip
FROM openjdk:11

ADD . /app
RUN set -ex \
&& cd /app \
&& flip -u ./gradlew \
&& ./gradlew build
&& ./gradlew build --no-daemon

EXPOSE 8080
WORKDIR /app
Expand Down
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
## Це — веб-служба (REST API) для аналізу українських текстів (NLP) за допомогою LanguageTool. ##
## REST API для аналізу українських текстів (NLP) за допомогою LanguageTool

## This project provides REST API for analyzing Ukrainian texts with LanguageTool. ##
This project provides REST API for analyzing Ukrainian texts with LanguageTool.

### Quick Start

### Як встановити ###
* Встановити java (JDK 8 або новішу)
* Клонувати проект з github
* Запустити `./gradlew bootRun`
* Документація в JSON: http://localhost:8080/v2/api-docs
* Документація з UI: http://localhost:8080/swagger-ui.html
The `/uber` endpoint accepts a batch of texts, processes all of them parallel and returns [sentences, tokens, lemmas] for each text.

### Як використовувати через Docker ###
Start the web server on port 8080:

```
docker build -t api_nlp_uk:latest .
docker run -it -p 8080:8080 api_nlp_uk:latest
curl -X POST -H "Content-Type: application/json" -d "{'text': 'Сьогодні у продажі. 12-те зібрання творів 1969 р. І. П. Котляревського.'}" http://localhost:8080/lemmatize/
docker run -p 8080:8080 ghcr.io/proger/api_nlp_uk:uber
```

Або можна викоритсовувати Docker image який підтримується в іншому репозиторії.
Run example query:

```
docker run -it -p 5000:5000 chaliy/api_nlp_uk:latest
curl -s -X POST -H "Content-Type: application/json" -d "['Привіт, котанче. Як справи?', 'Ну шо, приїхали?']" http://localhost:8080/uber \
| jq -c '.[]'
```

This will respond like:
```
[[["Привіт, котанче. ",["Привіт",","," ","котанче","."," "],["привіт",","," ","котанче","."," "]],["Як справи?",["Як"," ","справи","?"],["як"," ","справа","?"]]],[["Ну шо, приїхали?",["Ну"," ","шо",","," ","приїхали","?"],["ну"," ","шо",","," ","приїхати","?"]]]]
```

Вільно розповсюджується за умов ліцензії GPL версії 3.
Expand Down
67 changes: 34 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ buildscript {
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
mavenCentral()
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
// classpath "org.grails.plugins:hibernate5:6.0.0"
classpath "org.grails.plugins:views-gradle:1.1.2"
classpath "org.grails.plugins:views-gradle:2.3.2"
}
}

version "1.0"
group "languagetool_nlp"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
Expand All @@ -25,6 +25,7 @@ war.archiveName='languagetool.war'
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
mavenCentral()
}

dependencyManagement {
Expand All @@ -35,44 +36,44 @@ dependencyManagement {
}

dependencies {
compile "org.languagetool:language-uk:3.7"
implementation "org.languagetool:language-uk:6.0"

// compile "org.grails.plugins:swaggydoc-grails3:0.28.0"
compile "io.springfox:springfox-swagger2:2.6.1"
compile "io.springfox:springfox-swagger-ui:2.6.1"
// implementation "org.grails.plugins:swaggydoc-grails3:0.28.0"
implementation "io.springfox:springfox-swagger2:3.0.0"
implementation "io.springfox:springfox-swagger-ui:3.0.0"

compile "org.grails:grails-dependencies"
implementation "org.grails:grails-dependencies"

compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-codecs"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails:grails-plugin-services"
// compile "org.grails:grails-plugin-datasource"
// compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-async"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails.plugins:cache"
// compile "org.grails.plugins:hibernate5"
// compile "org.hibernate:hibernate-core:5.1.1.Final"
// compile "org.hibernate:hibernate-ehcache:5.1.1.Final"
compile "org.grails.plugins:views-json"
compile "org.grails.plugins:views-json-templates"
implementation "org.springframework.boot:spring-boot-starter-logging"
implementation "org.springframework.boot:spring-boot-autoconfigure"
implementation "org.grails:grails-core"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "org.springframework.boot:spring-boot-starter-tomcat"
implementation "org.grails:grails-plugin-url-mappings"
implementation "org.grails:grails-plugin-rest"
implementation "org.grails:grails-plugin-codecs"
implementation "org.grails:grails-plugin-interceptors"
implementation "org.grails:grails-plugin-services"
// implementation "org.grails:grails-plugin-datasource"
// implementation "org.grails:grails-plugin-databinding"
// implementation "org.grails:grails-plugin-async"
implementation "org.grails:grails-web-boot"
implementation "org.grails:grails-logging"
implementation "org.grails.plugins:cache"
// implementation "org.grails.plugins:hibernate5"
// implementation "org.hibernate:hibernate-core:5.1.1.Final"
// implementation "org.hibernate:hibernate-ehcache:5.1.1.Final"
implementation "org.grails.plugins:views-json"
implementation "org.grails.plugins:views-json-templates"
console "org.grails:grails-console"
profile "org.grails.profiles:rest-api"
// provided "org.codehaus.groovy:groovy-ant"
// runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
// testCompile "org.grails:grails-datastore-rest-client"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
// testCompile "org.grails:grails-plugin-testing"
// testCompile "org.grails.plugins:geb"
//// testCompile "org.grails:grails-datastore-rest-client"
// testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
// testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}

bootRun {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
grailsVersion=3.2.0
gradleWrapperVersion=3.0
groovyVersion=3.0.7
grailsVersion=5.2.4
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Nov 27 23:09:32 CET 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip
Loading