Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys
I am working on a project that my professor asked.
I need an algoritm to create a fsa for strings
example:
takes this sentences: "ali goes to school"
and create a graph like this
START->ali->goes->to->school->END

the graphical part of drawing a chart like this is not important.

the question is how can I create this.

this project is for a lesson named "The Formal Languages & Automata".
Professor wnats a peogram that take some strings from a text file and draw a common fsa for them, a fsa that all of strings in that file can be parsed with taht.

I need a serious help. so please share your knowledge with me
thank.
Posted

Right now you probably know more about this than most people here as you're in the middle of it so you may get a better response by having a go at it and asking more specific questions when you get stuck. It's been a very long time since I looked at anything like this so don't take my word for anything. Given that, IF I remember correctly you can brute force this by creating a state for every unique sub sequence that starts at a first item and then culling from there based on the number of potential state transitions.

ali goes to school
ali goes home

states:
ali
ali goes
ali goes to
ali goes home
ali goes to school

graph:
START->ali->goes->to->school->END
->home->END

Various reductions are possible for example 'ali' is always followed by 'goes' only one available transition so 'ali goes' can become one state, similarly 'to school' giving a reduced graph:
START->'ali goes'->'to school'->END
->'home'->END

I hope this is helpful.
 
Share this answer
 
Comments
ali_crash 18-Mar-13 13:41pm    
yes it is helpful
which langueage you think I should use for programing project? C# or java?
Matthew Faithfull 18-Mar-13 13:45pm    
Personally I would use C# if those were the choices but if you know both then I don't think it makes any difference. Although it might be easier to get C# help on CodeProject than Java help which is worth considering.
 
Share this answer
 
Comments
ali_crash 18-Mar-13 13:39pm    
I couldn't download that programs source and they are not exactly my problem's solution
please give me some codes, thanks :)

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