Skip to content

Commit

Permalink
Add docs (#18)
Browse files Browse the repository at this point in the history
* Add QRNN-based classifier (#14)

* Add PRAD (#14)

* Add a setting file for GitHub action

* Fix

* Fix yaml format

* Add install

* Add requirements.txt

* Update requirements.txt

* Unsupport 3.5

* Unsupport 3.6

* setup.py develop

* Add docs
  • Loading branch information
tma15 authored Aug 15, 2021
1 parent 3ec299f commit 64a5c99
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 1 deletion.
1 change: 1 addition & 0 deletions bunruija/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import bunruija.tokenizers
import bunruija.trainer

from .binarizer import Binarizer
from .evaluator import Evaluator
from .predictor import Predictor
from .trainer import Trainer
2 changes: 2 additions & 0 deletions bunruija/binarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@


class Binarizer:
"""Binarizes data
"""
def __init__(self, config_file):
self.config_file = config_file
with open(config_file) as f:
Expand Down
2 changes: 2 additions & 0 deletions bunruija/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@


class Evaluator:
"""Evaluates a trained model
"""
def __init__(self, args):
with open(args.yaml) as f:
self.config = yaml.load(f, Loader=yaml.SafeLoader)
Expand Down
4 changes: 3 additions & 1 deletion bunruija/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@


class Trainer:
def __init__(self, config_file):
"""Trains a text classification model.
"""
def __init__(self, config_file: str):
with open(config_file) as f:
self.config = yaml.load(f, Loader=yaml.SafeLoader)

Expand Down
9 changes: 9 additions & 0 deletions docs/binarizer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Binarizer
====================================

================
Binarizer module
================

.. automodule:: bunruija.Binarizer
:members:
57 changes: 57 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('../'))


# -- Project information -----------------------------------------------------

project = 'Bunruija'
copyright = '2021, Takuya Makino'
author = 'Takuya Makino'

# The full version, including alpha/beta/rc tags
release = '0.0.0'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
10 changes: 10 additions & 0 deletions docs/evaluator.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Evaluator
====================================

================
Evaluator module
================

.. automodule:: bunruija.Evaluator
:members:

25 changes: 25 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. Bunruija documentation master file, created by
sphinx-quickstart on Sun Aug 15 11:49:32 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Bunruija's documentation!
====================================

.. toctree::
:maxdepth: 1
:caption: Contents:

tutorial

binarizer
evaluator
trainer


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
10 changes: 10 additions & 0 deletions docs/trainer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Trainer
====================================

==============
Trainer module
==============

.. automodule:: bunruija.Trainer
:members:

57 changes: 57 additions & 0 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Tutorial
====================================

================
Data file format
================

.. code-block:: sh
label1,text
label2,text
label2,text
label3,text
label4,text
=================
Model file format
=================


.. code-block:: yaml
preprocess:
data:
train: train.csv
dev: dev.csv
test: test.csv
tokenizer:
type: mecab
args:
lemmatize: true
exclude_pos:
- 助詞
- 助動詞
bin_dir: models/svm-model
classifier:
- type: tfidf
args:
max_features: 10000
min_df: 3
ngram_range:
- 1
- 3
- type: svm
args:
verbose: false
C: 10.
.. code-block:: sh
bunruija-preprocess -y settings/model.yaml
bunruija-train -y settings/model.yaml
bunruija-evaluate -y settings/model.yaml

0 comments on commit 64a5c99

Please sign in to comment.