[NLP]Remove lemmatize api from Nlp project (#479)
authorzg2nets <40655877+zg2nets@users.noreply.github.com>
Thu, 20 Sep 2018 09:59:45 +0000 (17:59 +0800)
committerGitHub <noreply@github.com>
Thu, 20 Sep 2018 09:59:45 +0000 (17:59 +0800)
* Remove lemmatize api from Nlp project

* Modify Nlp project return description

src/Tizen.Nlp/Tizen.Nlp/LemmatizeResult.cs [deleted file]
src/Tizen.Nlp/Tizen.Nlp/NaturalLanguageProcess.cs

diff --git a/src/Tizen.Nlp/Tizen.Nlp/LemmatizeResult.cs b/src/Tizen.Nlp/Tizen.Nlp/LemmatizeResult.cs
deleted file mode 100644 (file)
index c93f630..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Tizen.Nlp
-{
-    /// <summary>
-    /// This class contains result of lemmatized.
-    /// </summary>
-    /// <since_tizen> 5 </since_tizen>
-    public class LemmatizeResult
-    {
-        /// <summary>
-        /// The whole sentence.
-        /// </summary>
-        /// <since_tizen> 5 </since_tizen>
-        public string ActualWord { get; set; }
-    }
-}
index bc5cbe6..3f7a70c 100644 (file)
@@ -42,7 +42,6 @@ namespace Tizen.Nlp
         private int _requestIdLang = 0;
         private int _requestIdNeChunk = 0;
         private int _requestIdWordTokenize = 0;
-        private int _requestIdLemmatize = 0;
         private Task _connectionTask;
         private ConnectedState _connectionState = ConnectedState.Disconnected;
 
@@ -57,8 +56,6 @@ namespace Tizen.Nlp
         private readonly Dictionary<int, NamedEntityRecognitionCallback> _mapsNamedEntity =
             new Dictionary<int, NamedEntityRecognitionCallback>();
 
-        private readonly Dictionary<int, LemmatizeCallback> _mapsLemmatize = new Dictionary<int, LemmatizeCallback>();
-
         /// <summary>
         /// An construct method  to init local env of NLP .
         /// </summary>
@@ -76,8 +73,6 @@ namespace Tizen.Nlp
 
         private delegate bool NamedEntityRecognitionCallback(MessageReceivedEventArgs e);
 
-        private delegate bool LemmatizeCallback(MessageReceivedEventArgs e);
-
         /// <summary>
         /// A connection status change event
         /// </summary>
@@ -150,15 +145,6 @@ namespace Tizen.Nlp
                     _mapsNamedEntity.Remove(requestid);
                 }
             }
-            else if (msg.GetItem("command").Equals("lemmatize"))
-            {
-                e.Message = result;
-                if (_mapsLemmatize.ContainsKey(requestid))
-                {
-                    _mapsLemmatize[requestid]?.Invoke(e);
-                    _mapsLemmatize.Remove(requestid);
-                }
-            }
             else if (msg.GetItem("command").Equals("langdetect"))
             {
                 e.Message = result;
@@ -174,6 +160,7 @@ namespace Tizen.Nlp
         /// An async method  to connect remote service.
         /// </summary>
         /// <since_tizen> 5 </since_tizen>
+        /// <returns>A task representing the asynchronous connect operation.</returns>
         /// <exception cref="InvalidOperationException">Thrown when the connect is rejected.</exception>
         public Task Connect()
         {
@@ -198,8 +185,8 @@ namespace Tizen.Nlp
             {
                 Log.Debug(LogTag, "start to register");
                 _msg.CoRegister(Application.Current.ApplicationInfo.ApplicationId, _noti);
-                tcs.SetResult(true);
                 _connectionState = ConnectedState.Connected;
+                tcs.SetResult(true);
             };
             _msg.Rejected += (sender, e) =>
             {
@@ -231,7 +218,6 @@ namespace Tizen.Nlp
             _mapsWordTokenize.Clear();
             _mapsPosTag.Clear();
             _mapsNamedEntity.Clear();
-            _mapsLemmatize.Clear();
             _mapsLangDetect.Clear();
         }
 
@@ -331,28 +317,6 @@ namespace Tizen.Nlp
         }
 
         /// <summary>
-        /// Send Lemmatize request to remote tidl service with one parameters.
-        /// </summary>
-        /// <param name="sentence">A sentence need to be processed.</param>
-        /// <returns>ProcessResult</returns>
-        /// <since_tizen> 5 </since_tizen>
-        public Task<LemmatizeResult> LemmatizeaAsync(string sentence)
-        {
-            int id = _requestIdLemmatize++;
-            MakeRequest("lemmatize", sentence, id);
-            var task = new TaskCompletionSource<LemmatizeResult>();
-            _mapsLemmatize[id] = (e) =>
-            {
-                LemmatizeResult mr = new LemmatizeResult();
-                e.Message.TryGetValue("token", out string[] tokens);
-                if (tokens != null) mr.ActualWord = tokens[0];
-                task.SetResult(mr);
-                return true;
-            };
-            return task.Task;
-        }
-
-        /// <summary>
         /// Send word tokenize request to remote tidl service with one parameters.
         /// </summary>
         /// <param name="sentence">A sentence need to be processed.</param>