Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i have a small problem implementing text spinning in vb.net. Text spinning is an art of changing text by replacing some words by their synonyms.

like : codeproject is an excellent website.

spin syntax : codeproject is a {excellent|good|cool} website

so everytime we spin, we get sentences like :

codeproject is a good website
codeproject is a cool website etc.

i have a list of synonyms from a dictionary (text file). how do i implement the above syntax in vb.net and how do i spin

suppose the user selects the word in a rich textbox and clicks a button, then the word should change to

{original|synonym1|synonym2|synonym3}

next when the user clicks spin button, the changed text should appear in another text box, but how do i select the word from above options??

i do not want the whole code, only some ideas??
Posted

Hi, the dictionary you say, is kind of a xml file? it should be, isn't?

and use a rich textbox isn't the best way. Why don't you limit the words that user can select in a Select tag (or asp.net DropDownList)

if you do like this, you can generate certain code in the page, that makes the suggests (or spinning) in different labels with dropdownlist SelectedIndexChanged. And add a <a> tag or an that select the text and pass it through javascript to the textBox.

Understand me? ;)
 
Share this answer
 
Comments
amit_upadhyay 28-Jul-10 11:47am    
its a windows application not a web application, that is why i need to do it in a richtextbox
PunkIsNotDead 28-Jul-10 11:56am    
Then use a key_Up event of RichTextBox and evaluate every word. Then dynamically generate rows in a selectable grid view
What exactly are you stuck on? Really, that wouldn't be that difficult to do.

Personally, I would do it through a ContextMenuStrip, but you can do it the way you want.

It's easy enough to get and change the selected text within a RTB. All you do is read and change the SelectedText property.

Then, you could set up a series of CharacterRanges that are associated with each of the new synonyms. Then, when the user mouses over any of the CharacterRanges, change the mouse to the Hand. Then, if the user clicks while over one of the CharacterRanges, you change the previous word to the new one.

Of course, there are some things to think about. Like what if the user starts typing and now the CharacterRanges are off. Well, you'd have to know if you had added any and then hook the TextChanged event and find the new ranges and update them. But, there are definitely many ways you could to it to find them. Personally, I would have a class to store all of that information and it could create the string with the {original|synonym1|synonym2|synonym3} set up and then you could use it to search for your string. The class could also store the CharacterRanges for checking mouse position or just tell you if you're over a CharacterRange and which one you're over.

I would also look into using NHunspell. It's a stand-alone spell checker, but it includes a thesaurus. It's extremely fast at generating synonyms and does all of the work for you.
 
Share this answer
 
v2
Comments
amit_upadhyay 28-Jul-10 12:17pm    
i got the selectedtext change part. but how do i change the text when spinning? after the user has selected evrything he wants to change, he will click on spin, then the whole article will come into new richtextbox, but only one word should come from the spin syntax. how do i do this? i think i will need to check for braces in the whole article, and then if it contains "|" then maybe replace text?
William Winner 28-Jul-10 12:27pm    
Did you actually read what I wrote? Also, you said, "i do not want the whole code, only some ideas??" so I won't provide that.

I would create a class that stores all of that information. Its constructor could be just the original word and then it could fill out a list with the synonyms. You could then have a property that would provide you with the {original|synonym1|...} syntax. Then, you replace the selected text with that syntax.

Then when you spin the word, you look for that syntax and replace it with the word that they selected. You need to look for the whole text, because what if someone on their own wrote "The list is: {23|24|25}" and you just searched for a brace with pipes in it? You wouldn't replace the write text.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900