public void GetTags() { using (var tagger = new NLTagger(NLTagScheme.LexicalClass, NLTagScheme.Lemma) { String = Text }) { Assert.That(tagger.DominantLanguage, Is.EqualTo(NLLanguage.English), "DominantLanguage"); var tags = tagger.GetTags(new NSRange(0, Text.Length), NLTokenUnit.Word, NLTagScheme.Lemma, NLTaggerOptions.OmitWhitespace | NLTaggerOptions.OmitPunctuation, out var ranges); Assert.That(tags.Length, Is.EqualTo(ranges.Length), "Length"); foreach (var tag in tags) { Assert.NotNull(tag, tag); } } }
void ShowTags(NLTagScheme tagScheme) { if (!String.IsNullOrWhiteSpace(UserInput.Text)) { var tagger = new NLTagger(new NLTagScheme[] { tagScheme }); var range = new NSRange(0, UserInput.Text.Length); tagger.String = UserInput.Text; tags = tagger.GetTags(range, NLTokenUnit.Word, tagScheme, NLTaggerOptions.OmitWhitespace, out NSValue[] ranges); tokenRanges = ranges; detailViewTitle = tagScheme == NLTagScheme.NameType ? "Named Entities" : "Parts of Speech"; PerformSegue(ShowEntitiesSegue, this); } }