Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Visual-Studio Algorithms , +
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. Smile | :) Smile | :)
Posted 3-Apr-13 4:32am
Edited 3-Apr-13 4:35am
Pheonyx at 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 at 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 at 3-Apr-13 10:08am
Sir @Pheonyx, good job Sir.... How about adverb of time? Isn't important?
Pheonyx at 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 at 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 at 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 at 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
0 OriginalGriff 690
1 Maciej Los 280
2 Suvendu Shekhar Giri 229
3 Richard Deeming 195
4 Sascha Lefévre 164
0 Sergey Alexandrovich Kryukov 9,678
1 OriginalGriff 9,135
2 Peter Leow 5,082
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,606

Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 3 Apr 2013
Copyright © CodeProject, 1999-2015
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