Current location: Hot Scripts Forums » Programming Languages » Windows .NET Programming » search function using dot net

search function using dot net

Reply
  #1  
Old 08-04-08, 03:25 PM
nishudude_13 nishudude_13 is offline
New Member
 
Join Date: Aug 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question search function using dot net

i m working on project on online telecom using c#.i hv to create a function searchComplaint() dat takes mysql connection and customer complaints to search in the database that any related solution is present already in the database of this complaints. This can be done by splitting the complaints into words and removing all the special characters and remove the commonly used words like "is, was, the, there, like, than, that, while, an , of, do, be, for, from etc." and based on the final string each words we have to search in the database if any one word match we have to return the solution for that complaint.

example: while system is running its hanging after removing the commonly used words, the keywords are system, running and hanging


sumone plz help me wid the coding...
Reply With Quote
  #2  
Old 08-28-08, 12:28 PM
ben77 ben77 is offline
New Member
 
Join Date: Aug 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Word Wrap function for c# (.net)
Most of the technical posts I make on this blog, are issues that I struggle with for a day or two, and was unable to find a good solution for on the internet. Once I find the solution, I try to post it here, to try and make things easier on everyone else out there. I made a similar post to usenet microsoft.public.dotnet.faqs group last April, about doing word wrap in .net. This weekend, someone sent some feedback from my blog asking if that post was mine, and thanking me for the information. I really appreciated the comment, since it is hard to tell if people out there need and use the information I post.

In any case, I decided to repost the word wrap function to my blog, in hopes that more people can get some use out of it.


Code:
public static string[] Wrap(string text, int maxLength) 
 
{ 
 
text = text.Replace("\n", " "); 
 
text = text.Replace("\r", " "); 
 
text = text.Replace(".", ". "); 
 
text = text.Replace(">", "> "); 
 
text = text.Replace("\t", " "); 
 
text = text.Replace(",", ", "); 
 
text = text.Replace(";", "; "); 
 
text = text.Replace("
", " "); 
 
text = text.Replace(" ", " "); 
 
 
 
string[] Words = text.Split(' '); 
 
int currentLineLength = 0; 
 
ArrayList Lines = new ArrayList(text.Length / maxLength); 
 
string currentLine = ""; 
 
bool InTag = false; 
 
 
 
foreach (string currentWord in Words) 
 
{ 
 
//ignore html 
 
if (currentWord.Length > 0) 
 
{ 
 
 
 
if (currentWord.Substring(0,1) == "<") 
 
InTag = true; 
 
 
 
if (InTag) 
 
{ 
 
//handle filenames inside html tags 
 
if (currentLine.EndsWith(".")) 
 
{ 
 
currentLine += currentWord; 
 
 
 
} 
 
 
 
else 
 
currentLine += " " + currentWord; 
 
if (currentWord.IndexOf(">") > -1) 
 
InTag = false; 
 
 
 
} 
 
 
 
else 
 
{ 
 
if (currentLineLength + currentWord.Length + 1 < maxLength) 
 
{ 
 
currentLine += " " + currentWord; 
 
currentLineLength += (currentWord.Length + 1); 
 
} 
 
 
 
else 
 
{ 
 
Lines.Add(currentLine); 
 
currentLine = currentWord; 
 
currentLineLength = currentWord.Length; 
 
 
 
} 
 
} 
 
} 
 
} 
 
 
 
if (currentLine != "") 
 
Lines.Add(currentLine); 
 
string[] textLinesStr = new string[Lines.Count]; 
 
Lines.CopyTo(textLinesStr, 0); 
 
return textLinesStr; 
 
}


.Net - String vs StringBuilder
Appending text a string object is done in this fashion:

stringObject += "more text";Concating strings like that is very fast and reliable when it comes to small C# strings. In fact it can be significantly simpler and faster than using the StringBuilder class.

The StringBuilder class on the other hand is excellent for processing large pieces of text. To add a string to a StringBuilder goes like this:

stringBuilderObject.Append("more text");The downside to the StringBuilder is at the end it needs to be converted back into a regular string. However if we are going to need to create some C# functions that will processes big amounts of text, then StringBuilder is the way to go. For more on the speed performace of string vs string builder visit the application optimization article.

In the C# String Processing Library functions are divided into two sections, the StringProcessing and the StringBuilderProcess classes, so you can run whichever one is more fitting.

Advanced Csharp String Functions
public static string Capitalize(string input)This C# function takes the first letter of a string an capitalizes it:
word -> Word
this is a sentence -> This is a sentence

public static bool IsCapitalized(string input)This C# function checks to see if the first letter of a string is capitalized:
Word -> True
word -> False

public static bool IsLowerCase(string input)Checks to see that an entire string is in lower cases
word -> True
Word -> False

public static bool IsUpperCase(string input)Checks to see that an entire string is in upper cases
Word -> False
WORD -> True

public static string SwapCases(string input)This C# function swaps the cases of a string
word -> WORD
Word -> wORD

public static string AlternateCases(string input)Takes the first character's casing an alternates the casing of the rest of the string
Hi -> Hi
helloworld -> hElLoWoRlD

public static string AlternateCases(string input, bool firstIsUpper) This C# string function works exactly the same except the user specifies on which case the string will start (Upper case or Lower case)

public static bool IsAlternateCases(string input)Checks to see whether a string has alternating cases

public static int CountTotal(string input, string chars, bool ignoreCases)Counts the total number of occurances of a string within another string
hello, l -> 2
hello, el -> 1

public static string RemoveVowels(string input)This C# string function removes the vowels in a string
hello -> hll

public static string KeepVowels(string input)This C# string function removes everything but the vowels in a string
hello -> eo

public static bool HasVowels(string input)Checks to see if there is any vowel present in a string

public static bool IsSpaces(string input)Quickly and effortlessly checks to see if a string is nothing but spaces

public static bool IsRepeatedChar(string input)Quickly and effortlessly checks to see if a string is nothing but the same letter repeated
aaaaaaaaaa -> True
aaaaaaaaad -> False

public static bool IsNumeric(string input)Processes a string to see if it contains only numbers

public static bool HasNumbers(string input)

Checks a string to see if it contains any numbers.

public static bool IsAlphaNumberic(string input)This C# function evaluates whether a string contains only numbers and letters (no symbols).

public static bool isLetters(string input)

Checks for a string to contain nothing but letters, no numbers or symbols.

public static string GetInitials(string input, bool capitalize, bool includeSpace)Converts a string, like a name, into its initials
Bob Landon -> B.L.

public static string GetTitle(string input)Capitalizes the first letter of every word in a string
the good story -> The Good Story


public static string GetNameCasing(string input)


(got it from google... =) )

Last edited by digioz; 08-28-08 at 12:36 PM. Reason: Please use Code Tags!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP upload prob minority ASP 1 06-27-05 09:35 AM
PHP Error Fairnie PHP 8 06-26-04 08:15 AM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM
Help trim code down TheLaughingBandit JavaScript 0 09-02-03 10:50 AM


All times are GMT -5. The time now is 07:23 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 (Unregistered)