tokenDetails — Return a table of token details for tokenized documents.
tokenDetails(documents) returns a table describing the tokens stored in a RunMat tokenizedDocument compatibility object.
Syntax
tdetails = tokenDetails(documents)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
documents | Any | Yes | — | tokenizedDocument object. |
Returns
| Name | Type | Description |
|---|---|---|
tdetails | Any | Token detail table. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:tokenDetails:InvalidInput | Input is not a supported tokenizedDocument object or option form. | tokenDetails: invalid input |
How tokenDetails works
documentsmust be a RunMattokenizedDocumentobject created bytokenizedDocument.- Normally tokenized documents return table variables
Token,DocumentNumber,LineNumber,Type, andLanguage. - After
addSentenceDetails, documents also return aSentenceNumbervariable afterDocumentNumber. - After
addPartOfSpeechDetails, documents also return aPartOfSpeechvariable afterLanguage. - After
addEntityDetails, documents also return anEntityvariable afterPartOfSpeechwhen part-of-speech details are present, otherwise afterLanguage. - After
addLemmaDetails, documents also return aLemmavariable afterLanguage; if multiple language details are present,PartOfSpeechprecedesEntity, andEntityprecedesLemma. - After
addDependencyDetails, documents also returnHeadandDependencyvariables after the other language-detail variables. - Pre-tokenized documents created with
TokenizeMethod,"none"initially return onlyTokenandDocumentNumber, matching MATLAB's manually tokenized form. - After
addTypeDetails, pre-tokenized documents also return aTypevariable. Typevalues are derived from RunMat's lightweight tokenizer and includeletters,digits,punctuation,email-address,web-address,hashtag,at-mention,emoticon,emoji, andother.LineNumberis currently1for each token because RunMat's tokenizer stores document-level tokens and does not yet preserve per-line token provenance.- Exact MathWorks dependency-parser and full language-model parity remain broader Text Analytics work.
GPU memory and residency
tokenDetails constructs a host table and has no provider kernel.
Examples
View Token Details
documents = tokenizedDocument(["alpha 123"; "visit https://example.com"]);
tdetails = tokenDetails(documents)Expected output:
`tdetails` is a table with token text, document number, line number, token type, and language.Add Types To Pre-Tokenized Documents
documents = tokenizedDocument(["For" "more" "information"], "TokenizeMethod", "none");
documents = addTypeDetails(documents);
tdetails = tokenDetails(documents)Expected output:
`tdetails` includes `Token`, `DocumentNumber`, and `Type`.Add Sentence Numbers
documents = tokenizedDocument("First sentence. Second sentence.");
documents = addSentenceDetails(documents);
tdetails = tokenDetails(documents)Expected output:
`tdetails` includes `SentenceNumber`.Add Lemmas
documents = tokenizedDocument("The dogs ran.");
documents = addLemmaDetails(documents);
tdetails = tokenDetails(documents)Expected output:
`tdetails` includes `Lemma`.Add Part-Of-Speech Tags
documents = tokenizedDocument("The dogs are running.");
documents = addPartOfSpeechDetails(documents);
tdetails = tokenDetails(documents)Expected output:
`tdetails` includes `PartOfSpeech`.Add Entity Tags
documents = tokenizedDocument("Mary uses MATLAB at MathWorks.");
documents = addEntityDetails(documents);
tdetails = tokenDetails(documents)Expected output:
`tdetails` includes `Entity`.Add Dependency Details
documents = tokenizedDocument("The dogs chase cats.");
documents = addDependencyDetails(documents);
tdetails = tokenDetails(documents)Expected output:
`tdetails` includes `Head` and `Dependency`.Using tokenDetails with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how tokenDetails changes the result.
Run a small tokenDetails example, explain the result, then change one input and compare the output.
FAQ
Does tokenDetails return sentence or part-of-speech details?⌄
RunMat returns SentenceNumber after addSentenceDetails, PartOfSpeech after addPartOfSpeechDetails, Entity after addEntityDetails, Lemma after addLemmaDetails, and Head/Dependency after addDependencyDetails. Exact model parity remains tracked by the Text Analytics umbrella issue.
Does tokenDetails execute on the GPU?⌄
No. It builds a host table from token metadata.
Related Strings functions
Text Analytics
addDependencyDetails · addEntityDetails · addLemmaDetails · addPartOfSpeechDetails · addSentenceDetails · addTypeDetails · bagOfNgrams · bagOfWords · cosineSimilarity · doc2sequence · encode · extractFileText · extractHTMLText · fastTextWordEmbedding · findElement · getAttribute · htmlTree · ind2word · isVocabularyWord · normalizeWords · readWordEmbedding · removeLongWords · removeShortWords · removeStopWords · removeWords · stopWords · 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 tokenDetails is executed, line by line, in Rust.
- View the source for tokenDetails 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.