简体   繁体   English

使用SharpNLP识别英语句子中的时态

[英]Recognize Tenses in English Sentence by using SharpNLP

In my assignment, here I use SharpNLP to define part of speech, like noun, adjective, verb and so on. 在我的作业中,这里我使用SharpNLP定义词性,例如名词,形容词,动词等。 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 = "I was busy yesterday." allInput =“我昨天很忙。”

Takes it simple, in listSentence[0] contains "I was busy yesterday". 简单来说, listSentence [0]中包含“昨天我很忙”。
Then split into "I", "was", "busy", "yesterday" in string[] lWord 然后在字符串中分成“ I”,“ was”,“ busy”,“昨天” [] lWord
Then I used SharpNLP, that's running well so that string[] lPOS contains {"NN", "VBD", "JJ", "NN"} 然后,我使用了SharpNLP,它运行良好,因此string [] lPOS包含{“ NN”,“ VBD”,“ JJ”,“ NN”}
That should be recognized as TRUE 那应该被认为是TRUE
Based on that output, I'm confused how to recognize as PAST TENSE - TRUE or FALSE. 基于该输出,我很困惑如何识别为过去时-TRUE或FALSE。

Explanation : 说明:

NN : Noun, singular or mass NN:名词,奇数或质量
VBD : Verb, past tense VBD:动词,过去时
VBP : Verb, non-3rd person singular present VBP:动词,非第三人称单数礼物
VBZ : Verb, 3rd person singular present VBZ:动词,第三人称单数礼物
VBG : Verb, gerund or present participle VBG:动词,动名词或现在分词
VBN : Verb, past participle VBN:动词,过去分词
JJ : Adjective JJ:形容词
PRP : Personal Pronoun PRP:人称代词

If allInput = "I am busy yesterday" 如果allInput =“我昨天很忙”
string[] lPOS = {"PRP", "VBP", "JJ", "NN"} string [] lPOS = {“ PRP”,“ VBP”,“ JJ”,“ NN”}
That should be recognized as FALSE 那应该被认作FALSE

If allInput = "They am busy yesterday" 如果allInput =“他们昨天很忙”
string[] lPOS = {"PRP", "VBP", "JJ", "NN"} string [] lPOS = {“ PRP”,“ VBP”,“ JJ”,“ NN”}
That should be recognized as FALSE 那应该被认作FALSE

If allInput = "I was busy tomorrow" 如果allInput =“我明天很忙”
string[] lPOS = {"PRP", "VBD", "JJ", "NN"} string [] lPOS = {“ PRP”,“ VBD”,“ JJ”,“ NN”}
That should be recognized as FALSE 那应该被认作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. 非常感谢。 :) :) :) :)

There is a basic contradiction in the goal. 目标中存在一个基本矛盾。 The parser operates at the syntactic(structure) level. 解析器在语法(结构)级别上运行。 But you want to classify based on semantics(meaning) as well. 但是您也想基于语义(含义)进行分类。
I was busy tomorrow is past tense according to the parser, because syntactically, there is a verb in past tense. 根据语法分析器, I was busy tomorrow ,因为过去时态是过去时态,因为从句法上来说,过去时态中有一个动词。 But, the semantics of the last word, makes it a semantically wrong sentence. 但是,最后一个单词的语义使它成为一个语义错误的句子。

In my opinion, for your goal, I am busy yesterday is Present tense and I was busy tomorrow is past tense. 我认为,为了您的目标, I am busy yesterday ,现在时,而I am busy yesterday I was busy tomorrow ,过去时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM