0

I am working on sharp nlp where i am extracting all the adjective now i need to store this in database and i have successfully added this to database but the problem is with me that i want to store adjective separately to database how can i store the adjective separately or for example we have string and we want to store each word separately into database and we have only one column how can we do this? .please help me out here is my code.

private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string cleaned = richTextBox1.Text.Trim();
                string st = "INSERT INTO TABLE1(adjective)VALUES('" + cleaned + "')";
                SqlConnection con = new SqlConnection("Data Source=ZAZIKHAN\\SQLEXPRESS;Initial Catalog=mis;Integrated Security=True");
                con.Open();
                SqlCommand cmd = new SqlCommand(st, con);


                if (cmd.ExecuteNonQuery() == 1)
                {

                    MessageBox.Show(" succesfully added");
                }
                else
                {
                    MessageBox.Show("Sorry we couldnt add the Values Please try Again");

                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex);
            }
        }

now i have this data to be stored which is in richtextbox.

local/JJ  daily/JJ  n/price/rate/JJ  human/JJ  possible/JJ  correct/JJ  exact/JJ  local/JJ  

local/JJ  daily/JJ  n/price/rate/JJ  human/JJ  possible/JJ  correct/JJ  exact/JJ  local/JJ  

dry/JJ  nd/JJ  

new/JJ  full/JJ  OK/JJ  final/JJ  white/JJ  OK/JJ  howajaa/JJ  smajder/JJR  agaa/JJ  nasambd/JJ  Live/JJ  



final/JJ  



great/JJ  s3/JJ  final/JJ  

resistant/JJ  Z1/JJ  white/JJ  new/JJ  black/JJ  amaa.Kintact/JJ  possible/JJ  main/JJ  mobile/JJ  rapak/JJ  mil/JJ  

important/JJ  mil/JJ  smart/JJ  



35-h/JJ  OK/JJ  full/JJ  











Want/JJ  complete/JJ  white/JJ  same/JJ  

available/JJ  perfect/JJ  

interested/JJ  

3 Answers 3

1

First off, the lines

string cleaned = richTextBox1.Text.Trim();
string st = "INSERT INTO TABLE1(adjective)VALUES('" + cleaned + "')";

create a massive security hole known as SQL Injection.

In order to store the adjectives separately in a properly denormalized database, you would have a parent table where e.g. the original sentence is stored, and a child table with a 1:N relationship to the parent where you store one row per adjective plus the appropriate ID of the parent row.

Since you only have one column available, you can use any convenient format to store the array of adjectives in a single column. You could serialize that array (to Binary, XML, JSON, etc) and store it, or since you know you have a limited input character set, you could even store it as a comma separated list.

Sign up to request clarification or add additional context in comments.

3 Comments

can you give me a example bro or a helpful link which relates to my problem
@Vicky: You can just store exactly what is in the Rich Text Box into the column in your table, but my read of your question is that you will process that data first somehow. Can you explain exactly what you want stored? If the columns of your table are pre-defined, please also share what the table columns look like.
i have edited my question and show whats in the rich textbox bro and i want to store these adjective in separate rows
0

You can prefix your words with some characters to indicate whether they are verb , noun , adjective and tehn insert those value in database

eg N_JonSkeet - Noun

V_Solve - Verb

A_Highest - Adjective

string cleaned = extractAdjective(richTextBox1.Text.Trim());
string st = "INSERT INTO TABLE1(word) VALUES(@Word)";
SqlConnection con = new SqlConnection("Data Source=ZAZIKHAN\\SQLEXPRESS;Initial Catalog=mis;Integrated Security=True");
con.Open();
SqlCommand cmd = new SqlCommand(st, con);
SqlParameter param = new SqlParameter("@Word", SqlDbType.NChar);
param.Value = "A_"+cleaned;
cmd.Parameters.Add(param);

4 Comments

bro i have successfully extracted the adjective from strings but the problem here is to store these adjective separately
Correct me if i am wrong what I have understood.... you have table with one column and you want to insert word in that column .. word can be verb , noun adjective etc...
no bro the word is only adjective which i have in a huge string and now i want these objecteve to store in database but seprately
ok i am editing my question please check it what i want to store.
0

I would separate the string into a list and then iterate over the list and insert into your DB:

var vals = "local/JJ  daily/JJ  n/price/rate/JJ  human/JJ  possible/JJ...";
var results = vals.Replace(" ", "")
                  .Replace("/JJ", "|")
                  .Replace("/", "|")
                  .Split('|')
                  .Distinct();

while(var result in results)
{
   // DO insert here
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.