Click here to Skip to main content
15,898,588 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
Is it possible to extract the nouns and verbs from a text? If possible, how can I do it using C#? I need to extract them separately. please help.

thanks
Posted
Updated 22-Jun-22 23:39pm

What you are looking for is not at all easy to do - however, you could take a look at this[^] - it could be helpful to you.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-May-11 12:51pm    
Abhinav, your reference cannot be helpful. This article solves a problem which is practically unrelated. Besides, the problem in question is practically hopeless and even theoretically not computable.

You will see it if you consider my answer.
--SA
Abhinav S 23-May-11 13:06pm    
I could not understand. How is this not related?
If the OP can parse English text, can he not then figure out verbs etc?
Not that it is at all easy to do or in fact practically possible, but at least in theory, it could be possble.
Sergey Alexandrovich Kryukov 23-May-11 13:08pm    
Yes, related, but statistical task is simpler.
--SA
Maciej Los 19-Nov-13 17:10pm    
Sergey, you're right and Abhinav is right ;) It depends on language specifics...

+5, Abhinav!
Kim Togo 23-May-11 12:58pm    
It look complicated :-) - My 5 for that.
Strictly speaking it's not possible without detailed syntactic analysis of the text, which has the same level of complexity as automatic translation. Oh, what am I even talking about?! There are cases when it is theoretically impossible to tell — the same text can allow more than one interpretation.

In English, it is especially easy to construct examples like that. What language do you want to use?

In some languages, such task cannot not be even formulated as they don't have nouns and verbs.

—SA
 
Share this answer
 
v3
Comments
thatraja 23-May-11 14:28pm    
Sensible answer.
Matt T Heffron 19-Nov-13 14:08pm    
+5"Time flies like an arrow, fruit flies like a banana."
Sergey Alexandrovich Kryukov 23-May-11 14:30pm    
Hope so, than you very much.
--SA
Sergey Alexandrovich Kryukov 19-Nov-13 15:24pm    
Great example, thank you very much, Matt.
This can be uses as the source: http://en.wikipedia.org/wiki/Time_flies_like_an_arrow, as an example of a garden path sentence and syntactic ambiguity.
—SA
Wonde Tadesse 23-May-11 23:30pm    
5+
Well the i have google alot for extracting them separately and finally i got an idea .
If you are using sharp NLP Than Apply pos tagging and Apply if condition to retrieve specific tags like noun and verbs.And i am getting only NNP tags.
Here is a little effort.
C#
richTextBox1.Show();
            StringBuilder output = new StringBuilder();

            string[] sentences = SplitSentences(rt2.Text);


            foreach (string sentence in sentences)
            {
                string[] tokens = TokenizeSentence(sentence);
                string[] tags = PosTagTokens(tokens);

                for (int currentTag = 0; currentTag < tags.Length; currentTag++)
                {
                  //  output.Append(tokens[currentTag]).Append("/").Append(tags[currentTag]).Append("  ");
                    
                    if (tags[currentTag] == "NNP")
                    {
                        output.Append(tokens[currentTag]).Append("/").Append(tags[currentTag]).Append("  ");
                    }
                }
                
                output.Append("\r\n\r\n");
            }

            richTextBox1.Text = output.ToString();
        }
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900