Click here to Skip to main content
13,052,669 members (64,952 online)
Rate this:
Please Sign up or sign in to vote.
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() != "")
        string[] lWord = listWord.ToArray();
        string[] lPOS = this.NLP.PosTagTokens(lWord);

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. :) :)
Posted 3-Apr-13 3:32am
Updated 3-Apr-13 3:35am
Pheonyx 3-Apr-13 9:41am
Why don't you check the IPOS array to see if it contains VBD or VBN ? From what you have written I understand they indicate past tense?
Berry Harahap 3-Apr-13 9:56am
Sir @Pheonyx, I thought about it too, VBD or VBN.. But i consider Adverb of TIME... May i see your suggestion in pseudocode Sir, as comparison.. :) :) CHeers...

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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
//Do Something with Present Tense
Berry Harahap 3-Apr-13 10:08am
Sir @Pheonyx, good job Sir.... How about adverb of time? Isn't important?
Pheonyx 3-Apr-13 10:11am
That is your decision, I can only work based on the information you provided, and I do not know how the SharpNLP will display the adverb of time. You will have to do some testing to identify what work is required regarding this.

Theoretically Time can be Future/Past/Present so you might need to do additional checks regarding that.
Berry Harahap 3-Apr-13 10:33am
Okay Sir @Pheonyx, SharpNLP display ex : tomorrow, yesterday, last night,.. as NN (Noun). Maybe I should make a list of adverb of time and then compare it with the Verb.. But i'm still waiting new idea or make that idea elegantly.. :) :) :) Thanks a lot Sir @Pheonyx Cheers>>

But if you are welcome to let me see you code that you mean "additional checks regarding that".. It will be helpful Sir. :) :)
Pheonyx 3-Apr-13 11:08am
If you were to look in the string for given words, such as "Yesterday" "tomorrow" etc, which ever words you define as being past tense words, then this might be a viable solution.

However, you get into the realms of "Bad English" at this point. What I mean is that if the string you are processing is written poorly then it could fail all of your tests.

"They am busy yesterday " is a very poor sentence, it should read "They were busy yesterday" and is a past tense sentence. Where as in it's current form it would be considered a "mixed" tense sentence.

Hopefully that makes sense?
Berry Harahap 3-Apr-13 11:23am
That makes sense Sir @Pheonyx, it means that I should consider subject (in this case Noun), verb and adverb to define tenses of sentence. Hmm, 3 variables, let's brainstorming it. It' will be harder. :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 3 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100