Click here to Skip to main content
15,920,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,

Does any one has knowledge about Markov Chain in programing in C#. I need to solve an problem, but I have no Idea how to start.

e.x I have text with 100 words. Ok I call it in a rich box or text box. The problem is:

When I write in other text box just one single word, the algorithm should give the other single word that is next.

example I open text '' The weather is very good today.....''

so, when i write word very in text box, the algorithm should reply the word good.


I hope, I was clear.

Thnx a lot.
Posted
Comments
Andreas Gieriet 12-Oct-13 3:02am    
This problem has nothing to do with Markov-Chain, or am I missing something?
Cheers
Andi
h7h7h7 12-Oct-13 3:09am    
Hi Andi, Ok how you so can make this solution, any Idea.
Andreas Gieriet 12-Oct-13 3:13am    
You must have some rules defined with associated probabilities to happen, based on the current state you are in. Do you have rules and what are the states?
Cheers
Andi
PS: Press the reply button on the right of my name to reply.
h7h7h7 12-Oct-13 3:22am    
Andi, I dont have rules. I open e text file in a rich box(now I can see a text). Near to rich box, I put a text boxt to write a word that is in a text, then I put button and all I want is when I click it if a word was ''very'', then application should reply me what is next word..

I write a code to find double word e.x Hi Andi, are you, why not....etc...but I am blocked in a problem above, from one given word, to find wich next...if you want i can write my code for finding double word, maybe it could give you an Idea.
Andreas Gieriet 12-Oct-13 3:52am    
I think you must first rephrase your problem for yoursef to get a clear idea what you are after. The task at hand seems to have multiple levels
- you talk about Markov Chains but you seem not to have an idea why this term appears here
- you talk about Rich Text Box and to get text to propose the next word but don't tell if this is the problem (register on key strokes to parse the entered text for getting the current last word?)
- is it the problem to search for the next word once you have the last word of the entered text?

It seems that this is a homework exercise for some intellisense text box with Markov-Chain probabilities of next words (Markov-Chain: it only bases on the last word and not on the whole sentence).
Did you understand the task at all? Can you rephrase the task in your words? Without that it's useless to talk about implementing "something".
And if you have understood the task, post a concrete problem where you struggle. E.g. how to register a keystroke handler on a text box, a concrete problem on parsing the text - not: "how to parse the text", that's your task...
This execise was designed that you can manage it to solve yourself. You won't get ready to use solutions here.
So: concrete question with the small code snippet that makes troubles would help.

Cheers
Andi
PS: You stated at least one rule: after "very" comes "good", no other word is suggested for "very". I.e. in Markov-Chain terms: from the "very"-state, you have 100% probability for "good" and 0% probability for any other word. And a second rule: any other word has 0% probability for any other next word (i.e. you do not suggest any under these conditions). Maybe you have more rules.

See César de Souza's great article on Hidden Markov models here on CP:
Sequence Classifiers in C# - Part I: Hidden Markov Models[^]
 
Share this answer
 
This is hardly a complicated problem. Save the text in a string[^] and use the various string methods to search and extract words according to your rules.
 
Share this answer
 

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