当前位置: 首页>>代码示例>>C#>>正文


C# ErrorSet.GetSeverityCount方法代码示例

本文整理汇总了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;
        }
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:61,代码来源:PolyphonyRuleFile.cs

示例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));
                            }
                        }

//.........这里部分代码省略.........
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:101,代码来源:LangDataCompiler.cs


注:本文中的ErrorSet.GetSeverityCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。