Natural Language Processing (NLP)

NLP is a subset of Natural Language Toolkit that specifies an interface and a protocol for basic natural language processing. Tizen enables you to use Natural Language Process (NLP) functionalities, such as language detection, parts of speech, word tokenization, and named entity detection. For more information, see the NLTK Forum.

Note

NLP API is deprecated since Tizen 8.0 and will be removed after two releases without any alternatives.

The main features of the Tizen.Nlp namespace include the following:

  • Word tokenize support

    You can get tokens from a sentence, the type of return is WordTokenizeResult. This method breaks up the sentence into words and punctuation.

  • Part-of-speech support

    You can get tokens and tags from a sentence, the type of return is PosTagResult. This method breaks up the sentence into words and punctuation with tag attributes.

  • Named entity recognizer support

    You can get tokens and tags from a sentence, the type of return is NamedEntityRecognitionResult. This method breaks up the sentence into words and punctuation with tag attributes.

  • Language detect support

    You can get language from a sentence, the type of return is LanguageDetectedResult. This method is used to detect the language of a sentence.

Prerequisites

To enable your application to use the NLP functionality, follow the steps below:

  1. To use the Tizen.Nlp namespace, the application has to request permission by adding the following privileges to the tizen-manifest.xml file:

    XML
    Copy
    <privileges> <privilege>http://tizen.org/privilege/appmanager.launch</privilege> <privilege>http://tizen.org/privilege/datasharing</privilege> </privileges>
  2. To use the methods and properties of the Tizen.Nlp namespace, include it in your application:

    C#
    Copy
    using Tizen.Nlp;

Receive WordTokenize tokens

To receive the tokens from sentence, follow the steps below:

  1. Construct NaturalLanguageProcess on OnCreate(), and connect the NLP service on init of app:

    C#
    Copy
    protected override void OnCreate { .. nlp = new NaturalLanguageProcess(); Task task = nlp.Connect(); .. }
  2. Call the WordTokenizeAsync(string msg) in a async task method:

    C#
    Copy
    public async Task OnTokenButtonPressedAsync(string msg) { .. var ret = nlp.WordTokenizeAsync(msg); WordTokenizeResult wr = await ret; .. }
  3. When NLP object is no longer needed, call Dispose() to release the resource of NLP:

    C#
    Copy
    protected override void OnTerminate() { .. nlp.Dispose(); .. }

Receive PosTag tokens and tags

To receive the tokens and tags from sentence, follow the steps below:

  1. Construct NaturalLanguageProcess on OnCreate(), and connect the NLP service on init of app:

    C#
    Copy
    protected override void OnCreate { .. nlp = new NaturalLanguageProcess(); Task task = nlp.Connect(); .. }
  2. Call the PosTagAsync(string msg) in a async task method:

    C#
    Copy
    public async Task OnPosButtonPressedAsync(string msg) { .. var ret = nlp.PosTagAsync(msg); PosTagResult pr = await ret; .. }
  3. When NLP object is no longer needed, call Dispose() to release the resource of NLP:

    C#
    Copy
    protected override void OnTerminate() { .. nlp.Dispose(); .. }

Receive named entity tokens and tags

To receive the tokens and tags information from sentence, follow the steps below:

  1. Construct NaturalLanguageProcess on OnCreate(), and connect the NLP service on init of app:

    C#
    Copy
    protected override void OnCreate { .. nlp = new NaturalLanguageProcess(); Task task = nlp.Connect(); .. }
  2. Call the NamedEntityRecognitionAsync(string msg) in a async task method:

    C#
    Copy
    public async Task OnTokenButtonPressedAsync(string msg) { .. var ret = nlp.NamedEntityRecognitionAsync(msg); NamedEntityRecognitionResult nr = await ret; .. }
  3. When NLP object is no longer needed, call Dispose() to release the resource of NLP:

    C#
    Copy
    protected override void OnTerminate() { .. nlp.Dispose(); .. }

Detect language

To detect the language from sentence, follow the steps below:

  1. Construct NaturalLanguageProcess on OnCreate(), and connect the NLP service on init of app:

    C#
    Copy
    protected override void OnCreate { .. nlp = new NaturalLanguageProcess(); Task task = nlp.Connect(); .. }
  2. Call the LanguageDetectAsync(string msg) in a async task method:

    C#
    Copy
    public async Task OnLangButtonPressedAsync(string msg) { .. var ret = nlp.LanguageDetectAsync(msg); LanguageDetectedResult lr = await ret; .. }
  3. When NLP object is no longer needed, call Dispose() to release the resource of NLP:

    C#
    Copy
    protected override void OnTerminate() { .. a.Dispose(); .. }
  • Dependencies
    • Tizen 5.0 and Higher
Natural Language Processing
Next Notifications and Content Sharing
Submit your feedback to GitHub