本文整理汇总了C#中ErrorSet.GetSeverityCount方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorSet.GetSeverityCount方法的具体用法?C# ErrorSet.GetSeverityCount怎么用?C# ErrorSet.GetSeverityCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorSet
的用法示例。
在下文中一共展示了ErrorSet.GetSeverityCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: Build
public ErrorSet Build(string moduleDataName, Stream outputStream, bool isEnableValidate, string formatGuid)
{
////#region Check arguments
if (string.IsNullOrEmpty(moduleDataName))
{
throw new ArgumentNullException("dataName");
}
if (outputStream == null)
{
throw new ArgumentNullException("outputStream");
}
////#endregion
ErrorSet errorSet = new ErrorSet();
ErrorSet subErrorSet = new ErrorSet();
try
{
switch (moduleDataName)
{
case ModuleDataName.PhoneSet:
TtsPhoneSet phoneSet = (TtsPhoneSet)GetObject(RawDataName.PhoneSet, errorSet);
if (!errorSet.Contains(ErrorSeverity.MustFix))
{
errorSet.Merge(PhoneSetCompiler.Compile(phoneSet, outputStream));
}
break;
case ModuleDataName.BackendPhoneSet:
phoneSet = (TtsPhoneSet)GetObject(RawDataName.BackendPhoneSet, errorSet);
if (!errorSet.Contains(ErrorSeverity.MustFix))
{
errorSet.Merge(PhoneSetCompiler.Compile(phoneSet, outputStream));
}
break;
case ModuleDataName.PosSet:
TtsPosSet posSet = (TtsPosSet)GetObject(RawDataName.PosSet, errorSet);
if (!errorSet.Contains(ErrorSeverity.MustFix))
{
errorSet.Merge(PosSetCompiler.Compile(posSet, outputStream));
}
break;
case ModuleDataName.PosTaggerPos:
LexicalAttributeSchema schema = (LexicalAttributeSchema)GetObject(
RawDataName.LexicalAttributeSchema, subErrorSet);
MergeDependencyError(errorSet, subErrorSet, _schemaFullName);
if (!subErrorSet.Contains(ErrorSeverity.MustFix))
{
TtsPosSet postaggingPosSet = TtsPosSet.LoadPosTaggingPosFromSchema(schema);
errorSet.Merge(PosSetCompiler.CompilePosTaggerPos(postaggingPosSet, outputStream));
}
break;
case ModuleDataName.Lexicon:
errorSet = CompileLexicon(outputStream);
break;
case ModuleDataName.CharTable:
ErrorSet charTableErrorSet = CompileCharTable(outputStream);
if (!isEnableValidate)
{
foreach (Error error in charTableErrorSet.Errors)
{
error.Severity = ErrorSeverity.Warning;
}
}
errorSet.Merge(charTableErrorSet);
break;
case ModuleDataName.SentenceSeparator:
string sentSepDataDir = _dataHandlerList.Datas[RawDataName.SentenceSeparatorDataPath].Path;
Collection<string> compiledSentenceSeparatorFiles = new Collection<string>();
errorSet = SentenceSeparatorCompiler.Compile(sentSepDataDir, outputStream, compiledSentenceSeparatorFiles);
if (errorSet.GetSeverityCount(ErrorSeverity.MustFix) == 0 &&
compiledSentenceSeparatorFiles.Count > 0)
{
errorSet.Add(ReportCompiledFiles("sentence separator", compiledSentenceSeparatorFiles));
}
break;
case ModuleDataName.WordBreaker:
{
System.IO.MemoryStream memStream = new MemoryStream();
string wordBreakerDataDir = _dataHandlerList.Datas[RawDataName.WordBreakerDataPath].Path;
Collection<string> compiledWordBreakerFiles = new Collection<string>();
errorSet = WordBreakerCompiler.Compile(wordBreakerDataDir, outputStream, compiledWordBreakerFiles, formatGuid);
if (errorSet.GetSeverityCount(ErrorSeverity.MustFix) == 0 && compiledWordBreakerFiles.Count > 0)
{
errorSet.Add(ReportCompiledFiles("word breaker", compiledWordBreakerFiles));
}
}
//.........这里部分代码省略.........