Indexnumber parsing disabled

This commit is contained in:
Simon Martens
2023-09-16 15:43:11 +02:00
parent f054c8913d
commit d86d508786
58 changed files with 447 additions and 297 deletions

View File

@@ -10,8 +10,8 @@ public class LetterDescNode : INodeRule
Documents = new[] { "metadaten" },
XPath = "//letterDesc"
};
public string[]? Attributes { get; } = { "ref" };
public string? uniquenessAttribute => "ref" ;
public string[]? Attributes { get; } = { "letter" };
public string? uniquenessAttribute => "letter" ;
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
};

View File

@@ -10,8 +10,8 @@ public class LetterTextNode : INodeRule
Documents = new[] { "brieftext" },
XPath = "//letterText"
};
public string[]? Attributes { get; } = { "index" };
public string? uniquenessAttribute => "index" ;
public string[]? Attributes { get; } = { "letter" };
public string? uniquenessAttribute => "letter" ;
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
};

View File

@@ -10,8 +10,8 @@ public class LetterTraditionNode : INodeRule
Documents = new[] { "ueberlieferung" },
XPath = "//letterTradition"
};
public string[]? Attributes { get; } = { "ref" };
public string? uniquenessAttribute => "ref" ;
public string[]? Attributes { get; } = { "letter" };
public string? uniquenessAttribute => "letter" ;
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
};

View File

@@ -10,8 +10,8 @@ public class MarginalNode : INodeRule
Documents = new[] { "stellenkommentar" },
XPath = "//marginal"
};
public string[]? Attributes { get; } = { "index", "letter", "page", "line" };
public string? uniquenessAttribute => "index";
public string[]? Attributes { get; } = { "letter", "page", "line" };
public string? uniquenessAttribute { get; }
public List<(string, HamannXPath, string)>? References { get; } = new List<(string, HamannXPath, string)>()
{
};

View File

@@ -16,7 +16,7 @@ public class StructureCollection : ICollectionRule {
public IEnumerable<(string, XElement, XMLRootDocument)> GenerateIdentificationStrings(IEnumerable<(XElement, XMLRootDocument)> list) {
foreach (var e in list) {
var id = e.Item1.Name == "letterText" ? e.Item1.Attribute("index")!.Value : e.Item1.Attribute("ref")!.Value;
var id = e.Item1.Attribute("letter")!.Value;
var currpage = String.Empty;
var currline = String.Empty;
foreach (var el in e.Item1.Descendants()) {

View File

@@ -233,7 +233,7 @@ public class TextRules {
{
if(reader.State.ParsedMarginals == null) reader.State.ParsedMarginals = new List<(string, string, string)>();
var sb2 = new StringBuilder();
margs = margs.OrderBy(x => Int32.Parse(x.Index));
if (margs.Count() > 1) margs = margs.OrderBy(x => Int32.Parse(x.Sort));
sb.Append(HaWeb.HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT, CSSClasses.COMMENTMARKERCLASS, "ma-" + reader.State.currpage + "-" + reader.State.currline));
sb.Append(HaWeb.HTMLHelpers.TagHelpers.CreateEndElement(DEFAULTELEMENT));
sb.Append(HaWeb.HTMLHelpers.TagHelpers.CreateElement(DEFAULTELEMENT, CSSClasses.MARGINGALBOXCLASS));

View File

@@ -14,24 +14,26 @@ public class BackLinkCollection : HaWeb.XMLParser.IXMLCollection {
public bool Searchable { get; } = true;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var margid = (string?)elem.Ancestors("marginal").First().Attribute("index");
if (String.IsNullOrWhiteSpace(margid)) return null;
return margid + _random.Next().ToString();
var letter = (string?)elem.Attribute("letter");
var page = (string?)elem.Attribute("page");
var line = (string?)elem.Attribute("line");
if (letter == null) return null;
var index = letter + "-" + page ?? "" + "-" + line ?? "";
if (String.IsNullOrWhiteSpace(index)) return null;
return index + _random.Next().ToString();
};
public static IDictionary<string, string>? GetDataFields(XElement element) {
var res = new Dictionary<string, string>();
var marg = element.Ancestors("marginal").First();
var index = (string?)marg.Attribute("index");
var letter = (string?)marg.Attribute("letter");
var page = (string?)marg.Attribute("page");
var line = (string?)marg.Attribute("line");
var refere = (string?)element.Attribute("ref");
var subref = (string?)element.Attribute("subref");
if (index == null || letter == null || (refere == null && subref == null)) return null;
if (letter == null || (refere == null && subref == null)) return null;
if (subref != null) res.Add("ref", subref);
else res.Add("ref", refere!);
res.Add("index", index);
res.Add("letter", letter);
if (page != null) res.Add("page", page);
if (line != null) res.Add("line", line);

View File

@@ -22,9 +22,9 @@ public static class CommentCollectionHelpers {
public static IDictionary<string, ILookup<string, CollectedItem>>? GetLookups(IEnumerable<CollectedItem> items) {
var res = new Dictionary<string, ILookup<string, CollectedItem>>();
var lemmas = items.Where(x => !String.IsNullOrWhiteSpace(x.Index));
var lemmas = items.Where(x => !String.IsNullOrWhiteSpace(x.ID));
if (lemmas != null && lemmas.Any())
res.Add("lemma", lemmas.ToLookup(x => x.Index.Substring(0, 1).ToUpper()));
res.Add("lemma", lemmas.ToLookup(x => x.ID.Substring(0, 1).ToUpper()));
// If we use lemmas
// var lemmas = items.Where(x => x.Fields != null && x.Fields.ContainsKey("lemma"));
// if (lemmas != null && lemmas.Any())

View File

@@ -13,7 +13,7 @@ public class LetterCollection : HaWeb.XMLParser.IXMLCollection {
public bool Searchable { get; } = true;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
var index = elem.Attribute("letter");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
else return null;

View File

@@ -13,9 +13,14 @@ public class MarginalCollection : HaWeb.XMLParser.IXMLCollection {
public bool Searchable { get; } = true;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("index");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
var letter = (string?)elem.Attribute("letter");
var page = (string?)elem.Attribute("page");
var line = (string?)elem.Attribute("line");
var sort = (string?)elem.Attribute("sort");
if (letter == null || page == null || line == null) return null;
var index = letter + "-" + page + "-" + line + sort ?? "";
if (index != null && !String.IsNullOrWhiteSpace(index))
return index;
else return null;
};
@@ -24,10 +29,12 @@ public class MarginalCollection : HaWeb.XMLParser.IXMLCollection {
var letter = (string?)element.Attribute("letter");
var page = (string?)element.Attribute("page");
var line = (string?)element.Attribute("line");
var sort = (string?)element.Attribute("sort");
if (letter == null || page == null || line == null) return null;
res.Add("letter", letter);
res.Add("page", page);
res.Add("line", line);
if (sort != null) res.Add("sort", sort);
return res;
}

View File

@@ -13,7 +13,7 @@ public class MetaCollection : HaWeb.XMLParser.IXMLCollection {
public bool Searchable { get; } = false;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("ref");
var index = elem.Attribute("letter");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
return null;

View File

@@ -13,7 +13,7 @@ public class TraditionCollection : HaWeb.XMLParser.IXMLCollection {
public bool Searchable { get; } = true;
public static Func<XElement, string?> GetKey { get; } = (elem) => {
var index = elem.Attribute("ref");
var index = elem.Attribute("letter");
if (index != null && !String.IsNullOrWhiteSpace(index.Value))
return index.Value;
return null;