Note that there are some explanatory texts on larger screens.

plurals
  1. POPunctuation Problems
    primarykey
    data
    text
    <p>This is a program that reads in a CSV file, adds the values to a dictionary class and then analyses a string in a textbox to see if any of the words match the dictionary entry. It will replace abbreviations (LOL, ROFL etc) into their real words. It matches strings by splitting the inputted text into individual words.</p> <pre><code>public void btnanalyze_Click(object sender, EventArgs e) { var abbrev = new Dictionary&lt;string, string&gt;(); using (StreamReader reader = new StreamReader("C:/Users/Jordan Moffat/Desktop/coursework/textwords0.csv")) { string line; string[] row; while ((line = reader.ReadLine()) != null) { row = line.Split(','); abbrev.Add(row[0], row[1]); Console.WriteLine(abbrev); } } string twitterinput; twitterinput = ""; // string output; twitterinput = txtInput.Text; char[] delimiterChars = { ' ', ',', '.', ':', '\t' }; string text = twitterinput; string[] words = twitterinput.Split(delimiterChars); string merge; foreach (string s in words) { if (abbrev.ContainsKey(s)) { string value = abbrev[s]; merge = string.Join(" ", value); } if (!abbrev.ContainsKey(s)) { string not = s; merge = string.Join(" ", not); } MessageBox.Show(merge); } } </code></pre> <p>The problem is that the program won't translate the word if there's punctuation. I realised the character set I was using meant that punctuation wasn't a problem, but also didn't allow me to retain it when printing out. Is there a way that I can ignore the last character, as opposed to removing it, and still retain it for the output? I was trying to write it into a new variable, but I can't find a way to do that either...</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload