ABB.Swum.SamuraiIdSplitter.SplitSameCase C# (CSharp) Метод

SplitSameCase() приватный Метод

Splits a word into subwords. The word should be either (1) all lowercase, (2) all uppercase, or (3) a single uppercase letter followed by lowercase letters
private SplitSameCase ( string word, double noSplitScore ) : string[]
word string The word to split.
noSplitScore double The word's score before any splitting.
Результат string[]
        private string[] SplitSameCase(string word, double noSplitScore)
        {
            List<string> bestSplit = new List<string>();
            bestSplit.Add(word);
            double maxScore = -1;

            for (int i = 0; i < word.Length; i++)
            {
                string left = word.Substring(0, i + 1);
                string right = word.Substring(i + 1);
                double scoreLeft = Score(left);
                double scoreRight = Score(right);
                bool prefix = IsPrefix(left) || IsSuffix(right);

                bool splitLeft = (Math.Sqrt(scoreLeft) > Math.Max(Score(word), noSplitScore));
                bool splitRight = (Math.Sqrt(scoreRight) > Math.Max(Score(word), noSplitScore));

                if (!prefix && splitLeft && splitRight)
                {
                    if (scoreLeft + scoreRight > maxScore)
                    {
                        //found new best split
                        maxScore = scoreLeft + scoreRight;
                        bestSplit.Clear();
                        bestSplit.Add(left);
                        bestSplit.Add(right);
                    }
                }
                else if (!prefix && splitLeft)
                {
                    string[] furtherSplit = SplitSameCase(right, noSplitScore);
                    if (furtherSplit.Length > 1)
                    {
                        bestSplit.Clear();
                        bestSplit.Add(left);
//                        maxScore = scoreLeft; //Emily doesn't set maxScore here, but shouldn't it be?
                        foreach (string w in furtherSplit)
                        {
                            bestSplit.Add(w);
//                            maxScore += Score(w); //Emily doesn't set maxScore here, but shouldn't it be?
                        }
                    }
                }
            }

            return bestSplit.ToArray();
        }

Same methods

SamuraiIdSplitter::SplitSameCase ( string word ) : string[]