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


C# ErrorSet.AddRange方法代码示例

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

示例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;
        }
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:61,代码来源:PolyphonyRuleFile.cs

示例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;
        }
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:101,代码来源:PolyphonyRuleFile.cs

示例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;
        }
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:29,代码来源:PosCorpus.cs


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