Below is a function that uses TessNet2 (OCR framework) to scan through a list of words captured by the OCR function built into TessNet2. Since the pages that I'm scanning in our less than perfect quality the detection of the words are not 100% accurate.
So sometimes it will confuse an 'S' with a '5' or an 'l' with a '1'. Also, it doesn't take into account capitalization. So I have to search for both cases.
The way it works is that I am searching for certain words that are close to each other on the paper. So the first set of words [I] is " Abstracting Service Ordered". If the page contains those words next to each other then it moves to the next set of words [j], and then the next [h]. If the page contains all 3 sets of words then it returns true.
This is the best method I've thought of but I'm hoping someone here can give me another way to try.
public Boolean isPageABSTRACTING(List<tessnet2.Word> wordList)
{
for (int i = 0; i < wordList.Count; i++) //scan through words
{
if ((wordList[i].Text == "Abstracting" || wordList[i].Text == "abstracting" || wordList[i].Text == "abstractmg" || wordList[i].Text == "Abstractmg" && wordList[i].Confidence >= 50) && (wordList[i + 1].Text == "Service" || wordList[i + 1].Text == "service" || wordList[i + 1].Text == "5ervice" && wordList[i + 1].Confidence >= 50) && (wordList[i + 2].Text == "Ordered" || wordList[i + 2].Text == "ordered" && wordList[i + 2].Confidence >= 50)) //find 1st tier check
{
for (int j = 0; j < wordList.Count; j++) //scan through words again
{
if ((wordList[j].Text == "Due" || wordList[j].Text == "Oue" && wordList[j].Confidence >= 50) && (wordList[j + 1].Text == "Date" || wordList[j + 1].Text == "Oate" && wordList[j + 1].Confidence >= 50) && (wordList[j + 2].Text == "&" && wordList[j + 2].Confidence >= 50)) //find 2nd tier check
{
for (int h = 0; h < wordList.Count; h++) //scan through words again
{
if ((wordList[h].Text == "Additional" || wordList[h].Text == "additional" && wordList[h].Confidence >= 50) && (wordList[h + 1].Text == "comments" || wordList[h + 1].Text == "Comments" && wordList[h + 1].Confidence >= 50) && (wordList[h + 2].Text == "about" || wordList[h + 2].Text == "About" && wordList[h + 2].Confidence >= 50) && (wordList[h + 3].Text == "this" || wordList[h + 3].Text == "This" && wordList[h + 3].Confidence >= 50)) //find 3rd tier check
{
return true;
}
}
}
}
}
}
return false;
}