February 2018
Intermediate to advanced
378 pages
10h 14m
English
NSLinguisticTagger is an all-in-one class for language detection, tokenization, lemmatization, part-of-speech tagging, named entity recognition and so on. The API is in the traditions of Objective-C: You have to create an instance of the class with some options, then assign it with a string to analyze, and then iterate through tags that it had found using enumerateTags() method. For each tag, it returns NSRange object which is somewhat inconvenient to use in Swift, so we have to add some utility functions to convert them to Swift ranges:
extension String { func range(from nsRange: NSRange) -> Range<String.Index>? { guard let from16 = utf16.index(utf16.startIndex, offsetBy: nsRange.location, limitedBy: utf16.endIndex), ...Read now
Unlock full access