Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NOTE: This is not yet completed (a lot of duplication)
- enum BreakType
- {
- None,
- Dialog,
- Command,
- Ending,
- }
- public string Split(string input)
- {
- var breakEarlyDialog = true;
- var dp = new bool[input.Length];
- var dpBreakTypes = new BreakType[input.Length];
- var hash = new HashSet<char>();
- var comma = new HashSet<char>();
- for (int i = 0; i < input.Length; i++)
- {
- if (hash.Contains(input[i]))
- {
- dp[i] = CanSplit(input, i);
- }
- }
- for (var i = 0; i < dp.Length; i++)
- {
- if (dpBreakTypes[i] == BreakType.None)
- {
- continue;
- }
- // maybe calculate and get type break type from position
- // return with break as soon as there is a match
- // note: to get the best from avg move both dir
- // split from mid and find first BreakType.Dialog and check if it's what we looking for
- // if true then it will give the best split position
- // f(x) => breaktype;
- // f(x+1) => breaktype
- // f(x-1) => breaktype
- if (dpBreakTypes[i] == BreakType.Dialog && breakEarlyDialog)
- {
- return string.Join(Environment.NewLine, input.Substring(0, i), input.Substring(i));
- }
- if (dp[i] && breakEarlyDialog && comma.Contains(input[i]))
- {
- return string.Join(Environment.NewLine, input.Substring(0, i), input.Substring(i));
- }
- if (dp[i] && breakEarlyDialog && comma.Contains(input[i]))
- {
- return string.Join(Environment.NewLine, input.Substring(0, i), input.Substring(i));
- }
- if (dp[i] && breakEarlyDialog && comma.Contains(input[i]))
- {
- return string.Join(Environment.NewLine, input.Substring(0, i), input.Substring(i));
- }
- if (dp[i] && breakEarlyDialog && comma.Contains(input[i]))
- {
- return string.Join(Environment.NewLine, input.Substring(0, i), input.Substring(i));
- }
- }
- return "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement