pub struct Lattice { /* private fields */ }Expand description
Lattice 구조
입력 텍스트의 모든 형태소 분석 후보를 담는 격자 구조입니다.
§메모리 최적화
nodes벡터는 재사용을 위해clear()시 용량 유지ends_at,starts_at도 용량 유지하여 재할당 최소화
Implementations§
Source§impl Lattice
impl Lattice
Sourcepub fn original_text(&self) -> &str
pub fn original_text(&self) -> &str
원본 텍스트 반환
Sourcepub fn original_byte_pos(&self, stripped_char_pos: usize) -> usize
pub fn original_byte_pos(&self, stripped_char_pos: usize) -> usize
Map a stripped-text char position to the corresponding byte offset in the original (space-included) text.
Sourcepub fn char_pos_from_start_and_byte_len(
&self,
start_pos: usize,
byte_len: usize,
) -> usize
pub fn char_pos_from_start_and_byte_len( &self, start_pos: usize, byte_len: usize, ) -> usize
특정 위치에서 시작하는 바이트 오프셋을 주어진 바이트 길이만큼 더한 뒤 해당 위치의 문자 인덱스를 반환합니다.
start_pos의 바이트 시작 위치에 byte_len을 더한 결과에 대응하는
문자 인덱스를 binary search로 빠르게 구합니다.
이를 통해 entry.surface.chars().count() 비용을 줄일 수 있습니다.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
노드 개수 (BOS, EOS 포함)
Sourcepub fn nodes_ending_at(&self, pos: usize) -> impl Iterator<Item = &Node>
pub fn nodes_ending_at(&self, pos: usize) -> impl Iterator<Item = &Node>
특정 위치에서 끝나는 노드들
Sourcepub fn nodes_starting_at(&self, pos: usize) -> impl Iterator<Item = &Node>
pub fn nodes_starting_at(&self, pos: usize) -> impl Iterator<Item = &Node>
특정 위치에서 시작하는 노드들
Sourcepub fn add_node(&mut self, builder: NodeBuilder) -> NodeId
pub fn add_node(&mut self, builder: NodeBuilder) -> NodeId
Sourcepub fn has_space_at(&self, char_pos: usize) -> bool
pub fn has_space_at(&self, char_pos: usize) -> bool
특정 위치에 띄어쓰기가 있는지 확인
Source§impl Lattice
impl Lattice
Sourcepub fn stats(&self) -> LatticeStats
pub fn stats(&self) -> LatticeStats
통계 정보 계산
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
메모리 사용량 추정 (바이트)
Lattice가 사용하는 대략적인 메모리 크기를 반환합니다.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Lattice
impl RefUnwindSafe for Lattice
impl Send for Lattice
impl Sync for Lattice
impl Unpin for Lattice
impl UnsafeUnpin for Lattice
impl UnwindSafe for Lattice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more