Skip to content

Commit

Permalink
Merge pull request #148 from lovit/feature/147
Browse files Browse the repository at this point in the history
Feature/147
  • Loading branch information
lovit authored Feb 4, 2025
2 parents d2feb99 + 3cce260 commit cfbb394
Show file tree
Hide file tree
Showing 15 changed files with 555 additions and 51 deletions.
5 changes: 4 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Pull Request

## Checklist

- [ ] 해당 PR 관련 이슈가 작성되었나요?
- [ ] 테스트 코드를 작성하였나요?
- [ ] 기존에 작성된 테스트코드가 정상적으로 작동하나요? (`tests/test*.py`)

## 1. 해당 PR은 어떤 내용인가요?

<!-- 해당 PR이 어떠한 내용인지 상세하게 명시 부탁드립니다. -->

## 2. PR과 관련된 이슈가 있나요?
<!-- PR이 참고하고 있는 이슈가 있다면 이슈번호를 `#123` 형식으로 남겨주세요. 여러 개의 이슈가 포함되어도 됩니다.-->

<!-- PR이 참고하고 있는 이슈가 있다면 이슈번호를 `#123` 형식으로 남겨주세요. 여러 개의 이슈가 포함되어도 됩니다.-->
30 changes: 30 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: pre-commit

on:
pull_request:
push:
branches: [master, dev, feature/146]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry==1.8.0
poetry install
- name: Test with pytest
run: |
poetry run pytest
39 changes: 0 additions & 39 deletions .github/workflows/pytest.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
#.idea/
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
fail_fast: true
minimum_pre_commit_version: "4.1.0"
repos:
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.393
hooks:
- id: pyright
entry: pyright
additional_dependencies: []
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.4
hooks:
- id: ruff
name: Run ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
name: Run black
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
name: Run preittier
language_version: 16.20.2
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-json
- id: check-toml
- id: check-yaml
args: [--allow-multiple-documents]
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# soynlp

Renewing ...
Renewing ...

## Install

```
pipx install poetry==1.8.0
poetry install
```
16 changes: 7 additions & 9 deletions data/loader.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os
from glob import glob


installpath = os.path.abspath(os.path.dirname(__file__))


def load(idx='134963', mode='norm', max_samples=-1):
def load(idx="134963", mode="norm", max_samples=-1):
"""
Args:
idx: str
idx: str
movie idx
mode: str
`mode` = 'norm' or not
Expand All @@ -21,17 +20,16 @@ def load(idx='134963', mode='norm', max_samples=-1):
scores: list of int
Annotated scores
"""
suffix = '' if mode != 'norm' else '_norm'
paths = glob(f'{installpath}/{idx}{suffix}.txt')
suffix = "" if mode != "norm" else "_norm"
paths = glob(f"{installpath}/{idx}{suffix}.txt")
if not paths:
raise ValueError(f'Not found file. Check idx {idx}')
with open(paths[0], encoding='utf-8') as f:
raise ValueError(f"Not found file. Check idx {idx}")
with open(paths[0], encoding="utf-8") as f:
docs = [line.strip() for line in f]
docs = [line.rsplit('\t', 1) for line in docs]
docs = [line.rsplit("\t", 1) for line in docs]
docs = [row for row in docs if len(row) == 2]
if max_samples > 0:
docs = docs[:max_samples]
texts, scores = zip(*docs)
scores = [int(s) for s in scores]
return texts, scores

Loading

0 comments on commit cfbb394

Please sign in to comment.