Skip to main content
Traditional pipelines segment text first, then tag the results — propagating early segmentation errors into downstream POS tags. This module eliminates that cascade by searching over word boundaries and POS labels in a single Viterbi pass, finding the globally optimal combination.

Overview

The Joint Optimization Problem

Traditional approach (sequential):
Joint approach (this module):

Benefits

Mathematical Formulation

The tagger finds:
In log space:
Components:
  • P(word_i) - Word N-gram probability
  • P(tag_i | tags) - Tag transition probability (HMM)
  • P(tag_i | word_i) - Emission probability

JointSegmentTagger Class

Parameters

Usage

Basic Segmentation and Tagging

State Space

The Viterbi algorithm operates on states:
State space: (position, word_start, current_tag, prev_tag)

Scoring Functions

Word Score

Tag Transition Score

Emission Score

Beam Pruning

To manage the large state space, beam pruning keeps only top-k states:

OOV Handling

For out-of-vocabulary words, the tagger uses morphological analysis:

Performance

Complexity

  • Time: O(n × W × T²) where n=length, W=max_word_length, T=num_tags
  • Space: O(n × beam_width)

Benchmarks

Joint is slightly slower for short texts but comparable for longer texts, with better accuracy.

Cache Management

Integration

With SpellChecker

See Also