lasta 39097d0240 Phase 1.5: 엔티티/클레임 직접 입력 — OntologyEditorPage + 3탭 (엔티티/클레임/JSON 일괄)
백엔드 (crawler_platform/app/api/routes.py):
- POST /projects/{n}/entities: 단일 엔티티 직접 생성 (upsert)
  - CreateEntityRequest (entity_type, name, metadata)
- POST /projects/{n}/entities/bulk: 다수 엔티티 일괄 생성
  - BulkCreateEntitiesRequest, 응답 created 수 + entities
- DELETE /projects/{n}/entities/{id}: 단일 엔티티 삭제
- POST /projects/{n}/claims: 단일 클레임 직접 생성
  - CreateClaimRequest (source_name, subject_entity_id, predicate,
    object_entity_id|object_value, confidence, confidence_reason, evidence_text)
  - claim_hash로 중복 검출 → 있으면 confidence/메타 갱신
  - status="validated_claim", extraction_method="manual"
  - evidence_text 있으면 Evidence 자동 생성
- DELETE /projects/{n}/claims/{id}: 단일 클레임 삭제

프론트엔드 API (src/lib/api/):
- entities.ts: list/create/bulkCreate/delete + Zod 스키마
- claims.ts: list/create/delete + Zod 스키마 (passthrough)

TanStack Query 훅 (src/hooks/):
- useEntities.ts: useEntities, useCreateEntity, useBulkCreateEntities, useDeleteEntity
- useClaims.ts: useClaims, useCreateClaim, useDeleteClaim
- queryKeys에 entities.list, claims.list 키 팩토리

UI 프리미티브 (src/components/ui/):
- tabs.tsx: Tabs, TabsList, TabsTrigger, TabsContent (Context API 기반)

OntologyEditorPage 신규 (src/pages/):
- 3개 탭 구조:
  * 엔티티 탭: 도메인의 entity_types에서 타입 선택 + 이름 입력 → 추가
    + 엔티티 목록 (max-h scroll, 타입 배지, 삭제 버튼)
  * 클레임 탭: 소스/주어/술어/목적어(엔티티 or 리터럴)/신뢰도 입력
    + 클레임 목록 (S-P-O 시각화, 신뢰도, status 배지)
  * JSON 일괄 탭: textarea에 { entities: [...] } 붙여넣기 → 파싱 → bulkCreate
- react-hook-form + zod 검증
- useOntology(domain)으로 entity_types/predicates 자동 로드
- 삭제 confirm 대화상자, sonner 토스트

라우팅 & Sidebar:
- App.tsx: /editor/:projectId 라우트 추가
- AppShell: 사이드바에 "온톨로지 편집" 메뉴 (Network 아이콘)

i18n: editor.*, nav.editor 키 (한/영)

UI_REBUILD_PLAN.md 업데이트:
- Phase 1.4 `00786a4` 커밋 기록
- Phase 1.5 완료 표시 + 대기 보드 Phase 2/3 재정렬

다음 단계: Phase 2 — 그래프 시각화/편집 (Cytoscape React 래퍼)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-14 19:10:37 +09:00
2026-05-13 19:57:34 +09:00
2026-05-13 19:57:34 +09:00
2026-05-13 19:57:34 +09:00
2026-05-11 13:02:11 +09:00
2026-05-13 19:57:34 +09:00
2026-05-13 19:57:34 +09:00
2026-05-13 19:57:34 +09:00
2026-05-13 19:57:34 +09:00
2026-05-13 19:57:34 +09:00
2026-05-13 19:57:34 +09:00
2026-05-11 22:55:01 +09:00
2026-05-11 22:55:01 +09:00
2026-05-13 19:57:34 +09:00

Ontology Platform

온톨로지 플랫폼은 웹에서 구조화된 지식(엔티티/관계)을 자동 추출, 검증, 저장하는 고속 시스템입니다.

Phase 0-4 전체 구현 완료 | 추출(10초) → 검증(<100ms) → 그래프 저장 → 벡터 검색

🚀 빠른 시작

1. 설치

# 기본 설치 (Phase 0-1: 추출)
pip install fastapi uvicorn pydantic trafilatura httpx

# Phase 2 추가 (동적 페이지)
pip install crawl4ai

# Phase 4 추가 (Neo4j)
pip install neo4j sentence-transformers

2. Phase 0-1만 사용 (가장 간단)

# API 서버 시작
python -m uvicorn ontology_platform.ont_platform.api.phase0_app:app --reload

# URL에서 추출
curl -X POST "http://localhost:8000/api/v1/extract/url?url=https://example.com"

3. Phase 4 (그래프 검색) 포함

# Neo4j 시작
docker-compose -f docker-compose.neo4j.yml up -d

