Skip to main content

Module matrix

Module matrix 

Source
Expand description

§연접 비용 행렬 (Connection Cost Matrix)

형태소 간 연접 비용을 저장하고 조회하는 모듈입니다.

§포맷 지원

  • 텍스트 포맷 (matrix.def): MeCab 표준 형식
  • 바이너리 포맷 (matrix.bin): 고정 크기 i16 배열
  • 압축 포맷 (matrix.bin.zst): Zstd 압축 바이너리

§예제

use mecab_ko_dict::matrix::ConnectionMatrix;

// 텍스트 파일에서 로드
let matrix = ConnectionMatrix::from_def_file("matrix.def").unwrap();

// 연접 비용 조회 (left_id=0, right_id=0)
let cost = matrix.get(0, 0);

§행렬 구조

연접 비용 행렬은 lsize x rsize 크기의 2차원 배열입니다.

  • lsize: 좌문맥 ID 개수
  • rsize: 우문맥 ID 개수
  • 접근: matrix[right_id + lsize * left_id]

Structs§

DenseMatrix
밀집 연접 비용 행렬 (Dense Matrix)
MatrixLoader
연접 비용 행렬 로더
MmapMatrix
메모리 맵 연접 비용 행렬 (Memory-Mapped Matrix)
SparseMatrix
희소 연접 비용 행렬 (Sparse Matrix)

Enums§

ConnectionMatrix
연접 비용 행렬을 위한 통합 타입

Constants§

INVALID_CONNECTION_COST
기본 비용 (연결 불가능한 경우)

Traits§

Matrix
연접 비용 행렬 인터페이스