pub struct LSMMap { /* private fields */ }Expand description
An opaque Core Foundation type representing an LSM map (mutable).
See also Apple’s documentation
Implementations§
Source§impl LSMMap
impl LSMMap
Sourcepub unsafe fn new(
alloc: Option<&CFAllocator>,
flags: CFOptionFlags,
) -> CFRetained<LSMMap>
pub unsafe fn new( alloc: Option<&CFAllocator>, flags: CFOptionFlags, ) -> CFRetained<LSMMap>
Creates a new LSM map. Call CFRelease to dispose.
Source§impl LSMMap
impl LSMMap
Sourcepub unsafe fn set_properties(&self, properties: &CFDictionary)
pub unsafe fn set_properties(&self, properties: &CFDictionary)
Set a dictionary of properties for the map. LSM makes its own copy of the properties, there’s no need to retain them past this call.
§Safety
properties generics must be of the correct type.
Sourcepub unsafe fn properties(&self) -> CFRetained<CFDictionary>
pub unsafe fn properties(&self) -> CFRetained<CFDictionary>
Get a dictionary of properties for the map. LSM retains ownership of this dictionary, do not release it.
Sourcepub unsafe fn start_training(&self) -> i32
pub unsafe fn start_training(&self) -> i32
Puts the map into training mode, preparing it for the addition of more categories and/or texts. This function will be somewhat expensive, as it requires substantial data structure reorganization.
Sourcepub unsafe fn add_category(&self) -> LSMCategory
pub unsafe fn add_category(&self) -> LSMCategory
Adds another category and returns its category identifier.
Sourcepub unsafe fn category_count(&self) -> CFIndex
pub unsafe fn category_count(&self) -> CFIndex
Returns the number of categories in the map.
Sourcepub unsafe fn set_stop_words(&self, textref: &LSMText) -> i32
pub unsafe fn set_stop_words(&self, textref: &LSMText) -> i32
The specified words will be omitted from all classification efforts. Needs to be called before any other texts are created. The textref is no longer needed after this call.
Sourcepub unsafe fn add_text(&self, textref: &LSMText, category: LSMCategory) -> i32
pub unsafe fn add_text(&self, textref: &LSMText, category: LSMCategory) -> i32
Adds a training text to the given category. The textref is no longer needed after this call.
Sourcepub unsafe fn add_text_with_weight(
&self,
textref: &LSMText,
category: LSMCategory,
weight: c_float,
) -> i32
pub unsafe fn add_text_with_weight( &self, textref: &LSMText, category: LSMCategory, weight: c_float, ) -> i32
Adds a training text to the given category with a weight different from 1. The weight may be negative, but global counts will be pinned to 0. The textref is no longer needed after this call.
Sourcepub unsafe fn compile(&self) -> i32
pub unsafe fn compile(&self) -> i32
Compiles the map into executable form and puts it into mapping mode, preparing it for the classification of texts. This function is computationally expensive.
Sourcepub unsafe fn new_clusters(
alloc: Option<&CFAllocator>,
mapref: &LSMMap,
subset: Option<&CFArray>,
num_clusters: CFIndex,
flags: CFOptionFlags,
) -> Option<CFRetained<CFArray>>
pub unsafe fn new_clusters( alloc: Option<&CFAllocator>, mapref: &LSMMap, subset: Option<&CFArray>, num_clusters: CFIndex, flags: CFOptionFlags, ) -> Option<CFRetained<CFArray>>
Compute a set of clusters grouping similar categories or words. If subset is non-NULL, only perform clustering on the categories or words listed.
§Safety
subset generic must be of the correct type.
Source§impl LSMMap
impl LSMMap
Sourcepub unsafe fn apply_clusters(&self, clusters: &CFArray) -> i32
pub unsafe fn apply_clusters(&self, clusters: &CFArray) -> i32
Group categories or words (tokens) into the specified sets of clusters.
§Safety
clusters generic must be of the correct type.
Source§impl LSMMap
impl LSMMap
Sourcepub unsafe fn write_to_url(&self, file: &CFURL, flags: CFOptionFlags) -> i32
pub unsafe fn write_to_url(&self, file: &CFURL, flags: CFOptionFlags) -> i32
Compiles the map if necessary and then stores it into the given file.
Sourcepub unsafe fn from_url(
alloc: Option<&CFAllocator>,
file: &CFURL,
flags: CFOptionFlags,
) -> Option<CFRetained<LSMMap>>
pub unsafe fn from_url( alloc: Option<&CFAllocator>, file: &CFURL, flags: CFOptionFlags, ) -> Option<CFRetained<LSMMap>>
Loads a map from a given file.
Source§impl LSMMap
impl LSMMap
Sourcepub unsafe fn write_to_stream(
&self,
textref: Option<&LSMText>,
stream: &CFWriteStream,
options: CFOptionFlags,
) -> i32
pub unsafe fn write_to_stream( &self, textref: Option<&LSMText>, stream: &CFWriteStream, options: CFOptionFlags, ) -> i32
Writes information about a map and/or text to a stream in text form
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: ConcreteType,
Attempt to downcast the type to that of type T.
This is the reference-variant. Use CFRetained::downcast if you
want to convert a retained type. See also ConcreteType for more
details on which types support being converted to.
Sourcepub fn retain_count(&self) -> usize
pub fn retain_count(&self) -> usize
Get the reference count of the object.
This function may be useful for debugging. You normally do not use this function otherwise.
Beware that some things (like CFNumbers, small CFStrings etc.) may
not have a normal retain count for optimization purposes, and can
return usize::MAX in that case.
Trait Implementations§
Source§impl ConcreteType for LSMMap
impl ConcreteType for LSMMap
Source§impl RefEncode for LSMMap
impl RefEncode for LSMMap
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for LSMMap
impl Type for LSMMap
Source§fn retain(&self) -> CFRetained<Self>where
Self: Sized,
fn retain(&self) -> CFRetained<Self>where
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>where
Self: Sized,
core-foundation crate. Read more