使用SharpNLP识别英语句子中的过去时态 [英] Recognize Past Tense in English Sentence by using SharpNLP

查看:285
本文介绍了使用SharpNLP识别英语句子中的过去时态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的作业中,我使用SharpNLP来定义词性,如名词,形容词,动词等。然后,我想根据时态的类型对句子进行分类,首先在这种情况下,以PAST TENSE为例。



让我看看我的代码..



In my assignment, here I use SharpNLP to define part of speech, like noun, adjective, verb and so on. Then, i wanna classify sentence based on kind of tenses, firstly in this case, PAST TENSE as example.

Let see my code..

listSentence = ParseInput(allInput);

foreach (string word in listSentence[0].Split(separator))
    if (word.Trim() != "")
        listWord.Add(word);

string[] lWord = listWord.ToArray();
string[] lPOS = this.NLP.PosTagTokens(lWord);





allInput =我昨天很忙。



简单一点,在listSentence [0]中包含我昨天很忙。

然后分成I,was,busy,昨天in string [] lWord

然后我使用了SharpNLP,它运行良好,所以string [] lPOS包含{NN,VBD,JJ,NN}

那应该被认为是真的

根据那个输出,我很困惑如何识别为PAST TENSE - TRUE或FALSE。



说明:



NN:名词,单数或质量

VBD :动词,过去时

VBP:动词,非第3人单数礼物

VBZ:动词,第3人单数礼物

VBG:动词,动词或现在分词

VBN:动词,过去分词

JJ:形容词

PRP:人称代词



如果allInput =我昨天很忙

string [] lPOS = {PRP,VBP,JJ,NN}

那应该被认为是假的



如果allInput =他们昨天很忙

string [] lPOS = { PRP,VBP,JJ,NN}

这应被视为FALSE



如果allInput =我明天很忙

string [] lPOS = {PRP,VBD,JJ,NN}

应该被认为是假的



先生,请帮助我。给我一些想法,并根据上面的所有输出来识别过去时。让我通过你的例子来学习。非常感谢。 :):)



allInput = "I was busy yesterday."

Takes it simple, in listSentence[0] contains "I was busy yesterday".
Then split into "I", "was", "busy", "yesterday" in string[] lWord
Then I used SharpNLP, that''s running well so that string[] lPOS contains {"NN", "VBD", "JJ", "NN"}
That should be recognized as TRUE
Based on that output, I''m confused how to recognize as PAST TENSE - TRUE or FALSE.

Explanation :

NN : Noun, singular or mass
VBD : Verb, past tense
VBP : Verb, non-3rd person singular present
VBZ : Verb, 3rd person singular present
VBG : Verb, gerund or present participle
VBN : Verb, past participle
JJ : Adjective
PRP : Personal Pronoun

If allInput = "I am busy yesterday"
string[] lPOS = {"PRP", "VBP", "JJ", "NN"}
That should be recognized as FALSE

If allInput = "They am busy yesterday"
string[] lPOS = {"PRP", "VBP", "JJ", "NN"}
That should be recognized as FALSE

If allInput = "I was busy tomorrow"
string[] lPOS = {"PRP", "VBD", "JJ", "NN"}
That should be recognized as FALSE

Sir, please help me. Give me idea, and rules to recognize past tense based on all output above. Let me learn by your example. Thanks a lot all. :) :)

推荐答案

const string VERB_PAST_TENSE = "VBD";
const string VERB_PAST_PARTICIPLE = "VBN";

if(Array.contains(IPOS, VERB_PAST_TENSE) || 
   Array.contains(IPOS, VERB_PAST_PARTICIPLE )  )
{
//Do Something with past tense
}
else
{
//Do Something with Present Tense
}


这篇关于使用SharpNLP识别英语句子中的过去时态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