Struct morph_rs::MorphAnalyzer

source ·
pub struct MorphAnalyzer {
    pub fst: Map<Vec<u8>>,
    pub word_parses: Vec<Vec<Parse>>,
    pub tags: Vec<SmallVec<[Grammem; 8]>>,
    pub lemmas: Vec<SmallString<[u8; 16]>>,
    pub paradigms: Vec<Vanga>,
}
Expand description

Морфологический анализатор, образованный из словаря.

Fields§

§fst: Map<Vec<u8>>§word_parses: Vec<Vec<Parse>>§tags: Vec<SmallVec<[Grammem; 8]>>§lemmas: Vec<SmallString<[u8; 16]>>§paradigms: Vec<Vanga>

Implementations§

source§

impl MorphAnalyzer

source

pub fn from_dictionary(dictionary: Dictionary) -> MopsResult<Self>

Создание анализатора из словаря.

source

pub fn parse_word(&self, word: &str) -> Result<ParsedWords, ParseErr>

Парсинг слова.

source

pub fn normalized_word(&self, word: &str) -> Result<NormalizedWords, ParseErr>

Нормализация слова.

source§

impl MorphAnalyzer

Основная функциональность связана с поиском всех возможных тэгов и нормальных форм.

source

pub fn create( dict_path: PathBuf, out_dir: PathBuf, lang: Language ) -> MopsResult<Dictionary>

Первичное создание словаря.

dict_path - путь до словаря OpenCorpora
out_dir - место, где будет хранится fst и бинарная часть словаря для будущего открытия
language - язык, по-дефолту и пока единственный, Русский.

source

pub fn init(dictionary: Dictionary) -> MopsResult<Self>

source

pub fn init_with_reader( dict_path: PathBuf, out_dir: PathBuf, lang: Language ) -> MopsResult<Dictionary>

Первичное создание словаря по переданному пути с чтением из буфера.

Чтение из буфера несколько медленнее, чем из строки, но занимает сильно меньше памяти.

dict_path - путь до словаря OpenCorpora
out_dir - место, где будет хранится fst и бинарная часть словаря для будущего открытия
language - язык, по-дефолту и пока единственный, Русский.

source

pub fn open(path: PathBuf) -> MopsResult<Self>

Открытие словаря из бинарных данных.

source

pub fn parse(&self, word: &str) -> MopsResult<ParsedWords>

Парсинг слова. Получение всех возможных результатов.

Все варианты парсинга возвращаются в отсортированном порядке, гарантируя единообразие выдачи между запусками.

source

pub fn normalize(&self, word: &str) -> MopsResult<NormalizedWords>

Нормализация слова. Получение всех возможных результатов.

Все варианты нормализации возвращаются в отсортированном порядке, гарантируя единообразие выдачи между запусками.

source

pub fn inflect(&self, word: &str) -> MopsResult<NormalizedWords>

v0.1.0 - аналогично normalize() Приведение слова к начальной форме.

source

pub fn is_known(&self, word: &str) -> bool

Проверка слова на наличие в словаре.

source

pub fn parse_get( &self, word: &str, index: usize ) -> MopsResult<Option<ParsedWord>>

Парсинг слова и взятие нужного по индексу набора граммем.

source

pub fn parse_grammemes( &self, word: &str, grammemes: Vec<Grammem> ) -> MopsResult<Option<ParsedWord>>

Парсинг слова и взятие нужного слова в зависимости от нужного набора граммем.

source

pub fn normalize_get( &self, word: &str, index: usize ) -> MopsResult<Option<NormalizedWord>>

Нормализация слова и взятие по индексу формы слова с ее граммемами.

source

pub fn normalize_grammemes( &self, word: &str, grammemes: Vec<Grammem> ) -> MopsResult<Option<NormalizedWord>>

Нормализация слова и взятие нужного слова в зависимости от нужного набора граммем.

Trait Implementations§

source§

impl Allocative for MorphAnalyzer

source§

fn visit<'allocative_a, 'allocative_b: 'allocative_a>( &self, visitor: &'allocative_a mut Visitor<'allocative_b> )

source§

impl Debug for MorphAnalyzer

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more