Skip to content

Instantly share code, notes, and snippets.

@ayushoriginal
Last active June 24, 2019 11:56
Show Gist options
  • Save ayushoriginal/94f1357b3c456d7d3381229e0a2b6c0e to your computer and use it in GitHub Desktop.
Save ayushoriginal/94f1357b3c456d7d3381229e0a2b6c0e to your computer and use it in GitHub Desktop.
token_lowercase_cs
using NaturalLanguage;
private readonly hate_coreml hate_model = new hate_coreml(); // Initialize CoreML Model
NSValue[] tokens;
var tokenizer = new NLTokenizer(unit);
tokenizer.String = UserInput.Text;
var range = new NSRange(0, UserInput.Text.Length);
var k = tokenizer.GetTokens(range); // returns Foundation.NSValue[]
tokens = k;
tokens_str = new string[tokens.Length];
for (int i = 0; i < tokens.Length; i++)
{
NSRange rr = tokens[i].RangeValue; // Extract Range Value
string s = input_text.Substring((int)rr.Location, (int)rr.Length);
tokens_str[i] = s.ToLower();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment