Skip to content

Commit

Permalink
Add Dockerfile
Browse files Browse the repository at this point in the history
Add simple console script
  • Loading branch information
dyamah committed Jul 26, 2017
1 parent daf3af7 commit a2914f0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.6

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y mecab libmecab-dev mecab-ipadic-utf8 \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*


WORKDIR /root

ADD pymecab /root/pymecab
ADD setup.py /root

RUN ["/bin/bash", "-c", "pip install -e ."]

CMD ["/bin/bash", "-c", "pymecab.console"]
16 changes: 16 additions & 0 deletions pymecab/pymecab.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import namedtuple

from natto import MeCab


Expand Down Expand Up @@ -30,3 +31,18 @@ def __convert(self, mecab_token):

def tokenize(self, text):
return [self.__convert(t) for t in self.mecab.parse(text, as_nodes=True)]


def main():
import sys

mecab = PyMecab()

for line in sys.stdin:
for token in mecab.tokenize(line):
print(token.surface, token.pos1)

print('')

if __name__ == "__main__":
main()
14 changes: 12 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='pymecab',
version='1.0.1',
version='1.0.2',
description='mecab wrapper by using natto-py',
author='JX PRESS Corp.',
author_email='[email protected]',
Expand All @@ -22,5 +22,15 @@
license='MIT License',
install_requires=[
'natto-py'
]
],
extras_require={
'test': ['pytest']
},
entry_points={
'console_scripts': [
'pymecab.console=pymecab.pymecab:main'
]
}


)

0 comments on commit a2914f0

Please sign in to comment.