Skip to content

feat(postagger): POSExtractor 단계 조립 방식 유연화 - #252

Merged
lovit merged 1 commit into
refactor-2026-postaggerfrom
feature/239
Mar 9, 2026
Merged

feat(postagger): POSExtractor 단계 조립 방식 유연화#252
lovit merged 1 commit into
refactor-2026-postaggerfrom
feature/239

Conversation

@lovit

@lovit lovit commented Mar 9, 2026

Copy link
Copy Markdown
Owner

관련 이슈

closes #239

변경 내용

POSExtractor의 단계 조립을 유연화하여 도메인 특화 추출기를 삽입할 수 있도록 한다.

ExtractorStepProtocol

class ExtractorStepProtocol(Protocol):
    def extract(self, sentences, context: dict) -> dict: ...

POSExtractor.extra_steps

class MedicalTermStep:
    def extract(self, sentences, context: dict) -> dict:
        nouns = context.get("nouns", {})
        nouns.update({"항체": 1.0, "세포": 1.0})   # 도메인 명사 보정
        return {"nouns": nouns}

extractor = POSExtractor(extra_steps=[MedicalTermStep()])
nouns, predicators = extractor.extract(sentences)

실행 순서

[LRNounExtractor] → [extra_steps...] → [PredicatorExtractor]
  • 각 단계는 context: dict를 통해 이전 단계 결과(nouns, lrgraph 등)를 공유
  • 기본 동작(extra_steps 없음)은 완전히 동일

🤖 Generated with Claude Code

- pos_extractor.py: ExtractorStepProtocol(Protocol) 추가
  - extract(sentences, context: dict) -> dict 인터페이스 정의
- _NounExtractorStep, _PredicatorExtractorStep 어댑터 클래스 추가
- POSExtractor에 extra_steps 파라미터 추가
  - 명사 추출 직후, 용언 추출 직전에 실행되는 사용자 정의 단계
  - context dict로 단계 간 상태(nouns, lrgraph 등) 공유
- __init__.py: ExtractorStepProtocol export 추가
- test_postagger.py: Protocol 준수, context 주입 테스트 추가

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lovit
lovit merged commit 6789582 into refactor-2026-postagger Mar 9, 2026
2 checks passed
@lovit
lovit deleted the feature/239 branch March 10, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant