|
@@ -24,11 +24,11 @@
|
|
|
{
|
|
|
Debug.Assert(!string.IsNullOrWhiteSpace(key), "'groupName' can't be null or empty.");
|
|
|
this.Key = key;
|
|
|
- this._synosyms = ImmutableArray.CreateBuilder<ISynosym>();
|
|
|
+ this._synonyms = ImmutableArray.CreateBuilder<ISynonym>();
|
|
|
}
|
|
|
|
|
|
|
|
|
- private readonly ImmutableArray<ISynosym>.Builder _synosyms;
|
|
|
+ private readonly ImmutableArray<ISynonym>.Builder _synonyms;
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
@@ -38,45 +38,45 @@
|
|
|
/// <param name="words">欲關聯至此物件的多個單字。若此群組物件不包含任何與此參數相關的單字,則使用此參數建立新同義詞實體。</param>
|
|
|
/// <param name="stringComparer">字串比對器。</param>
|
|
|
/// <exception cref="ArgumentNullException"/>
|
|
|
- public ISynosym AppendOrCreate(IEnumerable<string> words, StringComparer stringComparer = null)
|
|
|
+ public ISynonym AppendOrCreate(IEnumerable<string> words, StringComparer stringComparer = null)
|
|
|
{
|
|
|
if (words is null)
|
|
|
throw new ArgumentNullException(nameof(words));
|
|
|
|
|
|
//Console.WriteLine(string.Join(":", words));
|
|
|
|
|
|
- foreach (var synosym in this._synosyms)
|
|
|
+ foreach (var synonym in this._synonyms)
|
|
|
{
|
|
|
- if (synosym.Equals(words))
|
|
|
+ if (synonym.Equals(words))
|
|
|
{
|
|
|
- synosym.AddRange(words);
|
|
|
- return synosym;
|
|
|
+ synonym.AddRange(words);
|
|
|
+ return synonym;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var inst = new Synosym(this, stringComparer);
|
|
|
+ var inst = new Synonym(this, stringComparer);
|
|
|
inst.AddRange(words);
|
|
|
- this._synosyms.Add(inst);
|
|
|
+ this._synonyms.Add(inst);
|
|
|
return inst;
|
|
|
}
|
|
|
|
|
|
- public bool TryGetSynosym(string word, out ISynosym synosyms)
|
|
|
+ public bool TryGetSynonym(string word, out ISynonym synonyms)
|
|
|
{
|
|
|
- foreach (var synosym in this._synosyms)
|
|
|
+ foreach (var synonym in this._synonyms)
|
|
|
{
|
|
|
- if (synosym.Equals(word))
|
|
|
+ if (synonym.Equals(word))
|
|
|
{
|
|
|
- synosyms = synosym;
|
|
|
+ synonyms = synonym;
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
- synosyms = null;
|
|
|
+ synonyms = null;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public IImmutableList<ISynosym> ToImmutable()
|
|
|
+ public IImmutableList<ISynonym> ToImmutable()
|
|
|
{
|
|
|
- return this._synosyms.ToImmutable();
|
|
|
+ return this._synonyms.ToImmutable();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|