<!--
{
  "availability" : [
    "iOS: 12.0.0 -",
    "iPadOS: 12.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.14.0 -",
    "tvOS: 12.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NaturalLanguage",
  "identifier" : "/documentation/NaturalLanguage/NLTokenUnit/sentence",
  "metadataVersion" : "0.1.0",
  "role" : "Case",
  "symbol" : {
    "kind" : "Case",
    "modules" : [
      "Natural Language"
    ],
    "preciseIdentifier" : "c:@E@NLTokenUnit@NLTokenUnitSentence"
  },
  "title" : "NLTokenUnit.sentence"
}
-->

# NLTokenUnit.sentence

An individual sentence.

```
case sentence
```

## Discussion

Use this linguistic unit to tokenize text into sentences, like in the following example:

```swift
let text = "This is a sentence. This is another sentence."
    
let tokenizer = NLTokenizer(unit: .sentence)
tokenizer.string = text
    
let range = text.startIndex..<text.endIndex
    
let tokenArray = tokenizer.tokens(for: range)
print("Number of tokens: \(tokenArray.count)")
    
tokenizer.enumerateTokens(in: range) { tokenRange, _ in
    print(text[tokenRange])
    return true
}
```

For more information, see [Tokenizing natural language text](/documentation/NaturalLanguage/tokenizing-natural-language-text).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)