Documentation

WordDiscoveryService

Service for discovering and creating unknown words.

Handles:

  • Finding unknown words in texts
  • Quick word creation with status
  • Hover-based word creation
  • Bulk word status operations
Tags
since
3.0.0

Table of Contents

Properties

$contextService  : WordContextService
$linkingService  : WordLinkingService

Methods

__construct()  : mixed
Constructor.
createOnHover()  : array{wid: int, word: string, wordRaw: string, translation: string, status: int, hex: string}
Create a word on hover with optional translation.
createWithStatus()  : array{id: int, rows: int}
Create a word with a specific status.
getAllUnknownWordsInText()  : array<int, array<string, mixed>>
Get all unknown words in a text (words without a WoID).
getUnknownWordsForBulkTranslate()  : array<int, array<string, mixed>>
Get unknown words for bulk translation with pagination.
getUnknownWordsInText()  : array<int, array<string, mixed>>
Get unknown words in a text (words without a WoID).
insertWordWithStatus()  : array{id: int, term: string, termlc: string, hex: string}
Insert a word with a specific status and link to text items.
markAllWordsWithStatus()  : array{int, array{wid: int, hex: string, term: string, status: int}[]}
Mark all unknown words in a text with a specific status.
processWordForWellKnown()  : array{int, array{wid: int, hex: string, term: string, status: int}|null}
Process a single word for the "mark all as well-known" operation.
setStatus()  : void
Update word status.

Properties

Methods

createOnHover()

Create a word on hover with optional translation.

public createOnHover(int $textId, string $text, int $status[, string $translation = '*' ]) : array{wid: int, word: string, wordRaw: string, translation: string, status: int, hex: string}

Used when user hovers and clicks to set a word status directly from the text.

Parameters
$textId : int

Text ID

$text : string

Word text

$status : int

Word status (1-5)

$translation : string = '*'

Optional translation

Return values
array{wid: int, word: string, wordRaw: string, translation: string, status: int, hex: string}

createWithStatus()

Create a word with a specific status.

public createWithStatus(int $langId, string $term, string $termlc, int $status) : array{id: int, rows: int}
Parameters
$langId : int

Language ID

$term : string

The term text

$termlc : string

Lowercase version of the term

$status : int

Status to set (98=ignored, 99=well-known)

Return values
array{id: int, rows: int}

Word ID and number of inserted rows

getAllUnknownWordsInText()

Get all unknown words in a text (words without a WoID).

public getAllUnknownWordsInText(int $textId) : array<int, array<string, mixed>>
Parameters
$textId : int

Text ID

Return values
array<int, array<string, mixed>>

Array of rows with Ti2Text and Ti2TextLC columns

getUnknownWordsForBulkTranslate()

Get unknown words for bulk translation with pagination.

public getUnknownWordsForBulkTranslate(int $textId, int $offset, int $limit) : array<int, array<string, mixed>>
Parameters
$textId : int

Text ID

$offset : int

Starting position

$limit : int

Number of words to return

Return values
array<int, array<string, mixed>>

Array of rows with word, Ti2LgID, pos columns

getUnknownWordsInText()

Get unknown words in a text (words without a WoID).

public getUnknownWordsInText(int $textId) : array<int, array<string, mixed>>
Parameters
$textId : int

Text ID

Return values
array<int, array<string, mixed>>

Array of rows with Ti2Text and Ti2TextLC columns

insertWordWithStatus()

Insert a word with a specific status and link to text items.

public insertWordWithStatus(int $textId, string $term, int $status) : array{id: int, term: string, termlc: string, hex: string}

Used for quick insert operations (mark as known/ignored).

Parameters
$textId : int

Text ID (to get language)

$term : string

Word text

$status : int

Status (98=ignored, 99=well-known)

Return values
array{id: int, term: string, termlc: string, hex: string}

markAllWordsWithStatus()

Mark all unknown words in a text with a specific status.

public markAllWordsWithStatus(int $textId, int $status) : array{int, array{wid: int, hex: string, term: string, status: int}[]}
Parameters
$textId : int

Text ID

$status : int

Status to apply (98=ignored, 99=well-known)

Return values
array{int, array{wid: int, hex: string, term: string, status: int}[]}

Total count and words data

processWordForWellKnown()

Process a single word for the "mark all as well-known" operation.

public processWordForWellKnown(int $status, string $term, string $termlc, int $langId) : array{int, array{wid: int, hex: string, term: string, status: int}|null}
Parameters
$status : int

New word status

$term : string

Word text

$termlc : string

Lowercase word text

$langId : int

Language ID

Return values
array{int, array{wid: int, hex: string, term: string, status: int}|null}

Rows modified and word data

setStatus()

Update word status.

public setStatus(int $wordId, int $status) : void
Parameters
$wordId : int

Word ID

$status : int

New status (1-5, 98, 99)


        
On this page

Search results