diff --git a/src/Lucene.Net.Analysis.Common/Analysis/De/GermanStemmer.cs b/src/Lucene.Net.Analysis.Common/Analysis/De/GermanStemmer.cs index bdb1413a02..2b39d5045c 100644 --- a/src/Lucene.Net.Analysis.Common/Analysis/De/GermanStemmer.cs +++ b/src/Lucene.Net.Analysis.Common/Analysis/De/GermanStemmer.cs @@ -1,4 +1,6 @@ // Lucene version compatibility level 4.8.1 + +using J2N.Text; using System; using System.Globalization; using System.Text; @@ -25,7 +27,7 @@ namespace Lucene.Net.Analysis.De */ /// - /// A stemmer for German words. + /// A stemmer for German words. /// /// The algorithm is based on the report /// "A Fast and Simple Stemming Algorithm for German Words" by Jörg @@ -60,8 +62,7 @@ protected internal virtual string Stem(string term) return term; } // Reset the StringBuilder. - sb.Remove(0, sb.Length); - sb.Insert(0, term); + sb.Replace(0, sb.Length, term); // Stemming starts here... Substitute(sb); Strip(sb); @@ -102,32 +103,32 @@ private void Strip(StringBuilder buffer) { if ((buffer.Length + substCount > 5) && buffer.ToString(buffer.Length - 2, buffer.Length - (buffer.Length - 2)).Equals("nd", StringComparison.Ordinal)) { - buffer.Remove(buffer.Length - 2, buffer.Length - (buffer.Length - 2)); + buffer.Delete(buffer.Length - 2, buffer.Length - (buffer.Length - 2)); } else if ((buffer.Length + substCount > 4) && buffer.ToString(buffer.Length - 2, buffer.Length - (buffer.Length - 2)).Equals("em", StringComparison.Ordinal)) { - buffer.Remove(buffer.Length - 2, buffer.Length - (buffer.Length - 2)); + buffer.Delete(buffer.Length - 2, buffer.Length - (buffer.Length - 2)); } else if ((buffer.Length + substCount > 4) && buffer.ToString(buffer.Length - 2, buffer.Length - (buffer.Length - 2)).Equals("er", StringComparison.Ordinal)) { - buffer.Remove(buffer.Length - 2, buffer.Length - (buffer.Length - 2)); + buffer.Delete(buffer.Length - 2, buffer.Length - (buffer.Length - 2)); } else if (buffer[buffer.Length - 1] == 'e') { - buffer.Remove(buffer.Length - 1, 1); + buffer.Delete(buffer.Length - 1, 1); } else if (buffer[buffer.Length - 1] == 's') { - buffer.Remove(buffer.Length - 1, 1); + buffer.Delete(buffer.Length - 1, 1); } else if (buffer[buffer.Length - 1] == 'n') { - buffer.Remove(buffer.Length - 1, 1); + buffer.Delete(buffer.Length - 1, 1); } // "t" occurs only as suffix of verbs. else if (buffer[buffer.Length - 1] == 't') { - buffer.Remove(buffer.Length - 1, 1); + buffer.Delete(buffer.Length - 1, 1); } else { @@ -145,7 +146,7 @@ private void Optimize(StringBuilder buffer) // Additional step for female plurals of professions and inhabitants. if (buffer.Length > 5 && buffer.ToString(buffer.Length - 5, buffer.Length - (buffer.Length - 5)).Equals("erin*", StringComparison.Ordinal)) { - buffer.Remove(buffer.Length - 1, 1); + buffer.Delete(buffer.Length - 1, 1); Strip(buffer); } // Additional step for irregular plural nouns like "Matrizen -> Matrix". @@ -167,7 +168,7 @@ private static void RemoveParticleDenotion(StringBuilder buffer) // LUCENENET: C { if (buffer.ToString(c, 4).Equals("gege", StringComparison.Ordinal)) { - buffer.Remove(c, (c + 2) - c); + buffer.Delete(c, (c + 2) - c); return; } } @@ -176,7 +177,7 @@ private static void RemoveParticleDenotion(StringBuilder buffer) // LUCENENET: C /// /// Do some substitutions for the term to reduce overstemming: - /// + /// /// /// Substitute Umlauts with their corresponding vowel: äöü -> aou, /// "ß" is substituted by "ss" @@ -223,37 +224,37 @@ private void Substitute(StringBuilder buffer) if ((c < buffer.Length - 2) && buffer[c] == 's' && buffer[c + 1] == 'c' && buffer[c + 2] == 'h') { buffer[c] = '$'; - buffer.Remove(c + 1, (c + 3) - (c + 1)); + buffer.Delete(c + 1, (c + 3) - (c + 1)); substCount = +2; } else if (buffer[c] == 'c' && buffer[c + 1] == 'h') { buffer[c] = '§'; - buffer.Remove(c + 1, 1); + buffer.Delete(c + 1, 1); substCount++; } else if (buffer[c] == 'e' && buffer[c + 1] == 'i') { buffer[c] = '%'; - buffer.Remove(c + 1, 1); + buffer.Delete(c + 1, 1); substCount++; } else if (buffer[c] == 'i' && buffer[c + 1] == 'e') { buffer[c] = '&'; - buffer.Remove(c + 1, 1); + buffer.Delete(c + 1, 1); substCount++; } else if (buffer[c] == 'i' && buffer[c + 1] == 'g') { buffer[c] = '#'; - buffer.Remove(c + 1, 1); + buffer.Delete(c + 1, 1); substCount++; } else if (buffer[c] == 's' && buffer[c + 1] == 't') { buffer[c] = '!'; - buffer.Remove(c + 1, 1); + buffer.Delete(c + 1, 1); substCount++; } } @@ -307,4 +308,4 @@ private static void Resubstitute(StringBuilder buffer) // LUCENENET: CA1822: Mar } } } -} \ No newline at end of file +} diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Fr/FrenchStemmer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Fr/FrenchStemmer.cs index 6a947a1339..814dbd16d5 100644 --- a/src/Lucene.Net.Analysis.Common/Analysis/Fr/FrenchStemmer.cs +++ b/src/Lucene.Net.Analysis.Common/Analysis/Fr/FrenchStemmer.cs @@ -1,4 +1,6 @@ // Lucene version compatibility level 4.8.1 + +using J2N.Text; using System; using System.Globalization; using System.Text; @@ -23,14 +25,14 @@ namespace Lucene.Net.Analysis.Fr */ /// - /// A stemmer for French words. + /// A stemmer for French words. /// /// The algorithm is based on the work of /// Dr Martin Porter on his snowball project /// refer to http://snowball.sourceforge.net/french/stemmer.html /// (French stemming algorithm) for details /// - /// @deprecated Use instead, + /// @deprecated Use instead, /// which has the same functionality. This filter will be removed in Lucene 4.0 [Obsolete("Use FrenchStemmer instead, which has the same functionality.")] public class FrenchStemmer @@ -102,8 +104,7 @@ protected internal virtual string Stem(string term) term = locale.TextInfo.ToLower(term); // Reset the StringBuilder. - sb.Remove(0, sb.Length); - sb.Insert(0, term); + sb.Replace(0, sb.Length, term); // reset the booleans modified = false; @@ -155,8 +156,7 @@ private void SetStrings() R1 = RetrieveR(sb); if (R1 != null) { - tb.Remove(0, tb.Length); - tb.Insert(0, R1); + tb.Replace(0, tb.Length, R1); R2 = RetrieveR(tb); } else @@ -291,7 +291,7 @@ private void Step4() char b = sb[sb.Length - 2]; if (b != 'a' && b != 'i' && b != 'o' && b != 'u' && b != 'è' && b != 's') { - sb.Remove(sb.Length - 1, sb.Length - (sb.Length - 1)); + sb.Delete(sb.Length - 1, sb.Length - (sb.Length - 1)); SetStrings(); } } @@ -317,7 +317,7 @@ private void Step5() { if (R0.EndsWith("enn", StringComparison.Ordinal) || R0.EndsWith("onn", StringComparison.Ordinal) || R0.EndsWith("ett", StringComparison.Ordinal) || R0.EndsWith("ell", StringComparison.Ordinal) || R0.EndsWith("eill", StringComparison.Ordinal)) { - sb.Remove(sb.Length - 1, sb.Length - (sb.Length - 1)); + sb.Delete(sb.Length - 1, sb.Length - (sb.Length - 1)); SetStrings(); } } @@ -387,7 +387,7 @@ private bool DeleteFromIfPrecededIn(string source, string[] search, string from, { if (from != null && from.EndsWith(prefix + search[i], StringComparison.Ordinal)) { - sb.Remove(sb.Length - search[i].Length, sb.Length - (sb.Length - search[i].Length)); + sb.Delete(sb.Length - search[i].Length, sb.Length - (sb.Length - search[i].Length)); found = true; SetStrings(); break; @@ -420,7 +420,7 @@ private bool DeleteFromIfTestVowelBeforeIn(string source, string[] search, bool bool test = IsVowel(sb[sb.Length - (search[i].Length + 1)]); if (test == vowel) { - sb.Remove(sb.Length - search[i].Length, sb.Length - (sb.Length - search[i].Length)); + sb.Delete(sb.Length - search[i].Length, sb.Length - (sb.Length - search[i].Length)); modified = true; found = true; SetStrings(); @@ -448,14 +448,14 @@ private void DeleteButSuffixFrom(string source, string[] search, string prefix, { if (source.EndsWith(prefix + search[i], StringComparison.Ordinal)) { - sb.Remove(sb.Length - (prefix.Length + search[i].Length), sb.Length - (sb.Length - (prefix.Length + search[i].Length))); + sb.Delete(sb.Length - (prefix.Length + search[i].Length), sb.Length - (sb.Length - (prefix.Length + search[i].Length))); modified = true; SetStrings(); break; } else if (without && source.EndsWith(search[i], StringComparison.Ordinal)) { - sb.Remove(sb.Length - search[i].Length, sb.Length - (sb.Length - search[i].Length)); + sb.Delete(sb.Length - search[i].Length, sb.Length - (sb.Length - search[i].Length)); modified = true; SetStrings(); break; @@ -483,21 +483,21 @@ private void DeleteButSuffixFromElseReplace(string source, string[] search, stri { if (source.EndsWith(prefix + search[i], StringComparison.Ordinal)) { - sb.Remove(sb.Length - (prefix.Length + search[i].Length), sb.Length - (sb.Length - (prefix.Length + search[i].Length))); + sb.Delete(sb.Length - (prefix.Length + search[i].Length), sb.Length - (sb.Length - (prefix.Length + search[i].Length))); modified = true; SetStrings(); break; } else if (from != null && from.EndsWith(prefix + search[i], StringComparison.Ordinal)) { - sb.Remove(sb.Length - (prefix.Length + search[i].Length), sb.Length - (sb.Length - (prefix.Length + search[i].Length))).Insert(sb.Length - (prefix.Length + search[i].Length), replace); + sb.Replace(sb.Length - (prefix.Length + search[i].Length), sb.Length - (sb.Length - (prefix.Length + search[i].Length)), replace); modified = true; SetStrings(); break; } else if (without && source.EndsWith(search[i], StringComparison.Ordinal)) { - sb.Remove(sb.Length - search[i].Length, sb.Length - (sb.Length - search[i].Length)); + sb.Delete(sb.Length - search[i].Length, sb.Length - (sb.Length - search[i].Length)); modified = true; SetStrings(); break; @@ -521,7 +521,7 @@ private bool ReplaceFrom(string source, string[] search, string replace) { if (source.EndsWith(search[i], StringComparison.Ordinal)) { - sb.Remove(sb.Length - search[i].Length, sb.Length - (sb.Length - search[i].Length)).Insert(sb.Length - search[i].Length, replace); + sb.Replace(sb.Length - search[i].Length, sb.Length - (sb.Length - search[i].Length), replace); modified = true; found = true; SetStrings(); @@ -545,7 +545,7 @@ private void DeleteFrom(string source, string[] suffix) { if (source.EndsWith(suffix[i], StringComparison.Ordinal)) { - sb.Remove(sb.Length - suffix[i].Length, sb.Length - (sb.Length - suffix[i].Length)); + sb.Delete(sb.Length - suffix[i].Length, sb.Length - (sb.Length - suffix[i].Length)); modified = true; SetStrings(); break; @@ -784,4 +784,4 @@ private bool IsStemmable(string term) return true; } } -} \ No newline at end of file +} diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs b/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs index 2bcda79add..741ae6832f 100644 --- a/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs +++ b/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs @@ -1450,8 +1450,7 @@ internal static void ApplyMappings(FST fst, StringBuilder sb) if (longestMatch >= 0) { - sb.Remove(i, longestMatch + 1 - i); - sb.Insert(i, longestOutput); + sb.Replace(i, longestMatch + 1 - i, longestOutput!.ToString()); // LUCENENET: [!]: longestOutput is set if longestMatch >= 0 i += (longestOutput.Length - 1); } } diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Nl/DutchStemmer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Nl/DutchStemmer.cs index d272a234d6..3d51055264 100644 --- a/src/Lucene.Net.Analysis.Common/Analysis/Nl/DutchStemmer.cs +++ b/src/Lucene.Net.Analysis.Common/Analysis/Nl/DutchStemmer.cs @@ -1,4 +1,6 @@ // Lucene version compatibility level 4.8.1 + +using J2N.Text; using System; using System.Collections.Generic; using System.Globalization; @@ -24,14 +26,14 @@ namespace Lucene.Net.Analysis.Nl */ /// - /// A stemmer for Dutch words. + /// A stemmer for Dutch words. /// /// The algorithm is an implementation of /// the dutch stemming /// algorithm in Martin Porter's snowball project. /// - /// @deprecated (3.1) Use instead, - /// which has the same functionality. This filter will be removed in Lucene 5.0 + /// @deprecated (3.1) Use instead, + /// which has the same functionality. This filter will be removed in Lucene 5.0 [Obsolete("(3.1) Use Tartarus.Snowball.Ext.DutchStemmer instead, which has the same functionality. This filter will be removed in Lucene 5.0")] public class DutchStemmer { @@ -67,8 +69,7 @@ public virtual string Stem(string term) } // Reset the StringBuilder. - sb.Remove(0, sb.Length); - sb.Insert(0, term); + sb.Replace(0, sb.Length, term); // Stemming starts here... Substitute(sb); StoreYandI(sb); @@ -94,7 +95,7 @@ private bool EnEnding(StringBuilder sb) int index = s.Length - end.Length; if (s.EndsWith(end, StringComparison.Ordinal) && index >= _R1 && IsValidEnEnding(sb, index - 1)) { - sb.Remove(index, index + end.Length - index); + sb.Delete(index, index + end.Length - index); UnDouble(sb, index); return true; } @@ -117,7 +118,8 @@ private void Step1(StringBuilder sb) if (s.EndsWith("heden", StringComparison.Ordinal)) { //sb.Remove(_R1, lengthR1 + _R1 - _R1).Insert(_R1, sb.Substring(_R1, lengthR1).replaceAll("heden", "heid")); - sb.Remove(_R1, lengthR1 + _R1 - _R1).Insert(_R1, sb.ToString(_R1, lengthR1).Replace("heden", "heid")); + // LUCENENET NOTE: Per #664, can't use Replace instead of Delete/Insert because argument references sb after Remove/Delete call + sb.Delete(_R1, lengthR1 + _R1 - _R1).Insert(_R1, sb.ToString(_R1, lengthR1).Replace("heden", "heid")); return; } @@ -128,12 +130,12 @@ private void Step1(StringBuilder sb) if (s.EndsWith("se", StringComparison.Ordinal) && (index = s.Length - 2) >= _R1 && IsValidSEnding(sb, index - 1)) { - sb.Remove(index, index + 2 - index); + sb.Delete(index, index + 2 - index); return; } if (s.EndsWith("s", StringComparison.Ordinal) && (index = s.Length - 1) >= _R1 && IsValidSEnding(sb, index - 1)) { - sb.Remove(index, index + 1 - index); + sb.Delete(index, index + 1 - index); } } @@ -153,7 +155,7 @@ private void Step2(StringBuilder sb) int index = s.Length - 1; if (index >= _R1 && s.EndsWith("e", StringComparison.Ordinal) && !IsVowel(sb[index - 1])) { - sb.Remove(index, index + 1 - index); + sb.Delete(index, index + 1 - index); UnDouble(sb); _removedE = true; } @@ -173,7 +175,7 @@ private void Step3a(StringBuilder sb) int index = s.Length - 4; if (s.EndsWith("heid", StringComparison.Ordinal) && index >= _R2 && sb[index - 1] != 'c') { - sb.Remove(index, index + 4 - index); //remove heid + sb.Delete(index, index + 4 - index); //remove heid EnEnding(sb); } } @@ -202,13 +204,13 @@ private void Step3b(StringBuilder sb) if ((s.EndsWith("end", StringComparison.Ordinal) || s.EndsWith("ing", StringComparison.Ordinal)) && (index = s.Length - 3) >= _R2) { - sb.Remove(index, index + 3 - index); + sb.Delete(index, index + 3 - index); if (sb[index - 2] == 'i' && sb[index - 1] == 'g') { if (sb[index - 3] != 'e' && index - 2 >= _R2) // LUCENENET: '&' was changed to '&&' following - https://github.com/apache/lucenenet/issues/673 { index -= 2; - sb.Remove(index, index + 2 - index); + sb.Delete(index, index + 2 - index); } } else @@ -221,26 +223,26 @@ private void Step3b(StringBuilder sb) { if (sb[index - 1] != 'e') { - sb.Remove(index, index + 2 - index); + sb.Delete(index, index + 2 - index); } return; } if (s.EndsWith("lijk", StringComparison.Ordinal) && (index = s.Length - 4) >= _R2) { - sb.Remove(index, index + 4 - index); + sb.Delete(index, index + 4 - index); Step2(sb); return; } if (s.EndsWith("baar", StringComparison.Ordinal) && (index = s.Length - 4) >= _R2) { - sb.Remove(index, index + 4 - index); + sb.Delete(index, index + 4 - index); return; } if (s.EndsWith("bar", StringComparison.Ordinal) && (index = s.Length - 3) >= _R2) { if (_removedE) { - sb.Remove(index, index + 3 - index); + sb.Delete(index, index + 3 - index); } //return; // LUCENENET: Removed redundant jump statements. https://rules.sonarsource.com/csharp/RSPEC-3626 } @@ -264,7 +266,7 @@ private void Step4(StringBuilder sb) char d = end[3]; if (v1 == v2 && d != 'I' && v1 != 'i' && IsVowel(v1) && !IsVowel(d) && !IsVowel(c)) { - sb.Remove(sb.Length - 2, (sb.Length - 1) - (sb.Length - 2)); + sb.Delete(sb.Length - 2, (sb.Length - 1) - (sb.Length - 2)); } } @@ -374,7 +376,7 @@ private void UnDouble(StringBuilder sb, int endIndex) string s = sb.ToString(0, endIndex); if (s.EndsWith("kk", StringComparison.Ordinal) || s.EndsWith("tt", StringComparison.Ordinal) || s.EndsWith("dd", StringComparison.Ordinal) || s.EndsWith("nn", StringComparison.Ordinal) || s.EndsWith("mm", StringComparison.Ordinal) || s.EndsWith("ff", StringComparison.Ordinal)) { - sb.Remove(endIndex - 1, endIndex - (endIndex - 1)); + sb.Delete(endIndex - 1, endIndex - (endIndex - 1)); } } @@ -436,8 +438,7 @@ private void StoreYandI(StringBuilder sb) private void ReStoreYandI(StringBuilder sb) { string tmp = sb.ToString(); - sb.Remove(0, sb.Length); - sb.Insert(0, tmp.Replace("I", "i").Replace("Y", "y")); + sb.Replace(0, sb.Length, tmp.Replace("I", "i").Replace("Y", "y")); } private bool IsVowel(char c) @@ -464,4 +465,4 @@ internal virtual IDictionary StemDictionary set => _stemDict = value; } } -} \ No newline at end of file +} diff --git a/src/Lucene.Net.Analysis.ICU/Analysis/Icu/ICUNormalizer2CharFilter.cs b/src/Lucene.Net.Analysis.ICU/Analysis/Icu/ICUNormalizer2CharFilter.cs index 577fa462f8..0b63b04a86 100644 --- a/src/Lucene.Net.Analysis.ICU/Analysis/Icu/ICUNormalizer2CharFilter.cs +++ b/src/Lucene.Net.Analysis.ICU/Analysis/Icu/ICUNormalizer2CharFilter.cs @@ -251,7 +251,7 @@ private int OutputFromResultBuffer(char[] cbuf, int begin, int len) resultBuffer.CopyTo(0, cbuf, begin, len); if (len > 0) { - resultBuffer.Remove(0, len); + resultBuffer.Delete(0, len); } return len; } diff --git a/src/Lucene.Net.Analysis.Kuromoji/Dict/UserDictionary.cs b/src/Lucene.Net.Analysis.Kuromoji/Dict/UserDictionary.cs index e71052d1c4..58232790d5 100644 --- a/src/Lucene.Net.Analysis.Kuromoji/Dict/UserDictionary.cs +++ b/src/Lucene.Net.Analysis.Kuromoji/Dict/UserDictionary.cs @@ -283,7 +283,7 @@ private string GetFeature(int wordId, params int[] fields) sb.Append(CSVUtil.QuoteEscape(allFeatures[field])).Append(','); } } - return sb.Remove(sb.Length - 1, 1).ToString(); + return sb.Delete(sb.Length - 1, 1).ToString(); } } } diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs b/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs index 84a5d94a2e..cce94d36c1 100644 --- a/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs +++ b/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs @@ -141,7 +141,7 @@ public void ProcessNextReplacement(string replacement, bool forceAppend) if (builder.Length > MAX_LENGTH) { //builder.delete(MAX_LENGTH, builder.Length); - builder.Remove(MAX_LENGTH, builder.Length - MAX_LENGTH); + builder.Delete(MAX_LENGTH, builder.Length - MAX_LENGTH); } cachedString = null; } diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/Nysiis.cs b/src/Lucene.Net.Analysis.Phonetic/Language/Nysiis.cs index b5a436564c..eb850f0be1 100644 --- a/src/Lucene.Net.Analysis.Phonetic/Language/Nysiis.cs +++ b/src/Lucene.Net.Analysis.Phonetic/Language/Nysiis.cs @@ -1,4 +1,6 @@ // commons-codec version compatibility level: 1.9 + +using J2N.Text; using Lucene.Net.Support; using System; using System.Text; @@ -317,7 +319,7 @@ public virtual string GetNysiis(string str) if (lastChar == 'S') { //key.deleteCharAt(key.length() - 1); - key.Remove(key.Length - 1, 1); + key.Delete(key.Length - 1, 1); lastChar = key[key.Length - 1]; } @@ -328,7 +330,7 @@ public virtual string GetNysiis(string str) if (last2Char == 'A' && lastChar == 'Y') { //.key.deleteCharAt(key.length() - 2); - key.Remove(key.Length - 2, 1); + key.Delete(key.Length - 2, 1); } } @@ -336,7 +338,7 @@ public virtual string GetNysiis(string str) if (lastChar == 'A') { //key.deleteCharAt(key.length() - 1); - key.Remove(key.Length - 1, 1); + key.Delete(key.Length - 1, 1); } } diff --git a/src/Lucene.Net.Analysis.SmartCn/Hhmm/HHMMSegmenter.cs b/src/Lucene.Net.Analysis.SmartCn/Hhmm/HHMMSegmenter.cs index d263a256d4..96171ca50d 100644 --- a/src/Lucene.Net.Analysis.SmartCn/Hhmm/HHMMSegmenter.cs +++ b/src/Lucene.Net.Analysis.SmartCn/Hhmm/HHMMSegmenter.cs @@ -1,4 +1,5 @@ // lucene version compatibility level: 4.8.1 + using System.Collections.Generic; using System.Text; @@ -60,9 +61,9 @@ private static SegGraph CreateSegGraph(string sentence) // LUCENENET: CA1822: Ma case CharType.HANZI: j = i + 1; //wordBuf.delete(0, wordBuf.length()); - wordBuf.Remove(0, wordBuf.Length); - // It doesn't matter if a single Chinese character (Hanzi) can form a phrase or not, - // it will store that single Chinese character (Hanzi) in the SegGraph. Otherwise, it will + wordBuf.Clear(); + // It doesn't matter if a single Chinese character (Hanzi) can form a phrase or not, + // it will store that single Chinese character (Hanzi) in the SegGraph. Otherwise, it will // cause word division. wordBuf.Append(sentence[i]); charArray = new char[] { sentence[i] }; @@ -93,8 +94,8 @@ private static SegGraph CreateSegGraph(string sentence) // LUCENENET: CA1822: Ma charArray = new char[wordBuf.Length]; //wordBuf.GetChars(0, charArray.Length, charArray, 0); wordBuf.CopyTo(0, charArray, 0, charArray.Length); - // idArray has been found (foundWordIndex!=-1) as a prefix before. - // Therefore, idArray after it has been lengthened can only appear after foundWordIndex. + // idArray has been found (foundWordIndex!=-1) as a prefix before. + // Therefore, idArray after it has been lengthened can only appear after foundWordIndex. // So start searching after foundWordIndex. foundIndex = wordDict.GetPrefixMatch(charArray, foundIndex); j++; diff --git a/src/Lucene.Net.Analysis.Stempel/Egothor.Stemmer/Diff.cs b/src/Lucene.Net.Analysis.Stempel/Egothor.Stemmer/Diff.cs index 90ae4530c7..7f82e94cae 100644 --- a/src/Lucene.Net.Analysis.Stempel/Egothor.Stemmer/Diff.cs +++ b/src/Lucene.Net.Analysis.Stempel/Egothor.Stemmer/Diff.cs @@ -1,4 +1,5 @@ -using Lucene; +using J2N.Text; +using Lucene; using Lucene.Net.Support; using System; using System.Text; @@ -149,7 +150,7 @@ public static void Apply(StringBuilder dest, string diff) // String s = orig.toString(); // s = s.substring( 0, pos ) + s.substring( o + 1 ); // orig = new StringBuffer( s ); - dest.Remove(pos, (o + 1) - pos); + dest.Delete(pos, (o + 1) - pos); break; case 'I': dest.Insert(pos += 1, param); diff --git a/src/Lucene.Net.Tests.Highlighter/VectorHighlight/AbstractTestCase.cs b/src/Lucene.Net.Tests.Highlighter/VectorHighlight/AbstractTestCase.cs index 80d9fbb5e5..b283a5e52b 100644 --- a/src/Lucene.Net.Tests.Highlighter/VectorHighlight/AbstractTestCase.cs +++ b/src/Lucene.Net.Tests.Highlighter/VectorHighlight/AbstractTestCase.cs @@ -311,7 +311,7 @@ internal bool GetNextSnippet() { startTerm = 0; startOffset = nextStartOffset; - snippetBuffer.Remove(0, snippetBuffer.Length); + snippetBuffer.Clear(); while (true) { if (ch != -1) diff --git a/src/Lucene.Net.Tests/Search/TestSearchWithThreads.cs b/src/Lucene.Net.Tests/Search/TestSearchWithThreads.cs index a05e4758d8..184317bbed 100644 --- a/src/Lucene.Net.Tests/Search/TestSearchWithThreads.cs +++ b/src/Lucene.Net.Tests/Search/TestSearchWithThreads.cs @@ -74,7 +74,7 @@ public virtual void Test() } body.SetStringValue(sb.ToString()); w.AddDocument(doc); - sb.Remove(0, sb.Length); + sb.Clear(); } IndexReader r = w.GetReader(); w.Dispose(); diff --git a/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs b/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs index 55465090b3..be4eed98c7 100644 --- a/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs +++ b/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs @@ -1,4 +1,5 @@ using J2N.Collections.Generic.Extensions; +using J2N.Text; using J2N.Threading.Atomic; using Lucene.Net.Diagnostics; using Lucene.Net.Index.Extensions; @@ -1307,7 +1308,7 @@ public void Generate(IList @out, StringBuilder b, char from, char to, in { b.Append(c); Generate(@out, b, from, c == to ? to : from, depth - 1); - b.Remove(b.Length - 1, 1);//remove last char + b.Delete(b.Length - 1, 1);//remove last char } } } diff --git a/src/Lucene.Net/Index/ParallelAtomicReader.cs b/src/Lucene.Net/Index/ParallelAtomicReader.cs index faa7f454ba..bc64902bec 100644 --- a/src/Lucene.Net/Index/ParallelAtomicReader.cs +++ b/src/Lucene.Net/Index/ParallelAtomicReader.cs @@ -1,4 +1,5 @@ using J2N.Runtime.CompilerServices; +using J2N.Text; using Lucene.Net.Support; using Lucene.Net.Support.Threading; using System; @@ -181,7 +182,7 @@ public override string ToString() if (removeLastCommaSpace) { - buffer.Remove(buffer.Length - 2, 2); + buffer.Delete(buffer.Length - 2, 2); } return buffer.Append(')').ToString(); @@ -372,4 +373,4 @@ public override void CheckIntegrity() } } } -} \ No newline at end of file +} diff --git a/src/Lucene.Net/Search/Payloads/PayloadNearQuery.cs b/src/Lucene.Net/Search/Payloads/PayloadNearQuery.cs index 558b27f9ed..5673fcfce6 100644 --- a/src/Lucene.Net/Search/Payloads/PayloadNearQuery.cs +++ b/src/Lucene.Net/Search/Payloads/PayloadNearQuery.cs @@ -1,3 +1,4 @@ +using J2N.Text; using System; using System.Collections.Generic; using System.Text; @@ -96,7 +97,7 @@ public override string ToString(string field) } if (hasCommaSpace) - buffer.Remove(buffer.Length - 2, 2); + buffer.Delete(buffer.Length - 2, 2); buffer.Append("], "); buffer.Append(m_slop);