- Home /
Show Strings With Last Characters of the first Word
Hello There Senior Programmer of Unity3d.. Can i ask u something about how to show 5 Words just like : Apple, Electro, Organic, Champ, and Pen First i want to show words "Apple" and following by "Electro" and "Organic" and etc but the first words "Apple" must be showed first and then the second words is taken from last character of the first Word "Apple --> E" and the Second character show up "Electro" and etc Example: 1. ApplE 2. ElectrO 3. OrganiC 4. ChamP 5. Pen
Could u help me to solve this problem? sorry for bothering u all with some questions like this..
Best Regards, Hadi From indonesia
Yepp.. I'm Using Speech Recognition.. i've tried to show the first words and it's succeed.. but.. if i want to show the second word with the last character of the first word i've failed.. Thx for your comment
IEnumerator DoRecording() { Debug.Log("Recording"); audio.clip = $$anonymous$$icrophone.Start(null, false, 3, 8000); yield return new WaitForSeconds(3); Debug.Log("Playing"); audio.Play(); $$anonymous$$icrophone.End(null);
float[] clipData = new float[audio.clip.samples * audio.clip.channels];
audio.clip.GetData(clipData, 0);
//Format to 8$$anonymous$$Hz sampling rate
WaveGen.WaveFormatChunk format = new WaveGen().$$anonymous$$akeFormat(audio.clip);
string filename = "recordedSpeech.wav";
FileStream stream = File.OpenWrite(filename);
new WaveGen().Write(clipData, format, stream);
stream.Close();
ATT_$$anonymous$$SSD$$anonymous$$.Speechv3.SpeechResponse response = SpeechToTextService(filename, "Generic", "audio/wav");
string speechOutput = response.Recognition.NBest[0].ResultText;
Debug.Log(speechOutput);
string text = speechOutput.ToLower();
if (text.Contains ("apple"))
{
Spawn();
}
speechText.text = text.ToString();
This is the code that i do.. but the problem is.. i want to show next character with the last character of "ApplE" it's meant E
Did I understand right? You need an algorithm that takes in an array of strings, starts from the first string and orders the rest so that each word starts with the letter the previous word ended with?
Yes.. Thx for your comment.. i need that algorithm.. can u solve this problem sir? sorry for botherig u.. best regards..
Answer by Kiwasi · Nov 06, 2014 at 10:50 AM
Query, does your algorithm need to find the best path through the words? Or just a path?
To find any path:
Put all the unused words in an unused list
Grab a random word, remove it from the list and add it to a used list
Search the unused list for a word where the first letter (The string class has several methods that will help. You can also convert the string to a character array)
Remove the found word the unused list and add it to the used list
Repeat
You will have to define your behaviour once a match cannot be found.
To find the best possible path
Build a directed graph by linking each word to the possible follow on words
Starting from each node traverse the graph until a path is found which includes all nodes
There is a bunch of optimisations in graph theory that may be able to help. Consider first splitting the graph up into multiple sub graphs by checking for nodes that are impossible to reach. Also consider marking nodes that must be at the end or start of a chain. There may be some similarities to algorithms for finding the critical path.
Your answer
Follow this Question
Related Questions
C# script error. 0 Answers
error CS8025: Parsing error in C# code 3 Answers
Why am I getting a parsing error? 1 Answer
Null in GetValidMethodInfo 0 Answers