TextParsing
in package
Text parsing and processing utilities (facade).
Delegates to JapaneseTextParser, StandardTextParser, and TextParsingPersistence.
Tags
Table of Contents
Methods
- checkText() : array{sentences: int, words: int, unknownPercent: float, preview: string}
- Check/preview text and return parsing statistics without saving.
- parseAndDisplayPreview() : void
- Parse text and display preview HTML for validation.
- parseAndSave() : void
- Parse text and save to database.
- splitIntoSentences() : array<string|int, string>
- Split text into sentences without database operations.
Methods
checkText()
Check/preview text and return parsing statistics without saving.
public
static checkText(string $text, int $lid) : array{sentences: int, words: int, unknownPercent: float, preview: string}
Use this method to get text statistics for preview purposes. Does not output any HTML or save to database.
Parameters
- $text : string
-
Text to parse
- $lid : int
-
Language ID
Return values
array{sentences: int, words: int, unknownPercent: float, preview: string}parseAndDisplayPreview()
Parse text and display preview HTML for validation.
public
static parseAndDisplayPreview(string $text, int $lid) : void
Use this method for the text checking UI. Outputs HTML directly to show parsed sentences and word statistics.
Parameters
- $text : string
-
Text to parse
- $lid : int
-
Language ID
parseAndSave()
Parse text and save to database.
public
static parseAndSave(string $text, int $lid, int $textId) : void
Use this method when creating or updating texts. Parses the text and inserts sentences and text items into the database.
Parameters
- $text : string
-
Text to parse
- $lid : int
-
Language ID
- $textId : int
-
Text ID (must be positive)
Tags
splitIntoSentences()
Split text into sentences without database operations.
public
static splitIntoSentences(string $text, int $lid) : array<string|int, string>
Use this method when you only need to split text into sentences without saving to the database (e.g., for long text splitting).
Parameters
- $text : string
-
Text to parse
- $lid : int
-
Language ID
Tags
Return values
array<string|int, string> —Array of sentences