From d38dd0142bcef1f21e0bd7deeddd8cdada236481 Mon Sep 17 00:00:00 2001 From: zg2nets <40655877+zg2nets@users.noreply.github.com> Date: Thu, 20 Sep 2018 17:59:45 +0800 Subject: [PATCH] [NLP]Remove lemmatize api from Nlp project (#479) * Remove lemmatize api from Nlp project * Modify Nlp project return description --- src/Tizen.Nlp/Tizen.Nlp/LemmatizeResult.cs | 35 -------------------- src/Tizen.Nlp/Tizen.Nlp/NaturalLanguageProcess.cs | 40 ++--------------------- 2 files changed, 2 insertions(+), 73 deletions(-) delete mode 100644 src/Tizen.Nlp/Tizen.Nlp/LemmatizeResult.cs diff --git a/src/Tizen.Nlp/Tizen.Nlp/LemmatizeResult.cs b/src/Tizen.Nlp/Tizen.Nlp/LemmatizeResult.cs deleted file mode 100644 index c93f630..0000000 --- a/src/Tizen.Nlp/Tizen.Nlp/LemmatizeResult.cs +++ /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 -{ - /// - /// This class contains result of lemmatized. - /// - /// 5 - public class LemmatizeResult - { - /// - /// The whole sentence. - /// - /// 5 - public string ActualWord { get; set; } - } -} diff --git a/src/Tizen.Nlp/Tizen.Nlp/NaturalLanguageProcess.cs b/src/Tizen.Nlp/Tizen.Nlp/NaturalLanguageProcess.cs index bc5cbe6..3f7a70c 100644 --- a/src/Tizen.Nlp/Tizen.Nlp/NaturalLanguageProcess.cs +++ b/src/Tizen.Nlp/Tizen.Nlp/NaturalLanguageProcess.cs @@ -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 _mapsNamedEntity = new Dictionary(); - private readonly Dictionary _mapsLemmatize = new Dictionary(); - /// /// An construct method to init local env of NLP . /// @@ -76,8 +73,6 @@ namespace Tizen.Nlp private delegate bool NamedEntityRecognitionCallback(MessageReceivedEventArgs e); - private delegate bool LemmatizeCallback(MessageReceivedEventArgs e); - /// /// A connection status change event /// @@ -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. /// /// 5 + /// A task representing the asynchronous connect operation. /// Thrown when the connect is rejected. 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 } /// - /// Send Lemmatize request to remote tidl service with one parameters. - /// - /// A sentence need to be processed. - /// ProcessResult - /// 5 - public Task LemmatizeaAsync(string sentence) - { - int id = _requestIdLemmatize++; - MakeRequest("lemmatize", sentence, id); - var task = new TaskCompletionSource(); - _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; - } - - /// /// Send word tokenize request to remote tidl service with one parameters. /// /// A sentence need to be processed. -- 2.7.4