Example #1
0
        private int AddUnmarkedSegment(int segmentTextStart, int segmentTextEnd)
        {
            if (segmentTextEnd < segmentTextStart)
            {
                return(-1);
            }

            var originalSegmentText =
                OriginalText.Substring(
                    segmentTextStart,
                    segmentTextEnd - segmentTextStart + 1
                    );

            var segmentTextHash = originalSegmentText.GetHashSha256();

            MappingComposerSegment segment;

            if (_segmentsDictionary.TryGetValue(segmentTextHash, out segment) == false)
            {
                segment = new MappingComposerSegment(UniqueSegmentsCount, UniqueUnmarkedSegmentsCount, originalSegmentText);

                _segmentsDictionary.Add(segmentTextHash, segment);

                UniqueUnmarkedSegmentsCount++;
            }

            _segmentsList.Add(segment);

            return(segmentTextEnd + 1);
        }
Example #2
0
        private int AddIdentifiedSegment(string leftDel, int segmentTextStart, string segmentText)
        {
            var originalSegmentText = leftDel + segmentText;

            var segmentTextHash = originalSegmentText.GetHashSha256();

            MappingComposerSegment segment;

            if (_segmentsDictionary.TryGetValue(segmentTextHash, out segment) == false)
            {
                segment = new MappingComposerSegment(UniqueSegmentsCount, UniqueMarkedSegmentsCount, leftDel, segmentText);

                _segmentsDictionary.Add(segmentTextHash, segment);

                UniqueMarkedSegmentsCount++;
            }

            _segmentsList.Add(segment);

            //Return the location of the start of the next segment
            return(segmentTextStart + originalSegmentText.Length);
        }