18 using System.Collections.Generic;
21 using TraceLabSDK.Types;
23 namespace TraceLab.Components.DevelopmentKit.Preprocessors.Splitters
36 public static TLArtifactsCollection
ProcessArtifacts(TLArtifactsCollection listOfArtifacts,
bool keepCompoundIdentifier)
38 TLArtifactsCollection processed =
new TLArtifactsCollection();
39 foreach (TLArtifact artifact
in listOfArtifacts.Values)
41 TLArtifact processedArtifact =
new TLArtifact(artifact.Id, String.Empty);
42 processedArtifact.Text = ProcessText(artifact.Text, keepCompoundIdentifier);
43 processed.Add(processedArtifact);
54 public static string ProcessText(
string originalBuffer,
bool keepCompoundIdentifier)
56 string[] words = originalBuffer.Split();
58 StringBuilder newBuffer =
new StringBuilder();
59 bool isCompoundIdentifier;
61 foreach (
string word
in words)
63 string originalWord = word;
67 StringBuilder newWord;
69 isCompoundIdentifier =
false;
70 if (word.IndexOf(
'_') >= 0)
72 isCompoundIdentifier =
true;
73 newWord =
new StringBuilder(word.Replace(
"_",
" "));
77 newWord =
new StringBuilder(word);
80 for (
int i = newWord.Length - 1; i >= 0; i--)
82 if (Char.IsUpper(newWord.ToString()[i]))
85 if (Char.IsLower(newWord.ToString()[i-1]))
87 newWord.Insert(i,
' ');
88 isCompoundIdentifier=
true;
92 if (Char.IsLower(newWord.ToString()[i]))
95 if (Char.IsUpper(newWord.ToString()[i-1]))
97 newWord.Insert(i - 1,
' ');
98 isCompoundIdentifier =
true;
103 newBuffer.Append(newWord.ToString().ToLower());
104 newBuffer.Append(
' ');
105 if (keepCompoundIdentifier)
107 if (isCompoundIdentifier)
109 newBuffer.Append(originalWord.ToLower());
110 newBuffer.Append(
' ');
114 return newBuffer.ToString();