# API 서버 시작
python -m uvicorn ontology_platform.ont_platform.api.phase0_app:app --reload

# 추출 → 수집 → 검색
curl -X POST "http://localhost:8000/api/v1/extract/url?url=https://example.com"
curl -X POST "http://localhost:8000/api/v1/search/ingest" -d '{"entities": [...], "relations": [...]}'
curl "http://localhost:8000/api/v1/search/vector?query=machine+learning"

📋 Phase별 기능

Phase 기능 시간 상태
0-1 HTML 추출 (Trafilatura) 10-15초
2 동적 페이지 (Crawl4AI) 20-30초
3A 경량 검증 (Pydantic) <100ms
3B SPARQL 검증 <500ms
4 Neo4j + 벡터 검색 50-200ms

🎯 사용 예시

예시 1: 기본 추출 (10초)

curl -X POST "http://localhost:8000/api/v1/extract/url?url=https://wikipedia.org/wiki/Python"

응답:

{
  "url": "https://wikipedia.org/wiki/Python",
  "title": "Python - Wikipedia",
  "entities": [
    {
      "id": "E_1",
      "label": "Python",
      "type": "ProgrammingLanguage",
      "confidence": 0.95
    }
  ],
  "relations": [...],
  "extraction_time_sec": 9.5,
  "validation_passed": true
}

예시 2: 동적 페이지 (25초)

curl -X POST "http://localhost:8000/api/v1/extract/url?url=https://app.example.com&profile=dynamic_page"

예시 3: 그래프 수집 + 검색

# 1. 추출
RESULT=$(curl -s -X POST "http://localhost:8000/api/v1/extract/url?url=https://example.com")

# 2. Neo4j에 수집
curl -X POST "http://localhost:8000/api/v1/search/ingest" \
  -H "Content-Type: application/json" \
  -d "{\"entities\": $(echo $RESULT | jq '.entities'), \"relations\": $(echo $RESULT | jq '.relations')}"

# 3. 벡터 검색
curl "http://localhost:8000/api/v1/search/vector?query=programming&limit=10"

# 4. 그래프 통계
curl "http://localhost:8000/api/v1/search/stats"

# 5. 엔티티 이웃
curl "http://localhost:8000/api/v1/search/entity/E_1?depth=1"

🔧 설정

Phase 선택 (validators.py)

# 경량 검증 (기본)
guard = OntologyGuard(validator_type="lightweight")

# SPARQL 검증
guard = OntologyGuard(validator_type="ontocast")

Neo4j 연결 (neo4j_adapter.py)

# 기본값
config = Neo4jConfig()  # localhost:7687

# 커스텀
config = Neo4jConfig(
    uri="bolt://custom-host:7687",
    username="user",
    password="pass",
    database="mydb"
)
adapter = Neo4jAdapter(config=config)

📊 API 문서

서버 시작 후:

주요 엔드포인트

POST   /api/v1/extract/url              추출
GET    /api/v1/search/stats             통계
POST   /api/v1/search/vector            벡터 검색
GET    /api/v1/search/entity/{id}       이웃 탐색
POST   /api/v1/search/ingest            그래프 수집

🧪 테스트

# Phase 0-1
python test_phase0_extraction.py

# Phase 2
python test_phase2_crawl.py

# Phase 3A
python test_phase3_validation.py

# Phase 3B
python test_phase3_option_b.py

# Phase 4
python test_phase4_integration.py

📦 의존성

  • FastAPI: API 프레임워크
  • Trafilatura: HTML 추출
  • Crawl4AI: 동적 크롤링 (선택)
  • Pydantic: 데이터 검증
  • Neo4j: 그래프 DB (선택)
  • SentenceTransformers: 벡터 임베딩 (선택)

🐳 Docker

# Neo4j만
docker-compose -f docker-compose.neo4j.yml up -d

# 전체 스택 (향후)
docker-compose up -d

📚 상세 문서

🎓 설계 원칙

  1. Phase-gated: 각 Phase는 선택사항
  2. Pluggable: 여러 검증 방식 지원
  3. Async: 높은 동시성
  4. Resilient: 의존성 부재 시에도 동작

💡 다음 단계

Phase 5: GraphRAG (선택)

  • RDF ↔ Property Graph 변환
  • Entity Resolver
  • Subgraph retrieval

Advanced Features

  • Critic loop (자동 수정)
  • Few-shot learning
  • Zero-shot 분류

🔗 관련 링크

📝 라이센스

MIT License


Version: 0.4.0 (Phase 0-4 완료)
Updated: 2026-05-14

Description
No description provided
Readme 232 MiB
Languages
Jupyter Notebook 46%
Python 35.1%
TypeScript 12.4%
JavaScript 2.1%
CSS 0.9%
Other 3.2%