本文整理汇总了C#中CharArraySet.AddAll方法的典型用法代码示例。如果您正苦于以下问题:C# CharArraySet.AddAll方法的具体用法?C# CharArraySet.AddAll怎么用?C# CharArraySet.AddAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharArraySet
的用法示例。
在下文中一共展示了CharArraySet.AddAll方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CapitalizationFilterFactory
internal readonly bool forceFirstLetter; // make sure the first letter is capital even if it is in the keep list
/// <summary>
/// Creates a new CapitalizationFilterFactory </summary>
public CapitalizationFilterFactory(IDictionary<string, string> args)
: base(args)
{
assureMatchVersion();
bool ignoreCase = getBoolean(args, KEEP_IGNORE_CASE, false);
HashSet<string> k = getSet(args, KEEP);
if (k != null)
{
keep = new CharArraySet(luceneMatchVersion, 10, ignoreCase);
keep.AddAll(k);
}
k = getSet(args, OK_PREFIX);
if (k != null)
{
okPrefix = new List<char[]>();
foreach (string item in k)
{
okPrefix.Add(item.ToCharArray());
}
}
minWordLength = getInt(args, MIN_WORD_LENGTH, 0);
maxWordCount = getInt(args, MAX_WORD_COUNT, CapitalizationFilter.DEFAULT_MAX_WORD_COUNT);
maxTokenLength = getInt(args, MAX_TOKEN_LENGTH, CapitalizationFilter.DEFAULT_MAX_TOKEN_LENGTH);
onlyFirstWord = getBoolean(args, ONLY_FIRST_WORD, true);
forceFirstLetter = getBoolean(args, FORCE_FIRST_LETTER, true);
if (args.Count > 0)
{
throw new System.ArgumentException("Unknown parameters: " + args);
}
}
示例2: TestNonZeroOffset
public virtual void TestNonZeroOffset()
{
string[] words = new string[] { "Hello", "World", "this", "is", "a", "test" };
char[] findme = "xthisy".ToCharArray();
CharArraySet set = new CharArraySet(TEST_VERSION_CURRENT, 10, true);
set.AddAll(words);
assertTrue(set.Contains(findme, 1, 4));
assertTrue(set.Contains(new string(findme, 1, 4)));
// test unmodifiable
set = CharArraySet.UnmodifiableSet(set);
assertTrue(set.Contains(findme, 1, 4));
assertTrue(set.Contains(new string(findme, 1, 4)));
}
示例3: GetWordSet
/// <summary>
/// Returns as <seealso cref="CharArraySet"/> from wordFiles, which
/// can be a comma-separated list of filenames
/// </summary>
protected internal CharArraySet GetWordSet(ResourceLoader loader, string wordFiles, bool ignoreCase)
{
assureMatchVersion();
IList<string> files = splitFileNames(wordFiles);
CharArraySet words = null;
if (files.Count > 0)
{
// default stopwords list has 35 or so words, but maybe don't make it that
// big to start
words = new CharArraySet(luceneMatchVersion, files.Count * 10, ignoreCase);
foreach (string file in files)
{
var wlist = getLines(loader, file.Trim());
words.AddAll(StopFilter.makeStopSet(luceneMatchVersion, wlist, ignoreCase));
}
}
return words;
}
示例4: MakeStopSet
/// <summary></summary>
/// <param name="stopWords">An array of stopwords</param>
/// <param name="ignoreCase">If true, all words are lower cased first.</param>
/// <returns> a Set containing the words</returns>
public static ISet<string> MakeStopSet(string[] stopWords, bool ignoreCase)
{
var stopSet = new CharArraySet(stopWords.Length, ignoreCase);
stopSet.AddAll(stopWords);
return stopSet;
}
示例5: TestClear
public virtual void TestClear()
{
var set = new CharArraySet(TEST_VERSION_CURRENT, 10, true);
set.AddAll(TEST_STOP_WORDS);
assertEquals("Not all words added", TEST_STOP_WORDS.Length, set.size());
set.Clear();
assertEquals("not empty", 0, set.size());
for (var i = 0; i < TEST_STOP_WORDS.Length; i++)
{
assertFalse(set.Contains(TEST_STOP_WORDS[i]));
}
set.AddAll(TEST_STOP_WORDS);
assertEquals("Not all words added", TEST_STOP_WORDS.Length, set.size());
for (var i = 0; i < TEST_STOP_WORDS.Length; i++)
{
assertTrue("Set doesn't contain " + TEST_STOP_WORDS[i], set.Contains(TEST_STOP_WORDS[i]));
}
}
示例6: TestUnmodifiableSet
public virtual void TestUnmodifiableSet()
{
var set = new CharArraySet(TEST_VERSION_CURRENT, 10, true);
set.AddAll(TEST_STOP_WORDS);
set.Add(Convert.ToInt32(1));
int size = set.size();
set = CharArraySet.UnmodifiableSet(set);
assertEquals("Set size changed due to unmodifiableSet call", size, set.size());
foreach (var stopword in TEST_STOP_WORDS)
{
assertTrue(set.Contains(stopword));
}
assertTrue(set.Contains(Convert.ToInt32(1)));
assertTrue(set.Contains("1"));
assertTrue(set.Contains(new[] { '1' }));
try
{
CharArraySet.UnmodifiableSet(null);
fail("can not make null unmodifiable");
}
catch (System.ArgumentNullException) // NOTE: In .NET we throw an ArgumentExcpetion, not a NullReferenceExeption
{
// expected
}
}
示例7: TestModifyOnUnmodifiable
public virtual void TestModifyOnUnmodifiable()
{
CharArraySet set = new CharArraySet(TEST_VERSION_CURRENT, 10, true);
set.AddAll(TEST_STOP_WORDS);
int size = set.size();
set = CharArraySet.UnmodifiableSet(set);
assertEquals("Set size changed due to unmodifiableSet call", size, set.size());
string NOT_IN_SET = "SirGallahad";
assertFalse("Test String already exists in set", set.Contains(NOT_IN_SET));
try
{
set.Add(NOT_IN_SET.ToCharArray());
fail("Modified unmodifiable set");
}
catch (System.NotSupportedException)
{
// expected
assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
assertEquals("Size of unmodifiable set has changed", size, set.size());
}
try
{
set.add(NOT_IN_SET);
fail("Modified unmodifiable set");
}
catch (System.NotSupportedException)
{
// expected
assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
assertEquals("Size of unmodifiable set has changed", size, set.size());
}
try
{
set.Add(new StringBuilder(NOT_IN_SET));
fail("Modified unmodifiable set");
}
catch (System.NotSupportedException)
{
// expected
assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
assertEquals("Size of unmodifiable set has changed", size, set.size());
}
try
{
set.clear();
fail("Modified unmodifiable set");
}
catch (System.NotSupportedException)
{
// expected
assertFalse("Changed unmodifiable set", set.contains(NOT_IN_SET));
assertEquals("Size of unmodifiable set has changed", size, set.size());
}
try
{
set.add(NOT_IN_SET);
fail("Modified unmodifiable set");
}
catch (System.NotSupportedException)
{
// expected
assertFalse("Test String has been added to unmodifiable set", set.contains(NOT_IN_SET));
assertEquals("Size of unmodifiable set has changed", size, set.size());
}
// NOTE: This results in a StackOverflow exception. Since this is not a public member of CharArraySet,
// but an extension method for the test fixture (which apparently has a bug), this test is non-critical
//// This test was changed in 3.1, as a contains() call on the given Collection using the "correct" iterator's
//// current key (now a char[]) on a Set<String> would not hit any element of the CAS and therefor never call
//// remove() on the iterator
//try
//{
// set.removeAll(new CharArraySet(TEST_VERSION_CURRENT, TEST_STOP_WORDS, true));
// fail("Modified unmodifiable set");
//}
//catch (System.NotSupportedException)
//{
// // expected
// assertEquals("Size of unmodifiable set has changed", size, set.size());
//}
#region Added for better .NET support
// This test was added for .NET to check the Remove method, since the extension method
// above fails to execute.
try
{
#pragma warning disable 612, 618
set.Remove(TEST_STOP_WORDS[0]);
#pragma warning restore 612, 618
fail("Modified unmodifiable set");
}
catch (System.NotSupportedException)
{
// expected
assertEquals("Size of unmodifiable set has changed", size, set.size());
}
//.........这里部分代码省略.........
示例8: StopAnalyzer
static StopAnalyzer()
{
{
var stopWords = new System.String[]{"a", "an", "and", "are", "as", "at", "be", "but", "by", "for", "if", "in", "into", "is", "it", "no", "not", "of", "on", "or", "such", "that", "the", "their", "then", "there", "these", "they", "this", "to", "was", "will", "with"};
var stopSet = new CharArraySet(stopWords.Length, false);
stopSet.AddAll(stopWords);
ENGLISH_STOP_WORDS_SET = CharArraySet.UnmodifiableSet(stopSet);
}
}