addSentenceDetails — Add sentence numbers to tokenized documents.
addSentenceDetails(documents) detects sentence boundaries in a RunMat tokenizedDocument compatibility object and stores one SentenceNumber value per token. Use tokenDetails to view the resulting table column.
Syntax
newDocuments = addSentenceDetails(documents)
newDocuments = addSentenceDetails(documents,Name,Value)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
documents | Any | Yes | — | tokenizedDocument object. |
NameValue | Any | Variadic | — | Name-value options: Abbreviations, Starters, DiscardKnownValues. |
Returns
| Name | Type | Description |
|---|---|---|
newDocuments | Any | Updated tokenized document object. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:addSentenceDetails:InvalidInput | Input is not a supported tokenizedDocument object or option form. | addSentenceDetails: invalid input |
How addSentenceDetails works
documentsmust be a RunMattokenizedDocumentobject.- RunMat assigns sentence numbers from terminating punctuation tokens
.,!,?, and common Japanese/Korean equivalents. Abbreviationsaccepts a character vector, string array, cell array of character vectors, or a table withAbbreviationandUsagevariables.- Text abbreviation lists are treated as
regularabbreviations. TableUsagevalues can be text or categorical values ofregular,inner,reference, orunit. Startersaccepts a character vector, string array, cell array of character vectors, or categorical vector and controls whether regular abbreviations break before capitalized starter words. The default starter list is based on RunMat's EnglishstopWordslist plus common sentence starters.DiscardKnownValuesdefaults tofalse; existing complete positive integer sentence-number details are preserved. Set it totrueto recompute every sentence number.- Single-letter initialisms such as
U.S.A.are treated as regular abbreviations and are not split inside the initialism. - RunMat's sentence detector is token-level and deterministic. Exact MathWorks statistical sentence boundary models, emoji-after-terminator placement, line-provenance-aware splitting, and Japanese/Korean MeCab behavior remain broader Text Analytics work.
GPU memory and residency
addSentenceDetails updates host tokenizedDocument metadata and has no provider kernel.
Examples
Add Sentence Details
documents = tokenizedDocument(["This is an example document. It has two sentences."; "This document has one sentence."]);
documents = addSentenceDetails(documents);
tdetails = tokenDetails(documents)Expected output:
`tdetails` includes a `SentenceNumber` column.Use Custom Abbreviations
documents = tokenizedDocument("Book an appt. We'll meet then.");
documents = addSentenceDetails(documents, "Abbreviations", "appt", "Starters", "we'll")Expected output:
`appt.` is treated as a regular abbreviation and breaks only before the configured starter.Recompute Sentence Details
documents = addSentenceDetails(documents, "DiscardKnownValues", true)Expected output:
`documents` has refreshed sentence-number details.Using addSentenceDetails with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how addSentenceDetails changes the result.
Run a small addSentenceDetails example, explain the result, then change one input and compare the output.
FAQ
Does addSentenceDetails support abbreviation tables?⌄
Yes. The table must contain Abbreviation and Usage variables, and Usage values can be text or categorical regular, inner, reference, or unit values.
Does addSentenceDetails execute on the GPU?⌄
No. It updates host tokenizedDocument metadata.
Related Strings functions
Text Analytics
addDependencyDetails · addEntityDetails · addLemmaDetails · addPartOfSpeechDetails · addTypeDetails · bagOfNgrams · bagOfWords · cosineSimilarity · doc2sequence · encode · extractFileText · extractHTMLText · fastTextWordEmbedding · findElement · getAttribute · htmlTree · ind2word · isVocabularyWord · normalizeWords · readWordEmbedding · removeLongWords · removeShortWords · removeStopWords · removeWords · stopWords · tokenDetails · tokenizedDocument · trainWordEmbedding · vaderSentimentScores · vec2word · word2ind · word2vec · wordEncoding · writeWordEmbedding
Transform
append · deblank · erase · eraseBetween · erasePunctuation · eraseURLs · extractAfter · extractBefore · extractBetween · insertAfter · insertBefore · join · lower · pad · replace · replaceBetween · reverse · split · splitlines · strcat · strip · strjoin · strjust · strrep · strsplit · strtrim · upper
Core
blanks · char · compose · convertCharsToStrings · convertContainedStringsToChars · convertStringsToChars · genvarname · int2str · isletter · isspace · isStringScalar · isstrprop · mat2str · native2unicode · newline · num2str · sprintf · sscanf · str2double · str2num · strcmp · strcmpi · string · string.empty · strings · strlength · strncmp · strncmpi · strtok · unicode2native
Search
contains · endsWith · matches · startsWith · strfind
Pattern
digitsPattern · lettersPattern · pattern · regexpPattern · textBoundary · wildcardPattern
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how addSentenceDetails is executed, line by line, in Rust.
- View the source for addSentenceDetails in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.