internal string ReplaceWithEscapeSequences(string message) { return(CompiledRegex.Replace(message, new MatchEvaluator(this.MatchEvaluator))); }
public Payload RunPlugin(Payload Input) { Payload pData = new Payload(); pData.FileID = Input.FileID; //pData.SegmentID = Input.SegmentID; for (int i = 0; i < Input.StringList.Count; i++) { HashSet <string> speakerListTransient = new HashSet <string>(); string[] readText_Lines = NewlineClean.Split(Input.StringList[i]); int NumberOfLines = readText_Lines.Length; //loop through all of the lines in each text for (int j = 0; j < NumberOfLines; j++) { string CurrentLine = readText_Lines[j]; if (regexRepl.Length > 0) { CurrentLine = CompiledRegex.Replace(CurrentLine, "").Trim(); } else { CurrentLine = CurrentLine.Trim(); } int IndexOfDelimiter = CurrentLine.IndexOf(DelimiterString); if (IndexOfDelimiter > -1) { string SpeakerTag = CurrentLine.Substring(0, IndexOfDelimiter + DelimiterLength); if (uniqueTagsOnly) { if (!speakerList.Contains(SpeakerTag) && SpeakerTag.Length <= MaxTagLengthInt) { speakerList.Add(SpeakerTag); pData.StringArrayList.Add(new string[] { SpeakerTag }); pData.SegmentNumber.Add(Input.SegmentNumber[i]); if (Input.SegmentID.Count > 0) { pData.SegmentID.Add(Input.SegmentID[i]); } } } else { if (!speakerListTransient.Contains(SpeakerTag) && SpeakerTag.Length <= MaxTagLengthInt) { speakerListTransient.Add(SpeakerTag); pData.StringArrayList.Add(new string[] { SpeakerTag }); pData.SegmentNumber.Add(Input.SegmentNumber[i]); if (Input.SegmentID.Count > 0) { pData.SegmentID.Add(Input.SegmentID[i]); } } } } //end of for loop through each line } } return(pData); }
public Payload RunPlugin(Payload Input) { Payload pData = new Payload(); pData.FileID = Input.FileID; for (int i = 0; i < Input.StringList.Count; i++) { //setting everything up Dictionary <string, List <string> > Text_Split = new Dictionary <string, List <string> >(); string[] readText_Lines = NewlineClean.Split(Input.StringList[i]); int NumberOfLines = readText_Lines.Length; string PreviousSpeaker = ""; GroupData group = new GroupData(); Dictionary <ulong, Tuple <string, int> > TurnTracker = new Dictionary <ulong, Tuple <string, int> >(); ulong turnCounter = 0; #region Parse Out Line into Speakers for (int j = 0; j < NumberOfLines; j++) { string CurrentLine = readText_Lines[j]; if (regexRepl.Length > 0) { CurrentLine = CompiledRegex.Replace(CurrentLine, "").Trim(); } else { CurrentLine = CurrentLine.Trim(); } //if the line is empty, move along... move along if (CurrentLine.Length == 0) { continue; } bool FoundSpeaker = false; //loop through each speaker in list to see if the line starts with their name for (int k = 0; k < SpeakerListLength; k++) { // here's what we do if we find a match if (CurrentLine.StartsWith(SpeakerList[k])) { FoundSpeaker = true; PreviousSpeaker = SpeakerList[k]; //clean up the line to remove the speaker tag from the beginning int Place = CurrentLine.IndexOf(SpeakerList[k]); CurrentLine = CurrentLine.Remove(Place, SpeakerList[k].Length).Insert(Place, "").Trim() + "\r\n"; if (Text_Split.ContainsKey(SpeakerList[k])) { Text_Split[SpeakerList[k]].Add(CurrentLine.Trim()); } else { Text_Split.Add(SpeakerList[k], new List <string>() { CurrentLine.Trim() }); } //make sure we track where the line is located TurnTracker.Add(turnCounter, new Tuple <string, int>(SpeakerList[k], Text_Split[SpeakerList[k]].Count - 1)); turnCounter++; //break to the next line in the text break; } } //what we will do if no speaker was found if ((FoundSpeaker == false) && (PreviousSpeaker != "")) { if (multiLine) { Text_Split[PreviousSpeaker][Text_Split[PreviousSpeaker].Count - 1] += CurrentLine.Trim() + "\r\n"; } } //end of for loop through each line } #endregion StringBuilder segID = new StringBuilder(); foreach (KeyValuePair <string, List <string> > entry in Text_Split) { group.People.Add(new Person(entry.Key, entry.Value)); segID.Append(entry.Key + ";"); } group.TurnTracker = TurnTracker; pData.ObjectList.Add(group); pData.SegmentID.Add(segID.ToString()); pData.SegmentNumber.Add(Input.SegmentNumber[i]); } return(pData); }