Skip to content

Commit 0c10621

Browse files
committed
Add KUCut
1 parent f2e78c6 commit 0c10621

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed

.github/workflows/kucut-build.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: KUCut-build
2+
3+
on:
4+
push:
5+
# Publish `v1.2.3` tags as releases.
6+
tags:
7+
- kucut-v*
8+
9+
# Run tests for any PRs.
10+
pull_request:
11+
12+
env:
13+
# TODO: Change variable to your image's name.
14+
IMAGE_NAME: kucut
15+
16+
jobs:
17+
# Run tests.
18+
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
19+
test:
20+
runs-on: ubuntu-20.04
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
25+
- name: Run tests
26+
run: |
27+
cd kucut
28+
docker build . --file Dockerfile
29+
# Push image to GitHub Packages.
30+
# See also https://docs.docker.com/docker-hub/builds/
31+
push:
32+
# Ensure test job passes before pushing image.
33+
needs: test
34+
35+
runs-on: ubuntu-latest
36+
if: github.event_name == 'push'
37+
38+
steps:
39+
- uses: actions/checkout@v2
40+
41+
- name: Build image
42+
run: |
43+
cd kucut
44+
docker build . --file Dockerfile --tag $IMAGE_NAME
45+
46+
- name: Log into registry
47+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
48+
49+
- name: Push image
50+
run: |
51+
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
52+
53+
# Change all uppercase to lowercase
54+
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
55+
# Strip git ref prefix from version
56+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
57+
# Strip "v" prefix from tag name
58+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
59+
# Use Docker `latest` tag convention
60+
[ "$VERSION" == "main" ] && VERSION=latest
61+
echo IMAGE_ID=$IMAGE_ID
62+
echo VERSION=$VERSION
63+
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
64+
docker push $IMAGE_ID:$VERSION

kucut/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Python 2.6 from https://gist.github.com/mjhea0/03fdaa4ff1e0311d7651e6a815d01583
2+
# base image
3+
FROM mjhea0/centos-6-python-2.6:latest
4+
5+
RUN git clone https://github.com/Thanabhat/KUCut.git
6+
7+
WORKDIR "/KUCut"
8+
9+
RUN python setup.py install

kucut/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# KUCut
2+
3+
This is dockerfile of KUCut.
4+
5+
KU wordcut is thai word segmentor.
6+
7+
GitHub: https://github.com/Thanabhat/KUCut
8+
9+
KUCut License: GPL-2.0 License
10+
11+
## How to build
12+
13+
> docker build -t kucut:v1.4.3b2 .
14+
15+
## Using
16+
17+
> docker run --rm -it --entrypoint bash kucut:v1.4.3b2
18+
19+
or when docker is running.
20+
21+
> docker exec -it kucut:v1.4.3b2 bash
22+
23+
using
24+
25+
```sh
26+
# python
27+
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
28+
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
29+
Type "help", "copyright", "credits" or "license" for more information.
30+
>>> from kucut import SimpleKucutWrapper as KUCut
31+
kucut/AIMA/utils.py:7: DeprecationWarning: the sets module is deprecated
32+
from sets import *
33+
>>> myKUCut = KUCut()
34+
35+
>>> result = myKUCut.tokenize([u"ทดสอบทดสอบ"])
36+
>>> result
37+
[[[u'\u0e17\u0e14\u0e2a\u0e2d\u0e1a', u'\u0e17\u0e14\u0e2a\u0e2d\u0e1a']]]
38+
>>> print result[0]
39+
[[u'\u0e17\u0e14\u0e2a\u0e2d\u0e1a', u'\u0e17\u0e14\u0e2a\u0e2d\u0e1a']]
40+
>>> print result[0][0]
41+
[u'\u0e17\u0e14\u0e2a\u0e2d\u0e1a', u'\u0e17\u0e14\u0e2a\u0e2d\u0e1a']
42+
>>> print result[0][0][0]
43+
ทดสอบ
44+
>>> print result[0][0][1]
45+
ทดสอบ
46+
```

0 commit comments

Comments
 (0)