本文整理汇总了C#中ErrorSet.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorSet.AddRange方法的具体用法?C# ErrorSet.AddRange怎么用?C# ErrorSet.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorSet
的用法示例。
在下文中一共展示了ErrorSet.AddRange方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryParseConditionLine
/// <summary>
/// TryParseConditionLine.
/// </summary>
/// <param name="line">Line.</param>
/// <param name="phoneSet">PhoneSet.</param>
/// <param name="polyphonyWord">PolyphonyWord.</param>
/// <param name="errorSet">ErrorSet.</param>
/// <returns>Whether the line is condition line.</returns>
private bool TryParseConditionLine(string line, TtsPhoneSet phoneSet,
PolyphonyRule polyphonyWord, ErrorSet errorSet)
{
bool isConditionLine = false;
if (IsConditionLine(line))
{
isConditionLine = true;
if (polyphonyWord == null)
{
errorSet.Add(PolyRuleError.MissKeyValueLine, line);
}
errorSet.AddRange(ParseConditionLine(line, phoneSet, polyphonyWord));
}
return isConditionLine;
}
示例2: ParseConditionLine
/// <summary>
/// ParseConditionLine.
/// </summary>
/// <param name="line">Line.</param>
/// <param name="phoneSet">PhoneSet.</param>
/// <param name="polyphonyWord">PolyphonyWord.</param>
/// <returns>ErrorSet.</returns>
private ErrorSet ParseConditionLine(string line, TtsPhoneSet phoneSet,
PolyphonyRule polyphonyWord)
{
ErrorSet errorSet = new ErrorSet();
Match match = Regex.Match(line, ConditionLineRegex);
if (match.Groups.Count < 3)
{
errorSet.Add(PolyRuleError.InvalidConditionFormat,
line);
}
else
{
PolyphonyPron polyphonyPron = new PolyphonyPron();
polyphonyPron.Pron = match.Groups[2].ToString().Trim();
// Allow empty pronunciation for polyphony rule.
if (!string.IsNullOrEmpty(polyphonyPron.Pron) && phoneSet != null)
{
errorSet.AddRange(Pronunciation.Validate(polyphonyPron.Pron, phoneSet));
}
string conditions = match.Groups[1].ToString().Trim();
bool hasMatched = false;
foreach (Match conditionMatch in Regex.Matches(conditions, ConditionRegex))
{
hasMatched = true;
string expression = conditionMatch.Value;
PolyphonyCondition condition = new PolyphonyCondition();
ParsePolyCondition(expression.Trim(), condition, errorSet);
polyphonyPron.Conditions.Add(condition);
}
if (hasMatched)
{
if (errorSet.GetSeverityCount(ErrorSeverity.MustFix) == 0)
{
if (polyphonyWord == null)
{
errorSet.Add(PolyRuleError.MissKeyValueLine, line);
}
else
{
polyphonyWord.PolyphonyProns.Add(polyphonyPron);
}
}
}
else
{
errorSet.Add(PolyRuleError.InvalidConditionFormat, line);
}
}
return errorSet;
}
示例3: Load
//.........这里部分代码省略.........
{
throw Helper.CreateException(typeof(FileNotFoundException), filePath);
}
if (!Helper.IsUnicodeFile(filePath))
{
throw new InvalidDataException(Helper.NeutralFormat(
"Polyphony rule file [{0}] is not unicode.", filePath));
}
ErrorSet errorSet = new ErrorSet();
_keyTypes.Clear();
bool finishReadHead = false;
bool firstKeyString = true;
PolyphonyRule polyphonyWord = null;
int lineNum = 0;
string domain = DomainItem.GeneralDomain;
foreach (string line in Helper.FileLines(filePath, Encoding.Unicode, false))
{
lineNum++;
string trimedLine = line.Trim();
if (string.IsNullOrEmpty(trimedLine))
{
continue;
}
if (IsComment(trimedLine))
{
continue;
}
if (IsDomainTag(trimedLine))
{
ParseDomainKey(trimedLine, ref domain);
continue;
}
ErrorSet parseErrorSet = new ErrorSet();
if (!finishReadHead)
{
bool isKeyDeclear = TryParseKeyDeclear(trimedLine,
ref firstKeyString, parseErrorSet);
AddParseError(errorSet, lineNum, parseErrorSet);
if (isKeyDeclear)
{
continue;
}
else
{
finishReadHead = true;
}
}
PolyruleKeys.Instance.KeyTypes = _keyTypes;
parseErrorSet.Clear();
bool isKeyLine = TryParseKeyLine(trimedLine,
ref polyphonyWord, parseErrorSet, domain);
domain = DomainItem.GeneralDomain;
AddParseError(errorSet, lineNum, parseErrorSet);
if (isKeyLine)
{
continue;
}
parseErrorSet.Clear();
bool isConditionLine = TryParseConditionLine(trimedLine, phoneSet,
polyphonyWord, parseErrorSet);
AddParseError(errorSet, lineNum, parseErrorSet);
if (isConditionLine)
{
continue;
}
errorSet.Add(PolyRuleError.InvalidLineFormat,
lineNum.ToString(CultureInfo.InvariantCulture), trimedLine);
}
if (polyphonyWord != null)
{
_polyphonyWords.Add(polyphonyWord);
}
if (string.IsNullOrEmpty(_keyString))
{
errorSet.Add(PolyRuleError.MissPrimaryKey,
filePath);
}
errorSet.AddRange(CheckDupWordDefinitions());
foreach (PolyphonyRule rule in _polyphonyWords)
{
errorSet.AddRange(rule.CheckDupRuleConditions());
}
return errorSet;
}
示例4: Parse
/// <summary>
/// Parse.
/// </summary>
/// <param name="line">Line.</param>
/// <param name="attributeSchema">LexicalAttributeSchema.</param>
/// <returns>ErrorSet.</returns>
public ErrorSet Parse(string line, LexicalAttributeSchema attributeSchema)
{
if (string.IsNullOrEmpty(line))
{
throw new ArgumentNullException("line");
}
ErrorSet errorSet = new ErrorSet();
_words.Clear();
string[] wordWithPosTags = line.Split(_wordDelimeters, StringSplitOptions.RemoveEmptyEntries);
foreach (string wordWithPosTag in wordWithPosTags)
{
PosCorpusWord word = new PosCorpusWord();
ErrorSet wordErrorSet = word.Parse(wordWithPosTag, attributeSchema);
errorSet.AddRange(wordErrorSet);
if (wordErrorSet.Count == 0)
{
_words.Add(word);
}
}
return errorSet;
}