public ExtensionImpl(IBundle bundle, XExtension metadata) { this.metadata = metadata; this.owner = bundle; this.point = metadata.Point; this.data = ParseExtensionData(metadata.ToString()); }
public HashSet <String> GetKeysForExtension(XExtension extension) { HashSet <XAttribute> extensionCollection = GetAttributesForExtension(extension); HashSet <string> keySet = new HashSet <string>(); foreach (XAttribute attribute in extensionCollection) { keySet.Add(attribute.Key); } return(keySet); }
/// <summary> /// Static helper method for extracting all extensions from an attribute map. /// </summary> /// <returns>The set of extensions in the attribute map.</returns> /// <param name="attributeMap"> The attribute map from which to extract extensions.</param> public static HashSet <XExtension> ExtractExtensions(IXAttributeMap attributeMap) { HashSet <XExtension> extensions = new HashSet <XExtension>(); foreach (XAttribute attribute in attributeMap.Values) { XExtension extension = attribute.Extension; if (extension != null) { extensions.Add(extension); } } return(extensions); }
public HashSet <XAttribute> GetAttributesForExtension(XExtension extension) { if (extension == null) { return(GetAttributesWithoutExtension()); } HashSet <XAttribute> extensionSet = this.extensionMap[extension]; if (extensionSet == null) { extensionSet = new HashSet <XAttribute>(); } return(extensionSet); }
public dictNatData(Langs natLang, dictCrsData crsData) { this.crsData = crsData; this.natLang = natLang; foreach (DictEntryType type in crsData.options.lingeaOnly ? XExtension.Create(DictEntryType.lingeaOld) : crsData.options.dictTypes) { switch (type) { case DictEntryType.lingeaOld: string fn = Machines.rootPath + string.Format(@"RwDicts\Sources\LingeaOld\{1}_{0}.xml", crsData.crsLang, natLang); if (!File.Exists(fn)) { continue; } var dict = XmlUtils.FileToObject <DictObj>(fn); //provazani hesla se zvukem foreach (var en in dict.entries) { foreach (var snd in en.entry.Descendants("sound")) { if (snd.Value.StartsWith("@")) { string url; if (!crsData.sounds.TryGetValue(snd.Value.Substring(1), out url)) { continue; } snd.Value = url; } } } addDictEntries(dict.entries); break; default: throw new NotImplementedException(); } } }
List <ILookup <string, DictEntryObj> > sourcesLower = new List <ILookup <string, DictEntryObj> >(); //tabulka case unsenzitive headword => hesla public XElement findEntry(string word, Action <XElement> modifySoundTag = null) { foreach (var w in crsData.getWordsForms(XExtension.Create(word))) { DictEntryObj dictEntry = find(w.Value); if (dictEntry == null) { continue; } string key = DictFoundRes.getKey(dictEntry.type, dictEntry.entryId); var snd = dictEntry.entry.Descendants("sound").FirstOrDefault(); if (modifySoundTag != null && snd != null) { modifySoundTag(snd); } else if (snd != null && snd.Value.StartsWith("@")) { snd.Remove(); } return(dictEntry.entry); } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="T:OpenXesNet.model.XAttributeID"/> class. /// </summary> /// <param name="key">The key of the attribute.</param> /// <param name="value">Value of the attribute.</param> /// <param name="extension">The extension of the attribute.</param> public XAttributeID(string key, XID value, XExtension extension) : base(key, extension) { this.Value = value; }
/// <summary> /// Initializes a new instance of the <see cref="T:OpenXesNet.model.XAttributeList"/> class. /// </summary> /// <param name="key">The attribute key.</param> /// <param name="extension">The attribute extension.</param> public XAttributeList(string key, XExtension extension) : base(key, extension) { this.collection = new List <XAttribute>(); }
/// <summary> /// Initializes a new instance of the <see cref="T:OpenXesNet.model.XAttributeContainer"/> class. /// </summary> /// <param name="key">Key of the attribute.</param> /// <param name="extension">The extension for this attribute.</param> public XAttributeContainer(string key, XExtension extension) : base(key, extension) { this.collection = null; }
/// <summary> /// Initializes a new instance of the <see cref="T:OpenXesNet.model.XAttributeLiteral"/> class. /// </summary> /// <param name="key">The key of the attribute.</param> /// <param name="value">The value of the attribute.</param> /// <param name="extension">The extension of the attribute.</param> public XAttributeLiteral(string key, string value, XExtension extension) : base(key, extension) { this.Value = value; }
public override IXLog Parse(Stream stream) { Stack <IXAttributable> attributableStack = new Stack <IXAttributable>(); Stack <XAttribute> attributeStack = new Stack <XAttribute>(); IXEvent evt = null; IXLog log = null; IXTrace trace = null; List <XAttribute> globals = null; using (XmlReader reader = XmlReader.Create(stream)) { List <string> ATTR_TYPE_TAGS = new List <string>(new string[] { "string", "date", "int", "float", "boolean", "id", "list", "container" }); ATTR_TYPE_TAGS.Sort(); while (reader.Read()) { if (reader.IsStartElement()) { // start tag found string tagName = reader.LocalName.Trim(); if (tagName.Length == 0) { tagName = reader.Name.Trim(); // <= qualified name } if (ATTR_TYPE_TAGS.Contains(tagName.ToLower())) { // The tag is an attribute string key = reader.GetAttribute("key") ?? ""; string val = reader.GetAttribute("value") ?? ""; XExtension ext = null; int colonindex = key.IndexOf(":", StringComparison.InvariantCultureIgnoreCase); if (colonindex > 0) { string prefix = key.Substring(0, colonindex); ext = XExtensionManager.Instance.GetByPrefix(prefix); } XAttribute attr = null; switch (tagName) { case "string": attr = factory.CreateAttributeLiteral(key, val, ext); break; case "int": attr = factory.CreateAttributeDiscrete(key, long.Parse(val), ext); break; case "boolean": attr = factory.CreateAttributeBoolean(key, bool.Parse(val), ext); break; case "date": DateTime d = XAttributeTimestamp.Parse(val); attr = factory.CreateAttributeTimestamp(key, d, ext); break; case "float": attr = factory.CreateAttributeContinuous(key, double.Parse(val), ext); break; case "id": attr = factory.CreateAttributeID(key, XID.Parse(val), ext); break; case "list": attr = factory.CreateAttributeList(key, ext); break; case "container": attr = factory.CreateAttributeContainer(key, ext); break; default: XLogging.Log("Unknown tag '" + tagName + "'", XLogging.Importance.WARNING); break; } if (reader.IsEmptyElement) { // No child nodes, we can directly store it if (globals != null) { // attribute is global globals.Add(attr); } else { attributableStack.Peek().GetAttributes().Add(attr.Key, attr); if ((!(attributeStack.Count == 0)) && (attributeStack.Peek() is XAttributeCollection)) { ((XAttributeCollection)attributeStack.Peek()).AddToCollection(attr); } } } else if (attr != null) { attributeStack.Push(attr); attributableStack.Push((IXAttributable)attr); } } else if ("event".Equals(tagName.ToLower())) { // Parse an event evt = factory.CreateEvent(); attributableStack.Push(evt); } else if ("trace".Equals(tagName.ToLower())) { trace = factory.CreateTrace(); attributableStack.Push(trace); } else if ("log".Equals(tagName.ToLower())) { log = factory.CreateLog(); ((XLog)log).Version = reader.GetAttribute("xes.version") ?? "2.0"; ((XLog)log).Features = reader.GetAttribute("xes.features") ?? ""; attributableStack.Push(log); } else if ("extension".Equals(tagName.ToLower())) { XExtension extension = null; String uriString = reader.GetAttribute("uri"); if (uriString != null) { extension = XExtensionManager.Instance.GetByUri(new UriBuilder(uriString).Uri); } else { string prefixString = reader.GetAttribute("prefix"); if (prefixString != null) { extension = XExtensionManager.Instance.GetByPrefix(prefixString); } } if (extension != null) { log.Extensions.Add(extension); } else { XLogging.Log("Unknown extension: " + uriString, XLogging.Importance.ERROR); } } else if ("global".Equals(tagName.ToLower())) { string scope = reader.GetAttribute("scope"); if (scope.Equals("trace")) { globals = log.GlobalTraceAttributes; } else if (scope.Equals("event")) { globals = log.GlobalEventAttributes; } } else if ("classifier".Equals(tagName.ToLower())) { string name = reader.GetAttribute("name"); string keys = reader.GetAttribute("keys"); if ((name == null) || (keys == null) || (name.Length <= 0) || (keys.Length <= 0)) { continue; } IList <string> keysList = FixKeys(log, XTokenHelper.ExtractTokens(keys)); string[] keysArray = new string[keysList.Count]; int i = 0; foreach (string key in keysList) { keysArray[(i++)] = key; } IXEventClassifier classifier = new XEventAttributeClassifier(name, keysArray); log.Classifiers.Add(classifier); } } else { // end tag found string tagName = reader.LocalName.Trim().ToLower(); if (tagName.Length == 0) { tagName = reader.Name.Trim().ToLower(); // <= qualified name } if ("global".Equals(tagName)) { globals = null; } else if (ATTR_TYPE_TAGS.Contains(tagName)) { XAttribute attribute = attributeStack.Pop(); attributableStack.Pop(); if (globals != null) { globals.Add(attribute); } else { attributableStack.Peek().GetAttributes().Add(attribute.Key, attribute); if ((!(attributeStack.Count == 0)) && (attributeStack.Peek() is XAttributeCollection)) { ((XAttributeCollection)attributeStack.Peek()).AddToCollection(attribute); } } } else if ("event".Equals(tagName)) { trace.Add(evt); evt = null; attributableStack.Pop(); } else if ("trace".Equals(tagName)) { log.Add(trace); trace = null; attributableStack.Pop(); } else if ("log".Equals(tagName)) { attributableStack.Pop(); } } } } return(log); }
public XAttributeTimestamp CreateAttributeTimestamp(string key, long millis, XExtension extension) { return(new XAttributeTimestamp(key, millis, extension)); }
/// <summary> /// Initializes a new instance of the <see cref="T:OpenXesNet.model.XAttributeCollection"/> class. /// </summary> /// <param name="key">The key of this attribute.</param> /// <param name="extension">The extension of the attribute.</param> protected XAttributeCollection(string key, XExtension extension) : base(key, "", extension) { }
/// <summary> /// Last call made when visiting an extension. /// </summary> /// <param name="ext">The extension to visit.</param> /// <param name="log">The log containing the extension.</param> public abstract void VisitExtensionPost(XExtension ext, XLog log);
public XAttributeBoolean CreateAttributeBoolean(string key, bool value, XExtension extension) { return(new XAttributeBoolean(key, value, extension)); }
public XAttributeContinuous CreateAttributeContinuous(string key, double value, XExtension extension) { return(new XAttributeContinuous(key, value, extension)); }
public XAttributeContainer CreateAttributeContainer(string key, XExtension extension) { return(new XAttributeContainer(key, extension)); }
public XAttributeList CreateAttributeList(string key, XExtension extension) { return(new XAttributeList(key, extension)); }
public XAttributeID CreateAttributeID(string key, XID value, XExtension extension) { return(new XAttributeID(key, value, extension)); }
protected XAttribute(string key, XExtension extension) : base(key, extension) { }
public XAttributeLiteral CreateAttributeLiteral(string key, string value, XExtension extension) { return(new XAttributeLiteral(key, value, extension)); }
/// <summary> /// Initializes a new instance of the <see cref="T:OpenXesNet.model.XAttributeBoolean"/> class. /// </summary> /// <param name="key">The key of the attribute.</param> /// <param name="value">Value of the attribute.</param> /// <param name="extension">The extension of the attribute.</param> public XAttributeBoolean(string key, bool value, XExtension extension) : base(key, extension) { this.value = value; }
/// <summary> /// Initializes a new instance of the <see cref="T:OpenXesNet.model.XAttributeTimestamp"/> class. /// </summary> /// <param name="key">The key of the attribute.</param> /// <param name="millis">Value of the attribute, in milliseconds.</param> /// <param name="extension">The extension of the attribute.</param> public XAttributeTimestamp(string key, long millis, XExtension extension) : this(key, new DateTime(millis), extension) { }
ILookup <string, string> forms; //tabulka Ohyb => zakladni tvary public Dictionary <string, List <string> > getWordsForms(IEnumerable <string> words) //words jsou ohyby, ke kterym se hleda heslo. Da k nim sebe, sebe.toLowerCase a zakladni tvary { return(words.ToDictionary(w => w, w => XExtension.Create(w, w.ToLower()).Concat(forms[w]).Distinct().ToList())); }
/// <summary> /// Initializes a new instance of the <see cref="T:OpenXesNet.model.XAttributeDiscrete"/> class. /// </summary> /// <param name="key">The key of the attribute.</param> /// <param name="value">Value of the attribute.</param> /// <param name="extension">The extension of the attribute.</param> public XAttributeDiscrete(string key, long value, XExtension extension) : base(key, extension) { this.value = value; }
public XAttributeDiscrete CreateAttributeDiscrete(string key, long value, XExtension extension) { return(new XAttributeDiscrete(key, value, extension)); }
/// <summary> /// Initializes a new instance of the <see cref="T:OpenXesNet.model.XAttributeContinuous"/> class. /// </summary> /// <param name="key">The key of the attribute.</param> /// <param name="value">Value of the attribute.</param> /// <param name="extension">The extension of the attribute.</param> public XAttributeContinuous(string key, double value, XExtension extension) : base(key, extension) { this.value = value; }
public XAttributeTimestamp CreateAttributeTimestamp(string key, DateTime value, XExtension extension) { return(new XAttributeTimestamp(key, value, extension)); }
/// <summary> /// Initializes a new instance of the <see cref="T:OpenXesNet.model.XAttributeTimestamp"/> class. /// </summary> /// <param name="key">The key of the attribute.</param> /// <param name="value">Value of the attribute.</param> /// <param name="extension">The extension of the attribute.</param> public XAttributeTimestamp(string key, DateTime value, XExtension extension) : base(key, extension) { Value = value; }
/// <summary> /// Composes the appropriate attribute type from the string-based information /// found, e.g., in XML serializations. /// </summary> /// <returns>An appropriate attribute.</returns> /// <param name="factory">Factory to use for creating the attribute.</param> /// <param name="key">Key of the attribute.</param> /// <param name="value">Value of the attribute.</param> /// <param name="type">Type string of the attribute.</param> /// <param name="extension">Extension of the attribute (can be <code>null</code>).</param> public static XAttribute ComposeAttribute(IXFactory factory, string key, string value, string type, XExtension extension) { type = type.Trim(); if (type.Equals("LIST", StringComparison.CurrentCultureIgnoreCase)) { XAttributeList attr = factory.CreateAttributeList(key, extension); return(attr); } if (type.Equals("CONTAINER", StringComparison.CurrentCultureIgnoreCase)) { XAttributeContainer attr = factory.CreateAttributeContainer(key, extension); return(attr); } if (type.Equals("LITERAL", StringComparison.CurrentCultureIgnoreCase)) { XAttributeLiteral attr = factory.CreateAttributeLiteral(key, value, extension); return(attr); } if (type.Equals("BOOLEAN", StringComparison.CurrentCultureIgnoreCase)) { XAttributeBoolean attr = factory.CreateAttributeBoolean(key, bool.Parse(value), extension); return(attr); } if (type.Equals("CONTINUOUS", StringComparison.CurrentCultureIgnoreCase)) { XAttributeContinuous attr = factory.CreateAttributeContinuous(key, double.Parse(value), extension); return(attr); } if (type.Equals("DISCRETE", StringComparison.CurrentCultureIgnoreCase)) { XAttributeDiscrete attr = factory.CreateAttributeDiscrete(key, long.Parse(value), extension); return(attr); } if (type.Equals("TIMESTAMP", StringComparison.CurrentCultureIgnoreCase)) { IXAttributeTimestamp attr; try { attr = factory.CreateAttributeTimestamp(key, DateTime.Parse(value), extension); } catch (FormatException) { throw new InvalidOperationException("OpenXES: could not parse date-time attribute. Value: " + value); } return((XAttributeTimestamp)attr); } if (type.Equals("ID", StringComparison.CurrentCultureIgnoreCase)) { XAttributeID attr = factory.CreateAttributeID(key, XID.Parse(value), extension); return(attr); } throw new InvalidOperationException("OpenXES: could not parse attribute type!"); }