本文整理汇总了C#中ErrorSet类的典型用法代码示例。如果您正苦于以下问题:C# ErrorSet类的具体用法?C# ErrorSet怎么用?C# ErrorSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ErrorSet类属于命名空间,在下文中一共展示了ErrorSet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Read
/// <summary>
/// Load stemmer file.
/// </summary>
/// <param name="stemmerFilePath">Stemmer file path.</param>
/// <param name="errorSet">Error set.</param>
/// <returns>Loaded stemmer items.</returns>
public static Dictionary<string, string> Read(string stemmerFilePath,
ErrorSet errorSet)
{
Dictionary<string, string> stemmer = new Dictionary<string, string>();
foreach (string line in Helper.FileLines(stemmerFilePath))
{
string[] items = line.Split(Delimitor.TabChars, StringSplitOptions.RemoveEmptyEntries);
if (items.Length < 2)
{
errorSet.Add(StemmerFileError.OneColumnLine, line, stemmerFilePath);
continue;
}
for (int i = 1; i < items.Length; i++)
{
if (stemmer.ContainsKey(items[i]))
{
// Skips this one if there already has it.
continue;
}
stemmer.Add(items[i], items[0]);
}
}
return stemmer;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:33,代码来源:StemmerFile.cs
示例2: Compile
/// <summary>
/// Compiles quotation mark table into binary stream.
/// </summary>
/// <param name="quoteTable">The instance of quotation mark table.</param>
/// <param name="outputStream">The instance of output binary stream.</param>
/// <returns>Any error found during the compilation.</returns>
public static ErrorSet Compile(QuotationMarkTable quoteTable, Stream outputStream)
{
if (quoteTable == null)
{
throw new ArgumentNullException("quoteTable");
}
if (outputStream == null)
{
throw new ArgumentNullException("outputStream");
}
ErrorSet errorSet = new ErrorSet();
BinaryWriter writer = new BinaryWriter(outputStream);
writer.Write((uint)quoteTable.Language);
writer.Write((uint)quoteTable.Items.Count);
foreach (var item in quoteTable.Items)
{
writer.Write((ushort)item.Left);
writer.Write((ushort)item.Right);
writer.Write((uint)item.Direct);
}
return errorSet;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:32,代码来源:QuotationMarkCompiler.cs
示例3: ValidateCompoundRule
/// <summary>
/// Validate compound rule file.
/// </summary>
/// <param name="filePath">Compound rule file path.</param>
/// <param name="phoneset">TTS phone set.</param>
/// <returns>ErrorSet.</returns>
public static ErrorSet ValidateCompoundRule(string filePath, TtsPhoneSet phoneset)
{
// Validate parameter
if (string.IsNullOrEmpty(filePath))
{
throw new ArgumentNullException("filePath");
}
if (!File.Exists(filePath))
{
throw Helper.CreateException(typeof(FileNotFoundException), filePath);
}
ErrorSet errorSet = new ErrorSet();
using (XmlTextReader xmlTextReader = new XmlTextReader(filePath))
{
while (xmlTextReader.Read())
{
if (xmlTextReader.NodeType == XmlNodeType.Element &&
xmlTextReader.Name == "out")
{
if (xmlTextReader.Read() && xmlTextReader.NodeType == XmlNodeType.Text)
{
ValidateCompoundRuleNodePron(xmlTextReader.Value.Trim(),
phoneset, xmlTextReader.LineNumber, errorSet);
}
}
}
}
return errorSet;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:38,代码来源:DataFileValidator.cs
示例4: LoadDataObject
/// <summary>
/// Load Lexicon Data object.
/// </summary>
/// <param name="errorSet">ErrorSet.</param>
/// <returns>Lexicon Data object.</returns>
internal override object LoadDataObject(ErrorSet errorSet)
{
Lexicon lexicon = new Lexicon(this.Language);
Lexicon.ContentControler lexiconControler = new Lexicon.ContentControler();
lexiconControler.IsCaseSensitive = true;
lexicon.Load(this.Path, lexiconControler);
return lexicon;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:13,代码来源:DataConfiguration.cs
示例5: AstHelper
public AstHelper(ModuleBuilder moduleBuilder)
{
ModuleBuilder = moduleBuilder;
Expecting = new Expecting();
Functions = new FunctionScope();
Variables = new VariableScope();
Types = new TypeScope();
Errors = new ErrorSet();
ReturnScope = new ReturnScope();
}
开发者ID:dayanruben,项目名称:TigerConverters,代码行数:11,代码来源:AstHelper.cs
示例6: Compile
/// <summary>
/// Compiler.
/// </summary>
/// <param name="mapFileName">Path of phoneme mapping file.</param>
/// <param name="sourceAsId">Whether source phone is phone id, to converted into int.</param>
/// <param name="outputStream">Output Stream.</param>
/// <returns>ErrorSet.</returns>
public static ErrorSet Compile(string mapFileName, bool sourceAsId, Stream outputStream)
{
if (string.IsNullOrEmpty(mapFileName))
{
throw new ArgumentNullException("mapFileName");
}
if (outputStream == null)
{
throw new ArgumentNullException("outputStream");
}
ErrorSet errorSet = new ErrorSet();
PhonemeMap phonemeMap = new PhonemeMap();
phonemeMap.LoadXml(mapFileName);
// Convert SAPI phoneme string
if (sourceAsId)
{
ConvertSourcePhoneID(phonemeMap.Pairs);
}
phonemeMap.Sort();
// Write the binary mapping file
BinaryWriter writer = new BinaryWriter(outputStream);
{
// Write number of phoneme mapping tables
writer.Write(1);
byte[] data = phonemeMap.ToBytes();
writer.Write(data.Length);
writer.Write(data);
}
return errorSet;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:43,代码来源:PhonemeMapCompiler.cs
示例7: Compile
/// <summary>
/// Compiler.
/// </summary>
/// <param name="truncRuleFileName">File path of trunc rule.</param>
/// <param name="phoneSet">Phone set.</param>
/// <param name="outputStream">Output Stream.</param>
/// <returns>ErrorSet.</returns>
public static ErrorSet Compile(string truncRuleFileName,
TtsPhoneSet phoneSet, Stream outputStream)
{
if (string.IsNullOrEmpty(truncRuleFileName))
{
throw new ArgumentNullException("truncRuleFileName");
}
// pauseLengthFileName could be null
if (phoneSet == null)
{
throw new ArgumentNullException("phoneSet");
}
if (outputStream == null)
{
throw new ArgumentNullException("outputStream");
}
ErrorSet errorSet = new ErrorSet();
phoneSet.Validate();
if (phoneSet.ErrorSet.Contains(ErrorSeverity.MustFix))
{
errorSet.Add(UnitGeneratorDataCompilerError.InvalidPhoneSet);
}
else
{
BinaryWriter bw = new BinaryWriter(outputStream);
{
errorSet.Merge(CompTruncRuleData(truncRuleFileName, phoneSet, bw));
}
}
return errorSet;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:42,代码来源:UnitGeneratorDataCompiler.cs
示例8: CompTruncRuleData
/// <summary>
/// Compile the trunc rule into binary writer.
/// </summary>
/// <param name="truncRuleFileName">File path of trunc rule.</param>
/// <param name="phoneSet">Phone set.</param>
/// <param name="bw">Binary writer.</param>
/// <returns>Error.</returns>
private static ErrorSet CompTruncRuleData(string truncRuleFileName, TtsPhoneSet phoneSet, BinaryWriter bw)
{
// maximum truncate rule length is 5 phonmes currently
const int MaxTruncRuleLength = 5;
ErrorSet errorSet = new ErrorSet();
List<TruncateNucleusRule> rules = new List<TruncateNucleusRule>();
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(truncRuleFileName);
XmlNamespaceManager nm = new XmlNamespaceManager(xmldoc.NameTable);
nm.AddNamespace("tts", "http://schemas.microsoft.com/tts/toolsuite");
XmlNodeList nodeList = xmldoc.DocumentElement.SelectNodes(
"/tts:offline/tts:truncateRules/tts:truncateRule", nm);
if (nodeList != null)
{
foreach (XmlNode node in nodeList)
{
XmlNodeList phoneNodeList;
XmlElement xmlNode = node as XmlElement;
string side = xmlNode.GetAttribute("side");
int direction = 0;
if (side.Equals("Right", StringComparison.OrdinalIgnoreCase))
{
direction = 2; // TruncFromRight
}
else if (side.Equals("Left", StringComparison.OrdinalIgnoreCase))
{
direction = 1; // TruncFromLeft
}
else
{
errorSet.Add(UnitGeneratorDataCompilerError.WrongRuleSide,
side, xmlNode.InnerXml);
}
phoneNodeList = xmlNode.SelectNodes("tts:phone", nm);
if (phoneNodeList.Count > MaxTruncRuleLength)
{
errorSet.Add(UnitGeneratorDataCompilerError.RuleLengthExceeded,
MaxTruncRuleLength.ToString(CultureInfo.InvariantCulture), xmlNode.InnerXml);
}
else
{
int idx = 0;
short[] ids = new short[MaxTruncRuleLength + 1];
foreach (XmlNode phoneNode in phoneNodeList)
{
XmlElement xmlPhoneNode = phoneNode as XmlElement;
string phoneValue = xmlPhoneNode.GetAttribute("value");
Phone phone = phoneSet.GetPhone(phoneValue);
if (phone != null)
{
ids[idx++] = (short)phone.Id;
}
else
{
errorSet.Add(UnitGeneratorDataCompilerError.InvalidPhone, phoneValue);
}
}
ids[idx] = 0;
TruncateNucleusRule rule = new TruncateNucleusRule();
rule.Ids = ids;
rule.Direction = direction;
rules.Add(rule);
}
}
}
// write the data
bw.Write(rules.Count);
foreach (TruncateNucleusRule ci in rules)
{
bw.Write(ci.Direction);
for (int i = 0; i < ci.Ids.Length; i++)
{
bw.Write(BitConverter.GetBytes(ci.Ids[i]));
}
}
return errorSet;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:92,代码来源:UnitGeneratorDataCompiler.cs
示例9: AddParseError
/// <summary>
/// AddParseError.
/// </summary>
/// <param name="errorSet">ErrorSet.</param>
/// <param name="lineNum">LineNum.</param>
/// <param name="parseErrorSet">ParseErrorSet.</param>
private void AddParseError(ErrorSet errorSet, int lineNum, ErrorSet parseErrorSet)
{
foreach (Error parseError in parseErrorSet.Errors)
{
Error error = new Error(PolyRuleError.ParseError, parseError,
lineNum.ToString(CultureInfo.InvariantCulture));
// Keep the same severity with the original error severity.
error.Severity = parseError.Severity;
errorSet.Add(error);
}
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:18,代码来源:PolyphonyRuleFile.cs
示例10: Validate
/// <summary>
/// Data validation.
/// </summary>
/// <param name="language">Language.</param>
/// <returns>Data error set found.</returns>
public ErrorSet Validate(Language language)
{
// Files existance validation
if (!Directory.Exists(Dir))
{
throw Helper.CreateException(typeof(DirectoryNotFoundException),
Dir);
}
if (!File.Exists(ScriptFilePath))
{
throw Helper.CreateException(typeof(FileNotFoundException),
ScriptFilePath);
}
if (!File.Exists(FileMapFilePath))
{
throw Helper.CreateException(typeof(FileNotFoundException),
FileMapFilePath);
}
if (!File.Exists(UnitFeatureFilePath))
{
throw Helper.CreateException(typeof(FileNotFoundException),
UnitFeatureFilePath);
}
ErrorSet errorSet = new ErrorSet();
ErrorSet subErrorSet =
FindUnmatchedSentences(ScriptFilePath, language, FileMapFilePath);
errorSet.Merge(subErrorSet);
subErrorSet = ValidateFeatureData(UnitFeatureFilePath, ScriptFilePath,
language);
errorSet.Merge(subErrorSet);
return errorSet;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:44,代码来源:FontCompilerConfig.cs
示例11: ValidateFeatureData
/// <summary>
/// Validation data alignment between feature file and script file.
/// </summary>
/// <param name="featureFile">Feature file.</param>
/// <param name="scriptFile">Script file.</param>
/// <param name="language">Language.</param>
/// <returns>Data error set found.</returns>
public static ErrorSet ValidateFeatureData(string featureFile,
string scriptFile, Language language)
{
ErrorSet errorSet = new ErrorSet();
TtsPhoneSet phoneSet = Localor.GetPhoneSet(language);
XmlScriptValidateSetting validateSetting = new XmlScriptValidateSetting(phoneSet, null);
XmlScriptFile script = XmlScriptFile.LoadWithValidation(scriptFile, validateSetting);
if (script.ErrorSet.Count > 0)
{
string message = string.Format(CultureInfo.InvariantCulture,
"{0} error(s) found in the script file [{1}]",
script.ErrorSet.Count, scriptFile);
throw new InvalidDataException(message);
}
XmlUnitFeatureFile unitFeatureFile = new XmlUnitFeatureFile(featureFile);
if (unitFeatureFile.Units.Count <= 0)
{
string message = string.Format(CultureInfo.InvariantCulture,
"Zero unit feature item in unit feature file {0}", featureFile);
errorSet.Add(VoiceFontError.OtherErrors, message);
throw new InvalidDataException(message);
}
if (unitFeatureFile.Language != language)
{
string message = string.Format(CultureInfo.InvariantCulture,
"Different lanuage\r\nScript File {0}: lang = {1}\r\n Feature File {2}: lang = {3}",
scriptFile, Localor.LanguageToString(language),
featureFile, Localor.LanguageToString(unitFeatureFile.Language));
throw new InvalidDataException(message);
}
foreach (string key in unitFeatureFile.Units.Keys)
{
UnitFeature unit = unitFeatureFile.Units[key];
string sid = unit.SentenceId;
int unitIndex = unit.Index;
string unitName = unit.Name;
if (unit.Index < 0)
{
string message = string.Format(CultureInfo.InvariantCulture,
"invalid unit index [{0}] found in feature file [{1}]. It should not be negative integer for unit indexing.",
unit.Index, featureFile);
errorSet.Add(VoiceFontError.OtherErrors, message);
continue;
}
try
{
if (!script.ItemDic.ContainsKey(unit.SentenceId))
{
string message = string.Format(CultureInfo.InvariantCulture,
"sentence id {0} in feature file [{1}] is not in script file [{2}]",
sid, featureFile, scriptFile);
errorSet.Add(ScriptError.OtherErrors, sid, message);
continue;
}
ScriptItem item = script.ItemDic[sid];
Phoneme phoneme = Localor.GetPhoneme(language);
SliceData sliceData = Localor.GetSliceData(language);
Collection<TtsUnit> itemUnits = item.GetUnits(phoneme, sliceData);
if (unitIndex >= itemUnits.Count)
{
string message = string.Format(CultureInfo.InvariantCulture,
"the {0}th unit [{1}] in sentence {2} of feature file [{3}] is out of range for sentence {2} in script file [{4}]",
unitIndex, unitName, sid, featureFile, scriptFile);
errorSet.Add(ScriptError.OtherErrors, sid, message);
continue;
}
TtsUnit ttsUnit = itemUnits[unitIndex];
string sliceName = ttsUnit.FullName.Replace(' ', '+');
if (sliceName != unitName)
{
string str1 = "the {0}th unit [{1}] in sentence {3} of feature file [{4}] ";
string str2 = "is not matched with {0}th unit [{2}] for sentence {3} in script file [{5}]";
string message = string.Format(CultureInfo.InvariantCulture,
str1 + str2,
unitIndex, unitName, sliceName, sid, featureFile, scriptFile);
errorSet.Add(ScriptError.OtherErrors, sid, message);
continue;
}
}
catch (InvalidDataException ide)
{
//.........这里部分代码省略.........
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:101,代码来源:FontCompilerConfig.cs
示例12: CreateParser
private CFlatTree CreateParser(string input, ErrorSet errorSet)
{
var antlrStringStream = new ANTLRStringStream(input);
var lexter = new CFlatLexer(antlrStringStream);
var tokens = new CommonTokenStream(lexter);
var parser = new CFlatParser(tokens);
var tree = parser.prog().Tree;
var nodes = new CommonTreeNodeStream(tree);
var walker = new CFlatTree(nodes, errorSet);
return walker;
}
开发者ID:adbrowne,项目名称:abcm,代码行数:14,代码来源:TypeTests.cs
示例13: Validate
/// <summary>
/// Validate char table.
/// </summary>
/// <param name="table">Char table.</param>
/// <param name="shallow">Shallow validation.</param>
/// <param name="wordsNotInLexicon">WordsNotInLexicon.</param>
/// <returns>ErrorSet.</returns>
public ErrorSet Validate(CharTable table,
bool shallow, Collection<string> wordsNotInLexicon)
{
if (table == null)
{
throw new ArgumentNullException("table");
}
ErrorSet errorSet = new ErrorSet();
int upperCaseNumber = 0;
int lowerCaseNumber = 0;
int digitNumber = 0;
Collection<string> symbols = new Collection<string>();
foreach (CharElement charElement in table.CharList)
{
if (charElement.Type == CharElement.CharType.UpperCase)
{
upperCaseNumber++;
}
else if (charElement.Type == CharElement.CharType.LowerCase)
{
lowerCaseNumber++;
}
else if (charElement.Type == CharElement.CharType.Digit)
{
digitNumber++;
}
if (!symbols.Contains(charElement.Symbol))
{
symbols.Add(charElement.Symbol);
}
else
{
errorSet.Add(new Error(CharTableError.DuplicateSymbol,
charElement.Symbol));
}
if (!shallow)
{
ValidateCharElement(charElement, errorSet, wordsNotInLexicon);
}
}
if (upperCaseNumber != lowerCaseNumber)
{
errorSet.Add(new Error(CharTableError.MismatchUpperAndLower,
upperCaseNumber.ToString(CultureInfo.InvariantCulture),
lowerCaseNumber.ToString(CultureInfo.InvariantCulture)));
}
if (digitNumber != 10)
{
errorSet.Add(new Error(CharTableError.ErrorDigitCount));
}
return errorSet;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:66,代码来源:CharTable.cs
示例14: GetObject
/// <summary>
/// Get the object.
/// </summary>
/// <param name="errorSet">ErrorSet.</param>
/// <returns>Object.</returns>
public object GetObject(ErrorSet errorSet)
{
if (errorSet == null)
{
throw new ArgumentNullException("errorSet");
}
if (!_processedLoad && _object == null)
{
_processedLoad = true;
if (string.IsNullOrEmpty(this.Path))
{
errorSet.Add(DataCompilerError.PathNotInitialized, this.Name);
}
else if (!File.Exists(this.Path))
{
errorSet.Add(DataCompilerError.RawDataNotFound, this.Name,
this.Path);
}
else
{
_object = LoadDataObject(errorSet);
}
}
else if (_processedLoad && _object == null)
{
errorSet.Add(DataCompilerError.RawDataError, this.Name);
}
return _object;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:36,代码来源:DataHandler.cs
示例15: allErrors
public static ErrorSet allErrors() {
ErrorSet ret = new ErrorSet(bwapiPINVOKE.allErrors(), false);
return ret;
}
开发者ID:albertouri,项目名称:emapf-starcraft-ai,代码行数:4,代码来源:bwapi.cs
示例16: ParsePolyCondition
/// <summary>
/// ParsePolyCondition.
/// </summary>
/// <param name="expression">Expression.</param>
/// <param name="condition">Condition.</param>
/// <param name="errorSet">ErrorSet.</param>
private void ParsePolyCondition(string expression,
PolyphonyCondition condition, ErrorSet errorSet)
{
string subExpression = expression;
// If the value is string, then search operator before """
if (subExpression.IndexOf('"') > 0)
{
subExpression = subExpression.Substring(0, subExpression.IndexOf('"'));
}
foreach (string oper in _allOperators)
{
if (subExpression.IndexOf(oper) >= 0)
{
condition.Operator = oper;
break;
}
}
bool succeeded = true;
if (string.IsNullOrEmpty(condition.Operator))
{
errorSet.Add(PolyRuleError.MissingOperatorInCondition,
expression);
succeeded = false;
}
if (succeeded)
{
condition.Key = expression.Substring(0,
expression.IndexOf(condition.Operator)).Trim();
if (!_keyTypes.ContainsKey(condition.Key))
{
errorSet.Add(PolyRuleError.NotDeclearedConditionKey,
condition.Key, expression);
succeeded = false;
}
}
if (succeeded)
{
string valueExpression = expression.Substring(
expression.IndexOf(condition.Operator) + condition.Operator.Length).Trim();
if (_keyTypes[condition.Key] == KeyType.String)
{
Match match = Regex.Match(valueExpression, @"^""(.*)""$");
if (match.Success)
{
valueExpression = match.Groups[1].ToString();
}
else
{
errorSet.Add(PolyRuleError.InvalidConditionFormat,
expression);
succeeded = false;
}
}
else
{
int intValue;
if (!int.TryParse(valueExpression, out intValue))
{
errorSet.Add(PolyRuleError.InvalidConditionFormat,
expression);
succeeded = false;
}
}
condition.Value = valueExpression;
}
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:78,代码来源:PolyphonyRuleFile.cs
示例17: TryParseKeyDeclear
/// <summary>
/// TryParseKeyDeclear.
/// </summary>
/// <param name="line">Line.</param>
/// <param name="firstKeyString">FirstKeyString.</param>
/// <param name="errorSet">ErrorSet.</param>
/// <returns>Whether the line is key declear line.</returns>
private bool TryParseKeyDeclear(string line,
ref bool firstKeyString, ErrorSet errorSet)
{
bool isKeyDeclearLine = false;
// No need check key declear after finish parsing the declear part.
if (IsDeclearKey(line))
{
isKeyDeclearLine = true;
string keyName = string.Empty;
KeyType keyType = KeyType.String;
ParseDeclearKey(line, ref keyName, ref keyType);
if (_keyTypes.ContainsKey(keyName))
{
errorSet.Add(PolyRuleError.DuplicateKeyName, keyName);
}
else
{
_keyTypes.Add(keyName, keyType);
if (firstKeyString)
{
_keyString = keyName;
firstKeyString = false;
}
}
}
return isKeyDeclearLine;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:36,代码来源:PolyphonyRuleFile.cs
示例18: TryParseKeyLine
/// <summary>
/// TryParseKeyLine.
/// </summary>
/// <param name="line">Line.</param>
/// <param name="polyphonyWord">PolyphonyWord.</param>
/// <param name="errorSet">ErrorSet.</param>
/// <param name="domain">Domain.</param>
/// <returns>Whether the line is key line.</returns>
private bool TryParseKeyLine(string line, ref PolyphonyRule polyphonyWord,
ErrorSet errorSet, string domain)
{
bool isKeyLine = false;
if (IsKeyLine(line))
{
isKeyLine = true;
if (polyphonyWord != null)
{
if (polyphonyWord.PolyphonyProns.Count == 0)
{
errorSet.Add(PolyRuleError.NoConditionForWord, polyphonyWord.Word);
}
else
{
_polyphonyWords.Add(polyphonyWord);
}
}
polyphonyWord = new PolyphonyRule();
polyphonyWord.Domain = domain;
int errorCountBeforeParsing = errorSet.Errors.Count;
string keyValue = ParseKeyValueLine(line, errorSet);
if (errorSet.Errors.Count == errorCountBeforeParsing)
{
polyphonyWord.Word = keyValue;
}
}
return isKeyLine;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:41,代码来源:PolyphonyRuleFile.cs
示例19: 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
示例20: AppendNormalWord
/// <summary>
/// Appends a normal word in the end of given utterance.
/// </summary>
/// <param name="utterance">
/// The given utterance.
/// </param>
/// <param name="scriptWord">
/// The script word.
/// </param>
/// <returns>
/// The phoneme count of the given word.
/// </returns>
/// <exception cref="InvalidDataException">
/// Exception.
/// </exception>
private int AppendNormalWord(TtsUtterance utterance, ScriptWord scriptWord)
{
TtsWord word = utterance.AppendNewWord();
word.LangId = (ushort)scriptWord.Language;
word.BreakLevel = (TtsBreakLevel)scriptWord.Break;
word.Emphasis = (TtsEmphasis)scriptWord.Emphasis;
word.WordText = scriptWord.Grapheme;
word.NETypeText = scriptWord.NETypeText;
word.WordRegularText = scriptWord.RegularText;
word.WordType = TtsWordType.WT_NORMAL;
word.AcousticDomain = DomainExtension.MapToEnum(scriptWord.AcousticDomainTag);
word.WordExpansion = scriptWord.Expansion;
word.ReadablePronunciation = scriptWord.Pronunciation;
if (!string.IsNullOrEmpty(scriptWord.Pronunciation))
{
word.PhoneIds = Phoneme.PronunciationToPhoneIds(Pronunciation.RemoveUnitBoundary(scriptWord.Pronunciation));
}
if (NeedPos)
{
// Checks pos.
if (string.IsNullOrEmpty(scriptWord.PosString))
{
throw new InvalidDataException(
Helper.NeutralFormat("No POS found in sentence \"{0}\" for word \"{1}\"",
scriptWord.Sentence.ScriptItem.Id, scriptWord.Grapheme));
}
// Sets pos value.
word.Pos = (ushort)PosSet.Items[scriptWord.PosString];
string taggingPos = PosSet.CategoryTaggingPOS[scriptWord.PosString];
word.POSTaggerPos = (ushort)PosSet.Items[taggingPos];
}
// Gets the normal phoneme count.
ErrorSet errorSet = new ErrorSet();
int count = scriptWord.GetNormalPhoneNames(PhoneSet, errorSet).Count;
if (errorSet.Count > 0)
{
throw new InvalidDataException(
Helper.NeutralFormat("Invalid phone found in sentence \"{0}\" for word \"{1}\"",
scriptWord.Sentence.ScriptItem.Id, scriptWord.Grapheme));
}
word.TextOffset = (uint)scriptWord.OffsetInString;
word.TextLength = (uint)scriptWord.LengthInString;
return count;
}
开发者ID:JohnsonYuan,项目名称:TTSFramework,代码行数:64,代码来源:LinguisticFeatureExtractor.cs
注:本文中的ErrorSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论