Skip to content

Commit

Permalink
Make seqeval optional (megagonlabs#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
shirayu authored Apr 14, 2022
1 parent 464c940 commit 3d7a76b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 45 deletions.
5 changes: 4 additions & 1 deletion bunkai/experiment/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import re
import typing

from seqeval.metrics import performance_measure
try:
from seqeval.metrics import performance_measure
except ImportError:
raise Exception("You need to install bunkai with pip install -U bunkai[train]")

from bunkai.constant import METACHAR_LINE_BREAK, METACHAR_SENTENCE_BOUNDARY

Expand Down
6 changes: 6 additions & 0 deletions docs/training.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

# Training of lbd (Linebreak Disambiguator)

## Install dependences

```console
poetry install --no-root -E lb -E train
```

## Preparation BCCWJ without newspaper texts

```bash
Expand Down
5 changes: 3 additions & 2 deletions mks/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ TERMS_CHECK_CONTENT_OPTION:=-e 文分割 -e 'coding: utf'

POETRY_NO_ROOT:= --no-root
POETRY_LB:= -E lb
POETRY_TRAIN:= -E train

dev_setup:
poetry install $(POETRY_NO_ROOT) $(POETRY_LB) $(POETRY_OPTION)
poetry install $(POETRY_NO_ROOT) $(POETRY_LB) $(POETRY_TRAIN) $(POETRY_OPTION)

setup: setup_python setup_npm

setup_python:
poetry install $(POETRY_LB) $(POETRY_OPTION)
poetry install $(POETRY_LB) $(POETRY_TRAIN) $(POETRY_OPTION)

setup_npm:
npm install
Expand Down
83 changes: 42 additions & 41 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ keywords = ["Japanese", "Sentence boundary disambiguation"]
python = ">=3.8,<4.0"
dataclasses-json = ">=0.5.2"
janome = ">=0.4.1"
seqeval = ">=1.2.2"
seqeval = {version = ">=1.2.2", optional = true}
spans = ">=1.1.0"
tqdm = "*"
numpy = {version = ">=1.16.0", optional = true}
Expand All @@ -38,6 +38,7 @@ black = ">=21.10b0"

[tool.poetry.extras]
lb = ["torch", "transformers", "numpy", "requests"]
train = ["seqeval"]

[build-system]
requires = ["poetry"]
Expand Down

0 comments on commit 3d7a76b

Please sign in to comment.