Created
March 10, 2019 19:59
-
-
Save ozgurshn/c83d95a0fe566ce9a603b77fe3818409 to your computer and use it in GitHub Desktop.
NLTokenizer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NaturalLanguage | |
let text = "All human beings are born free and equal in dignity and rights. They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood." | |
let tokenizer = NLTokenizer(unit: .word) | |
tokenizer.string = text | |
//let tokenArray = tokenizer.tokens(for: strRange) | |
tokenizer.enumerateTokens(in: text.startIndex..<text.endIndex) { tokenRange, _ in | |
print(text[tokenRange]) | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment