textclean

package
v0.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package textclean은 청킹 직전에 적용되는 소스별 텍스트 전처리를 모아둔다.

여기서 하는 정리는 documents.content 컬럼(수집기가 저장한 원문)을 건드리지 않는다 — internal/chunker.Split 이 문서를 청크로 쪼개기 직전에만 호출되므로, 재인덱스(re-index) 한 번으로 기존에 수집된 문서에도 곧바로 적용된다. 원문은 그대로 보존되므로 언제든 정리 규칙을 되돌리거나 바꿔도 데이터 손실이 없다.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanEmailBody

func CleanEmailBody(s string) string

CleanEmailBody는 Gmail 본문에서 인용된 이전 답장, 전달 헤더, 서명 블록을 제거해 청킹/임베딩에 실제 새로 쓴 내용만 전달되게 한다.

절대 본문 앞부분을 잃지 않도록 다음 순서로만 동작한다:

  1. 인용 시작 마커를 찾아 그 줄부터 끝까지 통째로 잘라낸다(본문은 항상 마커보다 앞에 있다고 가정).
  2. 남은 줄 중 '>' 인용 줄을 제거한다(일부 클라이언트가 최상단에도 짧은 인용을 섞어 넣는 경우에 대한 방어적 처리).
  3. 서명 구분자/모바일 서명 문구를 찾아 그 줄부터 끝까지 잘라낸다.
  4. 반복 공백 줄을 정리한다.
  5. 안전장치: 결과가 원문의 15% 미만이거나 100자 미만이면 원문을 그대로 반환한다(뉴스레터·짧은 메일 보호).

func CleanForChunking

func CleanForChunking(sourceType string, s string) string

CleanForChunking은 internal/chunker가 청킹 직전에 호출하는 단일 진입점이다. sourceType은 model.SourceType을 string으로 변환한 값이다. 지원하지 않는 소스 타입은 원문을 그대로 반환한다(무변경이 기본값).

새 소스에 전처리를 추가하려면 이 스위치에 분기를 추가하면 된다.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL