How Standalone and Interactive modes work
masterFarasapy supports two execution modes for its underlying Java binaries. Choosing the right mode depends on your input size and frequency of use.
Standalone Mode (Default)
In this mode, the object calls the binary for every task execution. It uses temporary files for input and output, which are garbage collected after the task ends.
- Best for: Large input texts that you only need to process once.
- Drawback: Some binaries (like the diacritizer) may have a slow startup time.
Interactive Mode
In this mode, the binary is run once upon instantiation. The library then feeds text to the running binary and captures the output.
- Best for: Small input texts that you need to process multiple times (improves speed by avoiding repeated binary startup).
- Usage: Pass
interactive=Trueto the class constructor. - Warning: Avoid passing very large lines in interactive mode as it may cause unexpected behavior. It is good practice to call
.terminate()on the object when finished to avoid unexpected behavior.
# Example of Interactive Mode
segmenter = FarasaSegmenter(interactive=True)
segmented = segmenter.segment(sample)
segmenter.terminate() # Recommended practice