Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

TextPosition

TextPosition["text",form]
gives a list of the starting and ending positions at which instances of form occur in text.

TextPosition["text",form,n]
gives the positions of the first n instances that occur.

Details and OptionsDetails and Options

  • Structural choices for form include:
  • "Word"word-like unit (usually delimited by whitespace)
    "Sentence"sentence-like unit (usually delimited by .)
    "Paragraph"paragraph-like unit (delimited by multiple newlines etc.)
    "Quotation"quotation delimited by quotation marks
    "Line"substring delimited by newline
    "Punctuation"punctuation mark (e.g. "?", "!!!", etc.)
    "NonText"characters not in ordinary letter-like text
  • Grammatical choices for form include:
  • "Noun","Verb",specified part of speech
    "ProperNoun"proper noun
    "Emoticon"textual emoticon
  • Formatting-based choices for form include:
  • "URL"correctly formatted URL
    "EmailAddress"correctly formatted email address
    "TwitterHandle"correctly formatted Twitter handle
    "PhoneNumber"international phone numbers
  • Semantic choices for form include:
  • "Number"number in standard format
    "Quantity"quantity with units
    "CurrencyAmount"currency with denomination
    "Country"country or country designation
    "City"city
    "Color"color specification or name
    "English","Chinese",sentences written in the specified language
    "Profanity"paragraphs that contain profanity
    "PositiveSentiment",paragraphs with positive, negative, or neutral sentiment
    Entity["type",name]strings corresponding to a particular entity
  • Combination choices for form include:
  • form1|form2|form matching any of the formi
    Containing[outer,inner]forms of type outer containing ones of type inner
  • The following options for TextPosition can be given:
  • PerformanceGoalAutomaticwhat aspects of performance to optimize
  • Possible settings for PerformanceGoal include "Speed" and "Quality".
  • TextPosition[ContentObject[]] gives positions based on the plain-text contents of the ContentObject.

ExamplesExamplesopen allclose all

Basic Examples  (5)Basic Examples  (5)

Find the words in a sentence:

In[1]:=
Click for copyable input
Out[1]=

Find the sentences in a string:

In[1]:=
Click for copyable input
Out[1]=

Find currency amounts:

In[1]:=
Click for copyable input
Out[1]=

Find cities in text:

In[1]:=
Click for copyable input
Out[1]=

Find position of colors in a ContentObject:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
Introduced in 2015
(10.2)