예제 #1
0
        /// <summary>
        /// Find out the each word type in a sentence.
        /// </summary>
        /// <param name="text"></param>
        private async void FindWordType(string text)
        {
            try
            {
                //set the loading indicator to true.
                //this.IsBusy = true;
                //initialize http client
                var    client     = new HttpClient();
                string SourceText = text;
                //parse the uri string
                string uri    = "https://api.textgain.com/1/tag?lang=en&q=" + SourceText;
                string result = await client.GetStringAsync(uri);

                //deserialize the json object returned from calling the api.
                var s = (Text)JsonConvert.DeserializeObject(result, typeof(Text));
                foreach (List <List <WordType> > section in s.data)
                {
                    foreach (List <WordType> sentence in section)
                    {
                        foreach (WordType wordType in sentence)
                        {
                            string word = wordType.word;
                            string tag  = wordType.tag;
                            //if the word is a noun, then save it to the easy table else not.
                            if (tag == "NOUN")
                            {
                                //serialize the data into a json object.
                                VocabModel vocabModel = new VocabModel()
                                {
                                    SourceText = word
                                };
                                //use POST method to send the json object to the easy table
                                await AzureManager.AzureManagerInstance.AddVocabModel(vocabModel);
                            }
                        }
                    }
                }
                //turn the loading indicator off.
                // this.IsBusy = false;
            }
            catch (Exception) { }
        }
예제 #2
0
 /// <summary>
 /// POST method
 /// </summary>
 /// <param name="vocabModel"></param>
 /// <returns></returns>
 public async Task AddVocabModel(VocabModel vocabModel)
 {
     await this.vocabTable.InsertAsync(vocabModel);
 }