Here is what i did so far. The problem is if a conjunction appears twice in the sentence the code doesnt work for the 2nd appearance of the conjunction. plz if any expert can help ?
private void SplitSentence_Click(object sender, EventArgs e)
{
richTextBox2.Text = "";
richTextBox3.Text = "";
string[] keywords = { " or ", " and ", " hence", "so that", "however", " because" };
string[] sentences = SentenceTokenizer(richTextBox1.Text);
string remSentence;
foreach (string sentence in sentences)
{
remSentence = sentence;
richTextBox3.Text = remSentence;
for (int i =0; i < keywords.Length; i++)
{
if ((remSentence.Contains(keywords[i])))// || (remSentence.IndexOf(keywords[i]) > 0))
{
richTextBox2.Text += remSentence.Substring(0, remSentence.IndexOf(keywords[i])) + '\n' + keywords[i] + '\n';
remSentence = remSentence.Substring(remSentence.IndexOf(keywords[i]) + keywords[i].Length);
}
}
richTextBox2.Text += remSentence;
}
}
public static string[] SentenceTokenizer(string text)
{
char[] sentdelimiters = new char[] { '.', '?', '۔', '؟', '\r', ':', '-' }; // '{ ',' }', '( ', ' )', ' [', ']', '>', '<','-', '_', '= ', '+','|', '\\', ':', ';', ' ', '\'', ',', '.', '/', '?', '~', '!','@', '#', '$', '%', '^', '&', '*', ' ', '\r', '\n', '\t'};
// text.Remove('\n');
return text.Split(sentdelimiters, StringSplitOptions.RemoveEmptyEntries);
}