public string ENNamespaceToPrefix(string en) { var allParts = new CogniPy.CNL.EN.EnName() { id = en }.Split(); if (!System.String.IsNullOrWhiteSpace(allParts.term) && allParts.term.StartsWith("<") && allParts.term.EndsWith(">")) { var nss = allParts.term.Substring(1, allParts.term.Length - 2); if (nss == _defaultNamespace) // remove if the namespace is the default one. { allParts.term = null; } else { var tterm = _ns2pfx(nss); if (!System.String.IsNullOrWhiteSpace(tterm)) { allParts.term = tterm; } } } return(allParts.Combine().id); }
public string DL(string en, CogniPy.CNL.EN.endict.WordKind wkrd = CogniPy.CNL.EN.endict.WordKind.NormalForm) { if (en.StartsWith("a ") || en.StartsWith("an ")) { en = en.Split(' ').Last(); } var allParts = new CogniPy.CNL.EN.EnName() { id = en }.Split(); if (!System.String.IsNullOrWhiteSpace(allParts.term) && !allParts.term.Contains("<")) { var tterm = getPfx2NsSource(allParts.term); if (!System.String.IsNullOrWhiteSpace(tterm)) { allParts.term = "<" + tterm + ">"; } else { throw new Exception("No namespace found for prefix " + allParts.term + ". You need to define it before saving into Ontorion."); } } else if (!System.String.IsNullOrWhiteSpace(allParts.term) && allParts.term.StartsWith("<") && allParts.term.EndsWith(">")) { var tterm = CogniPy.CNL.CNLTools.GetCanonicalNs(allParts.term.Substring(1, allParts.term.Length - 2)); // string without < and > allParts.term = "<" + tterm + ">"; } else //add the default namespace { var defaultNs = _defaultNamespace; allParts.term = string.Format("<{0}>", defaultNs); } return(CogniPy.CNL.EN.ENNameingConvention.ToDL(allParts.Combine(), wkrd).id); }