Skip to content

Commit

Permalink
Merge pull request #162 from ku-nlp/develop
Browse files Browse the repository at this point in the history
v1.5.1
  • Loading branch information
nobu-g authored Sep 18, 2023
2 parents 24fbac4 + f89221b commit 6c9d749
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly" # TODO: Change to "monthly"
interval: "monthly"
timezone: "Asia/Tokyo"
target-branch: "develop"
ignore:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ jobs:
name: Build the project
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 15
max-parallel: 18
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true # TODO: Remove this line when Python 3.12 is released
- name: Install Poetry
run: |
pipx install poetry
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
build-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/test-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ jobs:
container: kunlp/jumanpp-knp:ubuntu
runs-on: ubuntu-20.04 # to meet the ubuntu version in the kunlp/jumanpp-knp:ubuntu container
strategy:
max-parallel: 5
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install required apt packages
run: |
apt update -y
Expand All @@ -25,6 +26,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true # TODO: Remove this line when Python 3.12 is released
- name: Install Poetry
run: |
python3 -m pip install --user pipx
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ jobs:
container: kunlp/jumanpp-knp:ubuntu
runs-on: ubuntu-20.04 # to meet the ubuntu version in the kunlp/jumanpp-knp:ubuntu container
strategy:
max-parallel: 6
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install required apt packages
run: |
apt update -y
Expand All @@ -22,6 +23,7 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true # TODO: Remove this line when Python 3.12 is released
- name: Install Poetry
run: |
python3 -m pip install --user pipx
Expand All @@ -34,8 +36,8 @@ jobs:
run: |
poetry install --no-interaction --without dev,docs --extras=cli
- name: Install KWJA
# KWJA does not support Python 3.7
if: ${{ matrix.python-version != 3.7 }}
# KWJA does not support Python 3.7 or 3.12
if: ${{ matrix.python-version != 3.7 && matrix.python-version != 3.12 }}
run: |
pipx install kwja
kwja --model-size tiny --text "テスト"
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ repos:
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 23.7.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
Expand Down
6 changes: 3 additions & 3 deletions examples/apply_kwja.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
# Create a KWJA instance.
kwja = KWJA()

# Apply KNP to a sentence.
sent = kwja.apply_to_sentence(sys.argv[1])
# Apply KWJA to a document.
doc = kwja.apply_to_document(sys.argv[1])

# Get information.
for mrph in sent.morphemes:
for mrph in doc.morphemes:
print(f"Text: {mrph.text}")
print(f"Reading: {mrph.reading}")
print(f"Lemma: {mrph.lemma}")
Expand Down
39 changes: 35 additions & 4 deletions poetry.lock

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

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rhoknp"
version = "1.5.0"
version = "1.5.1"
description = "Yet another Python binding for Juman++/KNP/KWJA"
license = "MIT"
authors = [
Expand Down Expand Up @@ -57,10 +57,10 @@ Sphinx = [
{ version = "^5.3", python = "<3.8" },
{ version = "^7.0", python = ">=3.8" },
]
# sphinx-prompt 1.7.0 requires python < 3.11, which will be fixed in the next version
sphinx-prompt = [
{ version = "~1.5.0", python = "<3.8" },
{ version = "^1.6", python = ">=3.8,<3.11" },
{ version = "^1.6", python = ">=3.8,<3.9" },
{ version = "^1.8", python = ">=3.9" },
]
sphinx-copybutton = "^0.5.0"
myst-parser = [
Expand All @@ -84,7 +84,7 @@ rhoknp = "rhoknp.cli.cli:app"

[tool.black]
line-length = 120
target-version = ["py37", "py38", "py39", "py310", "py311"]
target-version = ["py37", "py38", "py39", "py310", "py311", "py312"]

[tool.isort]
line_length = 120
Expand Down
4 changes: 2 additions & 2 deletions src/rhoknp/cli/static/css/style.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* templates/components/raw_input.jinja2 */
.input-text {
white-space: pre-wrap;
margin: 0em 0.5em 1em;
margin: 0 0.5em 1em;
padding: 0.5em;
}

.result {
margin: 0em 0.5em 1em;
margin: 0 0.5em 1em;
padding: 0.5em;
}

Expand Down
4 changes: 2 additions & 2 deletions src/rhoknp/processors/kwja.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ def __init__(
tasks: List[str] = self.options[self.options.index("--tasks") + 1].split(",")
if "word" in tasks:
self._output_format = "knp"
elif "char" in tasks:
self._output_format = "words"
elif "seq2seq" in tasks:
self._output_format = "jumanpp"
elif "char" in tasks:
self._output_format = "words"
elif "senter" in tasks:
self._output_format = "line_by_line"
elif "typo" in tasks:
Expand Down
13 changes: 7 additions & 6 deletions src/rhoknp/units/base_phrase.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,13 @@ def from_knp(cls, knp_text: str) -> "BasePhrase":
match = cls.PAT.match(first_line)
if match is None:
raise ValueError(f"malformed base phrase line: {first_line}")
parent_index = int(match["pid"]) if match["pid"] is not None else None
dep_type = DepType(match["dtype"]) if match["dtype"] is not None else None
features = FeatureDict.from_fstring(match["feats"] or "")
rel_tags = RelTagList.from_fstring(match["feats"] or "")
memo_tag = MemoTag.from_fstring(match["feats"] or "")
base_phrase = cls(parent_index, dep_type, features, rel_tags, memo_tag)
base_phrase = cls(
parent_index=int(match["pid"]) if match["pid"] is not None else None,
dep_type=DepType(match["dtype"]) if match["dtype"] is not None else None,
features=FeatureDict.from_fstring(match["feats"] or ""),
rel_tags=RelTagList.from_fstring(match["feats"] or ""),
memo_tag=MemoTag.from_fstring(match["feats"] or ""),
)

morphemes: List[Morpheme] = []
for line in lines:
Expand Down
6 changes: 2 additions & 4 deletions src/rhoknp/units/morpheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,6 @@ def _from_jumanpp_line(cls, jumanpp_line: str, homograph: bool = False) -> "Morp
match_attr = cls._ATTRIBUTE_PAT.match(match["attrs"]) or cls._ATTRIBUTE_PAT_REPEATED.match(match["attrs"])
assert match_attr is not None
attributes = match_attr.groups()
semantics = SemanticsDict.from_sstring(match["sems"] or "")
features = FeatureDict.from_fstring(match["feats"] or "")
return cls(
surf,
attributes[0],
Expand All @@ -315,8 +313,8 @@ def _from_jumanpp_line(cls, jumanpp_line: str, homograph: bool = False) -> "Morp
int(attributes[7]),
attributes[8],
int(attributes[9]),
semantics,
features,
semantics=SemanticsDict.from_sstring(match["sems"] or ""),
features=FeatureDict.from_fstring(match["feats"] or ""),
homograph=homograph,
)

Expand Down

0 comments on commit 6c9d749

Please sign in to comment.