protected LoadException CreateUndefinedObjectException(string message, string id) { LoadException le = new LoadException(LoadException.LoadErrorType.UNDEFINED_OBJECT, this, message); le.Data["id"] = id; return(le); }
public virtual void Write(LoadException le) { m_out.WriteLine("Load Error: " + le.Message); m_out.WriteLine(); }
public virtual void Write(LoadException le) { m_xmlWriter.WriteElementString("LoadError", le.Message); }
public override void Write(LoadException le) { m_xmlWriter.WriteStartElement("Error"); switch (le.ErrorType) { case LoadException.LoadErrorType.INVALID_ENTRY_SHAPE: string entryShape = le.Data["shape"] as string; string entryId = le.Data["entry"] as string; SIL.HermitCrab.LexEntry entry = le.Loader.CurrentMorpher.Lexicon.GetEntry(entryId); m_xmlWriter.WriteString(string.Format(ParserCoreStrings.ksHCInvalidEntryShape, entryShape, entry.Description)); break; case LoadException.LoadErrorType.INVALID_RULE_SHAPE: string ruleShape = le.Data["shape"] as string; string ruleId = le.Data["rule"] as string; MorphologicalRule rule = le.Loader.CurrentMorpher.GetMorphologicalRule(ruleId); m_xmlWriter.WriteString(string.Format(ParserCoreStrings.ksHCInvalidRuleShape, ruleShape, rule.Description)); break; default: m_xmlWriter.WriteString(string.Format(ParserCoreStrings.ksHCDefaultErrorMsg, le.Message)); break; } m_xmlWriter.WriteEndElement(); }
protected LoadException CreateUndefinedObjectException(string message, string id) { LoadException le = new LoadException(LoadException.LoadErrorType.UNDEFINED_OBJECT, this, message); le.Data["id"] = id; return le; }
void LoadPSubrule(XmlElement psubruleNode, StandardPhonologicalRule prule, Dictionary<string, string> varFeatIds) { XmlElement structElem = psubruleNode.SelectSingleNode("PhonologicalSubruleStructure[@isActive='yes']") as XmlElement; PhoneticPattern rhs = new PhoneticPattern(true); LoadPSeq(rhs, structElem.SelectSingleNode("PhoneticOutput/PhoneticSequence") as XmlElement, prule.AlphaVariables, varFeatIds, null); Environment env = LoadEnv(structElem.SelectSingleNode("Environment"), prule.AlphaVariables, varFeatIds); StandardPhonologicalRule.Subrule sr = null; try { sr = new StandardPhonologicalRule.Subrule(rhs, env, prule); } catch (ArgumentException ae) { LoadException le = new LoadException(LoadException.LoadErrorType.INVALID_SUBRULE_TYPE, this, HCStrings.kstidInvalidSubruleType, ae); le.Data["rule"] = prule.ID; throw le; } sr.RequiredPOSs = LoadPOSs(psubruleNode.GetAttribute("requiredPartsOfSpeech")); sr.RequiredMPRFeatures = LoadMPRFeatures(psubruleNode.GetAttribute("requiredMPRFeatures")); sr.ExcludedMPRFeatures = LoadMPRFeatures(psubruleNode.GetAttribute("excludedMPRFeatures")); prule.AddSubrule(sr); }
void LoadAllomorph(XmlElement alloNode, LexEntry entry, Stratum stratum) { string alloId = alloNode.GetAttribute("id"); string shapeStr = alloNode.SelectSingleNode("PhoneticShape").InnerText; PhoneticShape shape = stratum.CharacterDefinitionTable.ToPhoneticShape(shapeStr, ModeType.SYNTHESIS); if (shape == null) { LoadException le = new LoadException(LoadException.LoadErrorType.INVALID_ENTRY_SHAPE, this, string.Format(HCStrings.kstidInvalidLexEntryShape, shapeStr, entry.ID, stratum.CharacterDefinitionTable.ID)); le.Data["shape"] = shapeStr; le.Data["charDefTable"] = stratum.CharacterDefinitionTable.ID; le.Data["entry"] = entry.ID; throw le; } LexEntry.RootAllomorph allomorph = new LexEntry.RootAllomorph(alloId, shapeStr, m_curMorpher, shape); allomorph.RequiredEnvironments = LoadEnvs(alloNode.SelectSingleNode("RequiredEnvironments")); allomorph.ExcludedEnvironments = LoadEnvs(alloNode.SelectSingleNode("ExcludedEnvironments")); allomorph.Properties = LoadProperties(alloNode.SelectSingleNode("Properties")); entry.AddAllomorph(allomorph); m_curMorpher.AddAllomorph(allomorph); }
IEnumerable<PhoneticPatternNode> LoadSegCtxts(XmlElement ctxtsNode) { CharacterDefinitionTable charDefTable = GetCharDefTable(ctxtsNode.GetAttribute("characterTable")); string shapeStr = ctxtsNode.SelectSingleNode("PhoneticShape").InnerText; PhoneticShape shape = charDefTable.ToPhoneticShape(shapeStr, ModeType.SYNTHESIS); if (shape == null) { LoadException le = new LoadException(LoadException.LoadErrorType.INVALID_RULE_SHAPE, this, string.Format(HCStrings.kstidInvalidPseqShape, shapeStr, charDefTable.ID)); le.Data["shape"] = shapeStr; le.Data["charDefTable"] = charDefTable.ID; throw le; } List<PhoneticPatternNode> nodes = new List<PhoneticPatternNode>(); for (PhoneticShapeNode node = shape.Begin; node != shape.Last; node = node.Next) { switch (node.Type) { case PhoneticShapeNode.NodeType.SEGMENT: nodes.Add(new SegmentContext(node as Segment)); break; case PhoneticShapeNode.NodeType.BOUNDARY: nodes.Add(new BoundaryContext(node as Boundary)); break; } } return nodes; }
List<MorphologicalOutput> LoadPhoneticOutput(XmlNode phonOutputNode, AlphaVariables varFeats, Dictionary<string, string> varFeatIds, Dictionary<string, int> partIds, string ruleId) { List<MorphologicalOutput> rhsList = new List<MorphologicalOutput>(); foreach (XmlNode partNode in phonOutputNode.ChildNodes) { if (partNode.NodeType != XmlNodeType.Element) continue; XmlElement partElem = partNode as XmlElement; switch (partElem.Name) { case "CopyFromInput": rhsList.Add(new CopyFromInput(partIds[partElem.GetAttribute("index")])); break; case "InsertSimpleContext": SimpleContext insCtxt = LoadNatClassCtxt(partElem.SelectSingleNode("SimpleContext") as XmlElement, varFeats, varFeatIds); rhsList.Add(new InsertSimpleContext(insCtxt)); break; case "ModifyFromInput": SimpleContext modCtxt = LoadNatClassCtxt(partElem.SelectSingleNode("SimpleContext") as XmlElement, varFeats, varFeatIds); rhsList.Add(new ModifyFromInput(partIds[partElem.GetAttribute("index")], modCtxt, m_curMorpher)); break; case "InsertSegments": CharacterDefinitionTable charDefTable = GetCharDefTable(partElem.GetAttribute("characterTable")); string shapeStr = partElem.SelectSingleNode("PhoneticShape").InnerText; PhoneticShape pshape = charDefTable.ToPhoneticShape(shapeStr, ModeType.SYNTHESIS); if (pshape == null) { LoadException le = new LoadException(LoadException.LoadErrorType.INVALID_RULE_SHAPE, this, string.Format(HCStrings.kstidInvalidRuleShape, shapeStr, ruleId, charDefTable.ID)); le.Data["shape"] = shapeStr; le.Data["charDefTable"] = charDefTable.ID; le.Data["rule"] = ruleId; throw le; } rhsList.Add(new InsertSegments(pshape)); break; } } return rhsList; }
private void HandleLoadException(LoadException le) { if (m_quitOnError) throw le; if (Output != null) { Output.Write(le); } }