![]() |
LIMA
Libre Multilingual Analyzer — C++ API
|
The implementation of the segmenter, a SegmentationClassifier, itself a RnnSequenceClassifier. More...
#include <deeplima/segmentation/impl/segmentation_impl.h>
Public Member Functions | |
| SegmentationImpl () | |
| virtual | ~SegmentationImpl ()=default |
| virtual void | load (const std::string &fn) |
| void | init (size_t threads, size_t buffer_size_per_thread) |
| virtual void | parse_from_stream (const read_callback_t fn) override |
| virtual void | register_handler (const segmentation_callback_t fn) override |
| virtual void | finalize () override |
| Cleanup all remaining locks if any. | |
| virtual bool | predicts_mwt () const override |
| MWT-aware iff the model has more than the base segmentation tag classes (i.e. | |
Public Member Functions inherited from deeplima::segmentation::ISegmentation | |
| virtual | ~ISegmentation () |
Public Member Functions inherited from deeplima::RnnSequenceClassifier< Model, InputVectorizer, Out > | |
| RnnSequenceClassifier () | |
| virtual | ~RnnSequenceClassifier () |
| int32_t | next_slot (uint32_t idx) |
| std::shared_ptr< StdMatrix< Out > > | get_output () |
| virtual void | reset () |
| Need to be called to be able to reuse this classifier on several sequences. | |
| virtual void | init (uint32_t max_feat, uint32_t overlap, uint32_t num_slots, uint32_t slot_len, uint32_t num_threads, bool precomputed_input=false) |
| void | load (const std::string &fn) |
| void | get_classes_from_fn (const std::string &fn, std::vector< std::string > &classes_names, std::vector< std::vector< std::string > > &classes) |
| uint8_t | get_output (uint64_t pos, uint8_t cls) |
| uint64_t | get_slot_begin (uint32_t idx) const |
| bool | get_slot_started (uint32_t idx) const |
| uint64_t | get_slot_end (uint32_t idx) const |
| uint8_t | get_lock_count (uint32_t idx) const |
| void | increment_lock_count (uint32_t idx, uint8_t v=1) |
| void | decrement_lock_count (uint32_t idx) |
| uint64_t | get_start_timepoint () const |
| void | increment_timepoint (uint64_t &timepoint) |
| uint32_t | get_num_slots () const |
| uint32_t | get_slot_size () const |
| int32_t | get_slot_idx (uint64_t timepoint) const |
| void | set_slot_lengths (uint32_t idx, const std::vector< size_t > &lengths) |
| void | set_slot_begin (uint32_t idx, uint64_t slot_begin) |
| void | set_slot_end (uint32_t idx, uint64_t slot_end) |
| void | start_job (uint32_t idx, bool no_more_data=false) |
| void | wait_for_slot (uint32_t idx) |
| void | pretty_print () const |
Public Member Functions inherited from deeplima::ThreadPool< RnnSequenceClassifier< Model, InputVectorizer, Out > > | |
| ThreadPool (size_t num_threads=0) | |
| void | init (size_t num_threads) |
| size_t | get_num_threads () const |
| virtual | ~ThreadPool () |
| void | stop () |
| size_t | running () |
| void | push (void *job) |
Protected Member Functions | |
| void | vectorize_timepoint (uint64_t timepoint) |
| void | increment_timepoint (uint64_t &timepoint) |
| void | send_results (int32_t slot_idx) |
| void | send_next_results () |
| void | acquire_slot () |
| void | handle_timepoint () |
| void | no_more_data () |
Protected Member Functions inherited from deeplima::RnnSequenceClassifier< Model, InputVectorizer, Out > | |
| int32_t | prev_slot (uint32_t idx) |
| void | clear_slot (uint32_t idx) |
| void | start_job_impl (uint32_t idx) |
| Push the slot idx in the thread pool for starting the job on it. | |
Protected Member Functions inherited from deeplima::ThreadPool< RnnSequenceClassifier< Model, InputVectorizer, Out > > | |
| bool | wait_for_new_job (void **job) |
| This will wait until a job is available and then job parameter will be set to this available which will be removed from the list. | |
| void | wait_for_any_job_notification (const std::function< bool()> fn) |
| void | thread_fn (size_t worker_id) |
Protected Attributes | |
| std::vector< uint8_t > | m_char_len |
| InputEncoder | m_input_encoder |
| OutputDecoder | m_decoder |
| uint64_t | m_current_timepoint |
| uint32_t | m_current_slot_timepoints |
| int32_t | m_current_slot_no |
| int32_t | m_last_completed_slot |
| locked_buffer_set_t | m_buff_set |
| size_t | m_curr_buff_idx |
Protected Attributes inherited from deeplima::RnnSequenceClassifier< Model, InputVectorizer, Out > | |
| friend | RnnSequenceClassifierThreadPool |
| uint32_t | m_overlap |
| uint32_t | m_num_slots |
| uint32_t | m_slot_len |
| std::vector< slot_t > | m_slots |
| std::vector< std::vector< size_t > > | m_lengths |
| std::shared_ptr< StdMatrix< Out > > | m_output |
Protected Attributes inherited from deeplima::ThreadPool< RnnSequenceClassifier< Model, InputVectorizer, Out > > | |
| std::vector< std::thread > | m_workers |
| std::atomic< bool > | m_stop |
| std::queue< void * > | m_jobs |
| std::mutex | m_mutex |
| std::condition_variable | m_cv |
| std::mutex | m_mutex_notify |
| std::condition_variable | m_cv_notify |
Additional Inherited Members | |
Public Types inherited from deeplima::segmentation::ISegmentation | |
| typedef std::function< bool(uint8_t *buffer, int32_t &read, int32_t max) > | read_callback_t |
Protected Types inherited from deeplima::RnnSequenceClassifier< Model, InputVectorizer, Out > | |
| enum | slot_flags_t : uint8_t { none = 0x00 , left_overlap = 0x01 , right_overlap = 0x02 , max_flags } |
| typedef RnnSequenceClassifier< Model, InputVectorizer, Out > | ThisClass |
| typedef ThreadPool< ThisClass > | RnnSequenceClassifierThreadPool |
Static Protected Member Functions inherited from deeplima::RnnSequenceClassifier< Model, InputVectorizer, Out > | |
| static void | run_one_job (ThisClass *this_ptr, size_t worker_id, void *p) |
The implementation of the segmenter, a SegmentationClassifier, itself a RnnSequenceClassifier.
Definition at line 69 of file segmentation_impl.h.
| deeplima::segmentation::impl::SegmentationImpl::SegmentationImpl | ( | ) |
Definition at line 10 of file segmentation_impl.cpp.
|
virtualdefault |
|
protected |
Definition at line 275 of file segmentation_impl.cpp.
|
overridevirtual |
Cleanup all remaining locks if any.
Implements deeplima::segmentation::ISegmentation.
Definition at line 329 of file segmentation_impl.cpp.
|
protected |
Definition at line 303 of file segmentation_impl.cpp.
|
protected |
Definition at line 184 of file segmentation_impl.cpp.
| void deeplima::segmentation::impl::SegmentationImpl::init | ( | size_t | threads, |
| size_t | buffer_size_per_thread | ||
| ) |
Definition at line 50 of file segmentation_impl.cpp.
|
virtual |
Definition at line 35 of file segmentation_impl.cpp.
|
protected |
Definition at line 320 of file segmentation_impl.cpp.
|
overridevirtual |
Implements deeplima::segmentation::ISegmentation.
Definition at line 61 of file segmentation_impl.cpp.
|
inlineoverridevirtual |
MWT-aware iff the model has more than the base segmentation tag classes (i.e.
it was trained with –mwt, giving the 4 extra _MWT end tags). The output class count is recorded as the size of the first output dict at model-conversion time.
Reimplemented from deeplima::segmentation::ISegmentation.
Definition at line 98 of file segmentation_impl.h.
|
overridevirtual |
Implements deeplima::segmentation::ISegmentation.
Definition at line 169 of file segmentation_impl.cpp.
|
protected |
Definition at line 236 of file segmentation_impl.cpp.
|
protected |
Definition at line 191 of file segmentation_impl.cpp.
|
protected |
Definition at line 174 of file segmentation_impl.cpp.
|
protected |
Definition at line 132 of file segmentation_impl.h.
|
protected |
Definition at line 121 of file segmentation_impl.h.
|
protected |
Definition at line 133 of file segmentation_impl.h.
|
protected |
Definition at line 129 of file segmentation_impl.h.
|
protected |
Definition at line 127 of file segmentation_impl.h.
|
protected |
Definition at line 126 of file segmentation_impl.h.
|
protected |
Definition at line 124 of file segmentation_impl.h.
|
protected |
Definition at line 123 of file segmentation_impl.h.
|
protected |
Definition at line 130 of file segmentation_impl.h.