mirror of
https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
synced 2025-10-29 17:25:32 +00:00
Moved unused code into Achive
This commit is contained in:
24
Archive/HaDocument/Models/Backlink.cs
Normal file
24
Archive/HaDocument/Models/Backlink.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Backlink {
|
||||
public string Index { get; } = "";
|
||||
|
||||
public string Letter { get; } = "";
|
||||
public string Page { get; } = "";
|
||||
public string Line { get; } = "";
|
||||
public string MarginalIndex { get; } = "";
|
||||
|
||||
public Backlink(
|
||||
string index,
|
||||
string letter,
|
||||
string page,
|
||||
string line,
|
||||
string marginalindex
|
||||
) {
|
||||
Index = index;
|
||||
Letter = letter;
|
||||
Page = page;
|
||||
Line = line;
|
||||
MarginalIndex = marginalindex;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
Archive/HaDocument/Models/Comment.cs
Normal file
36
Archive/HaDocument/Models/Comment.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace HaDocument.Models {
|
||||
public class Comment{
|
||||
public string Entry { get; } = "";
|
||||
public string Index { get; } = "";
|
||||
public string Type { get; } = "";
|
||||
public string Lemma { get; } = "";
|
||||
public string Parent { get; } = "";
|
||||
public int Order { get; } = -1;
|
||||
public ImmutableSortedDictionary<string, Comment> Kommentare { get; }
|
||||
|
||||
public Comment(
|
||||
string entry,
|
||||
string index,
|
||||
string type,
|
||||
string lemma,
|
||||
int order,
|
||||
SortedDictionary<string, Comment> subComments,
|
||||
string parent=""
|
||||
) {
|
||||
Entry = entry;
|
||||
Index = index;
|
||||
Type = type;
|
||||
Lemma = lemma;
|
||||
Order = order;
|
||||
Parent = parent;
|
||||
if (subComments != null)
|
||||
Kommentare = ImmutableSortedDictionary.ToImmutableSortedDictionary(subComments);
|
||||
else
|
||||
Kommentare = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Archive/HaDocument/Models/Editreason.cs
Normal file
32
Archive/HaDocument/Models/Editreason.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Editreason {
|
||||
public string Index { get; } = "";
|
||||
public string Element { get; } = "";
|
||||
public string Letter { get; } = "";
|
||||
public string StartPage { get; } = "";
|
||||
public string StartLine { get; } = "";
|
||||
public string EndPage { get; } = "";
|
||||
public string EndLine { get; } = "";
|
||||
public string Reference { get; } = "";
|
||||
|
||||
public Editreason(
|
||||
string index,
|
||||
string element,
|
||||
string letter = "",
|
||||
string startpage = "",
|
||||
string startline = "",
|
||||
string endpage = "",
|
||||
string endline = "",
|
||||
string reference = ""
|
||||
) {
|
||||
Index = index;
|
||||
Element = element;
|
||||
Letter = letter;
|
||||
StartPage = startpage;
|
||||
StartLine = startline;
|
||||
EndPage = endpage;
|
||||
EndLine = endline;
|
||||
Reference = reference;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Archive/HaDocument/Models/HaModel.cs
Normal file
15
Archive/HaDocument/Models/HaModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using HaXMLReader.EvArgs;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HaDocument.Models {
|
||||
public abstract class HaModel {
|
||||
protected static List<(Func<Tag, bool>, Action<Tag>)> FieldActions = null;
|
||||
|
||||
internal static void AddAction(Func<Tag, bool> If, Action<Tag> Then) {
|
||||
if (If == null || Then == null) throw new ArgumentNullException();
|
||||
if (FieldActions == null) FieldActions = new List<(Func<Tag, bool>, Action<Tag>)>();
|
||||
FieldActions.Add((If, Then));
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Archive/HaDocument/Models/Hand.cs
Normal file
26
Archive/HaDocument/Models/Hand.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Hand : HaModel {
|
||||
public string Letter { get; } = "";
|
||||
public string Person { get; } = "";
|
||||
public string StartPage { get; } = "";
|
||||
public string StartLine { get; } = "";
|
||||
public string EndPage { get; } = "";
|
||||
public string EndLine {get; } = "";
|
||||
|
||||
public Hand(
|
||||
string letter,
|
||||
string person,
|
||||
string startpage,
|
||||
string startline,
|
||||
string endpage,
|
||||
string endline
|
||||
) {
|
||||
Letter = letter;
|
||||
Person = person;
|
||||
StartPage = startpage;
|
||||
StartLine = startline;
|
||||
EndPage = endpage;
|
||||
EndLine = endline;
|
||||
}
|
||||
}
|
||||
}
|
||||
70
Archive/HaDocument/Models/IntermediateLibrary.cs
Normal file
70
Archive/HaDocument/Models/IntermediateLibrary.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System.Collections.Generic;
|
||||
using HaDocument.Interfaces;
|
||||
|
||||
namespace HaDocument.Models
|
||||
{
|
||||
public class IntermediateLibrary
|
||||
{
|
||||
public Dictionary<string, Tradition> Traditions;
|
||||
public Dictionary<string, Person> Persons;
|
||||
public Dictionary<string, Meta> Metas;
|
||||
public Dictionary<string, Marginal> Marginals;
|
||||
public Dictionary<string, Location> Locations;
|
||||
public Dictionary<string, Letter> Letters;
|
||||
public Dictionary<string, Person> HandPersons;
|
||||
public Dictionary<string, Editreason> Editreasons;
|
||||
public Dictionary<string, Comment> Comments;
|
||||
public Dictionary<string, List<Backlink>> Backlinks;
|
||||
public Dictionary<string, List<Hand>> Hands;
|
||||
|
||||
// Helper Library for precalculationg the Structure of the Document:
|
||||
public Dictionary<string, Dictionary<string, HashSet<string>>> LetterPageLines;
|
||||
|
||||
public Library GetLibrary(IHaDocumentOptions options)
|
||||
{
|
||||
var Structure = new Dictionary<string, Dictionary<string, Dictionary<string, string>>>();
|
||||
foreach (var letter in LetterPageLines)
|
||||
{
|
||||
if (Metas.ContainsKey(letter.Key) &&
|
||||
Metas[letter.Key].ZH != null)
|
||||
{
|
||||
if (!Structure.ContainsKey(Metas[letter.Key].ZH.Volume))
|
||||
{
|
||||
Structure.Add(Metas[letter.Key].ZH.Volume, new Dictionary<string, Dictionary<string, string>>());
|
||||
}
|
||||
foreach (var page in letter.Value)
|
||||
{
|
||||
if (!Structure[Metas[letter.Key].ZH.Volume].ContainsKey(page.Key))
|
||||
{
|
||||
Structure[Metas[letter.Key].ZH.Volume].Add(page.Key, new Dictionary<string, string>());
|
||||
}
|
||||
foreach (var line in page.Value)
|
||||
{
|
||||
if (!Structure[Metas[letter.Key].ZH.Volume][page.Key].ContainsKey(line))
|
||||
{
|
||||
Structure[Metas[letter.Key].ZH.Volume][page.Key].Add(line, letter.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new Library(
|
||||
Traditions,
|
||||
Persons,
|
||||
Metas,
|
||||
Marginals,
|
||||
Locations,
|
||||
Letters,
|
||||
HandPersons,
|
||||
Editreasons,
|
||||
Comments,
|
||||
Backlinks,
|
||||
Hands,
|
||||
Structure,
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Archive/HaDocument/Models/Letter.cs
Normal file
14
Archive/HaDocument/Models/Letter.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Letter : HaModel {
|
||||
public string Index { get; } = "";
|
||||
public string Element { get; } = "";
|
||||
|
||||
public Letter(
|
||||
string index,
|
||||
string element
|
||||
) {
|
||||
Index = index;
|
||||
Element = element;
|
||||
}
|
||||
}
|
||||
}
|
||||
150
Archive/HaDocument/Models/Library.cs
Normal file
150
Archive/HaDocument/Models/Library.cs
Normal file
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using HaDocument.Interfaces;
|
||||
using System.Collections.Immutable;
|
||||
using System.Collections.Generic;
|
||||
using HaDocument.Models;
|
||||
using HaDocument.Comparers;
|
||||
using System.Linq;
|
||||
|
||||
namespace HaDocument.Models
|
||||
{
|
||||
public class Library : ILibrary
|
||||
{
|
||||
public IHaDocumentOptions Options { get; }
|
||||
public ImmutableDictionary<string, Tradition> Traditions { get; }
|
||||
public ImmutableDictionary<string, Person> Persons { get; }
|
||||
public ImmutableDictionary<string, Meta> Metas { get; }
|
||||
public ImmutableDictionary<string, Marginal> Marginals { get; }
|
||||
public ImmutableDictionary<string, Location> Locations { get; }
|
||||
public ImmutableDictionary<string, Letter> Letters { get; }
|
||||
public ImmutableDictionary<string, Person> HandPersons { get; }
|
||||
public ImmutableDictionary<string, Editreason> Editreasons { get; }
|
||||
public ImmutableDictionary<string, Comment> Comments { get; }
|
||||
public ImmutableDictionary<string, ImmutableList<Backlink>> Backlinks { get; }
|
||||
public ImmutableDictionary<string, ImmutableList<Hand>> Hands { get; }
|
||||
|
||||
// Structure for lookups from ZH:
|
||||
public ImmutableDictionary<string, ImmutableDictionary<string, ImmutableDictionary<string, string>>> Structure { get; }
|
||||
|
||||
// Lookups:
|
||||
// Auswählen von Kommentaren nach (1) Kategorie, (2) Anfangsbuchstaben vom Lemma.
|
||||
// So: _ = CommentsByCategoryLetter['neuzeit']['A']
|
||||
public ImmutableDictionary<string, Lookup<string, Comment>> CommentsByCategoryLetter { get; }
|
||||
public Lookup<string, Comment> CommentsByCategory { get; }
|
||||
// Auswählen von Subkommentaren nach ID
|
||||
public ImmutableDictionary<string, Comment> SubCommentsByID { get; }
|
||||
// Auswählen von Marginalien nach Briefen
|
||||
public Lookup<string, Marginal> MarginalsByLetter { get; }
|
||||
// Ausw?hlen von Edits nach Briefen
|
||||
public Lookup<string, Editreason> EditreasonsByLetter { get; }
|
||||
// Auswählen von Briefen nach autoptischer Numemr und in zeitlich sortierter Reihenfolge.
|
||||
public ImmutableSortedSet<Meta> MetasByDate { get; }
|
||||
// Auswählen von Briefen nach dem Jahr, sortiert nach Datum
|
||||
public ILookup<string, Meta> MetasByYear { get; }
|
||||
|
||||
|
||||
public Library(
|
||||
Dictionary<string, Tradition> traditions,
|
||||
Dictionary<string, Person> persons,
|
||||
Dictionary<string, Meta> meta,
|
||||
Dictionary<string, Marginal> marginals,
|
||||
Dictionary<string, Location> locations,
|
||||
Dictionary<string, Letter> letters,
|
||||
Dictionary<string, Person> handPersons,
|
||||
Dictionary<string, Editreason> editReasons,
|
||||
Dictionary<string, Comment> comments,
|
||||
Dictionary<string, List<Backlink>> backlinks,
|
||||
Dictionary<string, List<Hand>> hands,
|
||||
Dictionary<string, Dictionary<string, Dictionary<string, string>>> Structure,
|
||||
IHaDocumentOptions options
|
||||
)
|
||||
{
|
||||
// Dictionaries
|
||||
Traditions = ImmutableDictionary.ToImmutableDictionary(traditions);
|
||||
Persons = ImmutableDictionary.ToImmutableDictionary(persons);
|
||||
Metas = ImmutableDictionary.ToImmutableDictionary(meta);
|
||||
Marginals = ImmutableDictionary.ToImmutableDictionary(marginals);
|
||||
Locations = ImmutableDictionary.ToImmutableDictionary(locations);
|
||||
Letters = ImmutableDictionary.ToImmutableDictionary(letters);
|
||||
HandPersons = ImmutableDictionary.ToImmutableDictionary(handPersons);
|
||||
Editreasons = ImmutableDictionary.ToImmutableDictionary(editReasons);
|
||||
Comments = ImmutableDictionary.ToImmutableDictionary(comments);
|
||||
|
||||
var backbuilder = ImmutableDictionary.CreateBuilder<string, ImmutableList<Backlink>>();
|
||||
foreach (var entry in backlinks)
|
||||
backbuilder.Add(entry.Key, ImmutableList.ToImmutableList(entry.Value));
|
||||
Backlinks = backbuilder.ToImmutableDictionary();
|
||||
|
||||
var handbuilder = ImmutableDictionary.CreateBuilder<string, ImmutableList<Hand>>();
|
||||
foreach (var entry in hands)
|
||||
handbuilder.Add(entry.Key, ImmutableList.ToImmutableList(entry.Value));
|
||||
Hands = handbuilder.ToImmutableDictionary();
|
||||
|
||||
// Lookups
|
||||
CommentsByCategory = (Lookup<string, Comment>)Comments.Values.ToLookup(x => x.Type);
|
||||
var CommentsByLetter_builder = ImmutableDictionary.CreateBuilder<string, Lookup<string, Comment>>();
|
||||
foreach (var ts in CommentsByCategory)
|
||||
{
|
||||
CommentsByLetter_builder.Add(ts.Key, (Lookup<string, Comment>)ts.ToLookup(x => x.Index.Substring(0, 1).ToUpper()));
|
||||
}
|
||||
CommentsByCategoryLetter = CommentsByLetter_builder.ToImmutableDictionary();
|
||||
MarginalsByLetter = (Lookup<string, Marginal>)Marginals.Values.ToLookup(x => x.Letter);
|
||||
EditreasonsByLetter = (Lookup<string, Editreason>)Editreasons.Values.ToLookup(x => x.Letter);
|
||||
MetasByDate = Metas.Values.ToImmutableSortedSet<Meta>(new DefaultComparer());
|
||||
MetasByYear = Metas.Values.ToLookup(x => x.Sort.Year.ToString());
|
||||
|
||||
var tempbuilder = ImmutableDictionary.CreateBuilder<string, Comment>();
|
||||
foreach (var comm in Comments)
|
||||
if (comm.Value.Kommentare != null)
|
||||
foreach (var subcomm in comm.Value.Kommentare)
|
||||
if (!tempbuilder.ContainsKey(subcomm.Key))
|
||||
tempbuilder.Add(subcomm.Key, subcomm.Value);
|
||||
SubCommentsByID = tempbuilder.ToImmutableDictionary();
|
||||
|
||||
var tempstructurebuilder = ImmutableDictionary.CreateBuilder<string, ImmutableDictionary<string, ImmutableDictionary<string, string>>>();
|
||||
foreach (var volume in Structure)
|
||||
{
|
||||
if (volume.Value != null)
|
||||
{
|
||||
var tempvolbuilder = ImmutableDictionary.CreateBuilder<string, ImmutableDictionary<string, string>>();
|
||||
foreach (var page in volume.Value)
|
||||
{
|
||||
if (page.Value != null)
|
||||
{
|
||||
tempvolbuilder.Add(page.Key, page.Value.ToImmutableDictionary());
|
||||
}
|
||||
}
|
||||
if (tempvolbuilder.Any())
|
||||
{
|
||||
tempstructurebuilder.Add(volume.Key, tempvolbuilder.ToImmutableDictionary());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.Structure = tempstructurebuilder.ToImmutableDictionary();
|
||||
|
||||
Options = options;
|
||||
|
||||
}
|
||||
|
||||
// public List<Meta> MetasByDate() {
|
||||
// var ret = Metas.OrderBy(x => x.Value, new DefaultComparer()).ToLookup(x => x.Value.Autopsic, x => x.Value);
|
||||
// ret.Sort(new DefaultComparer());
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
public ImmutableList<Meta> MetasByZH()
|
||||
{
|
||||
return Metas.Values.ToImmutableList().Sort(new Comparers.ZHComparer());
|
||||
}
|
||||
|
||||
public List<Person> PersonByAlphabet()
|
||||
{
|
||||
var ret = Persons.Values.ToList();
|
||||
ret.Sort(new PersonComparer());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
14
Archive/HaDocument/Models/Location.cs
Normal file
14
Archive/HaDocument/Models/Location.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Location {
|
||||
public string Index { get; } = "";
|
||||
public string Name { get; } = "";
|
||||
|
||||
public Location(
|
||||
string index,
|
||||
string name
|
||||
) {
|
||||
Index = index;
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Archive/HaDocument/Models/Marginal.cs
Normal file
23
Archive/HaDocument/Models/Marginal.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Marginal {
|
||||
public string Index { get; } = "";
|
||||
public string Letter { get; } = "";
|
||||
public string Page { get; } = "";
|
||||
public string Line { get; } = "";
|
||||
public string Element { get; } = "";
|
||||
|
||||
public Marginal(
|
||||
string index,
|
||||
string letter,
|
||||
string page,
|
||||
string line,
|
||||
string elemnt
|
||||
) {
|
||||
Index = index;
|
||||
Letter = letter;
|
||||
Page = page;
|
||||
Line = line;
|
||||
Element = elemnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Archive/HaDocument/Models/Meta.cs
Normal file
49
Archive/HaDocument/Models/Meta.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HaXMLReader.EvArgs;
|
||||
|
||||
namespace HaDocument.Models {
|
||||
public class Meta {
|
||||
public string Index { get; } = "";
|
||||
public string Autopsic { get; } = "";
|
||||
public string Date { get; } = "";
|
||||
public DateTime Sort { get; } = new DateTime(1700, 1, 1);
|
||||
public int Order { get; } = -1;
|
||||
public string Location { get; } = "";
|
||||
public List<string> Senders { get; } = null;
|
||||
public List<string> Receivers { get; } = null;
|
||||
public OptionalBool hasOriginal { get; } = OptionalBool.None;
|
||||
public OptionalBool isProofread { get; } = OptionalBool.None;
|
||||
public OptionalBool isDraft { get; } = OptionalBool.None;
|
||||
public ZHInfo ZH { get; } = null;
|
||||
|
||||
public Meta(
|
||||
string index,
|
||||
string autopsic,
|
||||
string date,
|
||||
DateTime sort,
|
||||
int order,
|
||||
OptionalBool hasOriginal,
|
||||
OptionalBool isProofread,
|
||||
OptionalBool isDraft,
|
||||
string location,
|
||||
List<string> senders,
|
||||
List<string> receivers,
|
||||
ZHInfo ZH
|
||||
) {
|
||||
Index = index;
|
||||
Autopsic = autopsic;
|
||||
Date = date;
|
||||
Sort = sort;
|
||||
Order = order;
|
||||
Location = location;
|
||||
Senders = senders;
|
||||
Receivers = receivers;
|
||||
this.hasOriginal = hasOriginal;
|
||||
this.isProofread = isProofread;
|
||||
this.isDraft = isDraft;
|
||||
this.ZH = ZH;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
13
Archive/HaDocument/Models/OptionalBool.cs
Normal file
13
Archive/HaDocument/Models/OptionalBool.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace HaDocument.Models
|
||||
{
|
||||
public enum OptionalBool
|
||||
{
|
||||
True,
|
||||
False,
|
||||
None
|
||||
}
|
||||
}
|
||||
20
Archive/HaDocument/Models/Person.cs
Normal file
20
Archive/HaDocument/Models/Person.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Person {
|
||||
public string Index { get; } = "";
|
||||
public string Name { get; } = "";
|
||||
public string Prename { get; } = "";
|
||||
public string Surname { get; } = "";
|
||||
|
||||
public Person(
|
||||
string index,
|
||||
string name,
|
||||
string prename,
|
||||
string surname
|
||||
) {
|
||||
Index = index;
|
||||
Name = name;
|
||||
Prename = prename;
|
||||
Surname = surname;
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Archive/HaDocument/Models/Tradition.cs
Normal file
14
Archive/HaDocument/Models/Tradition.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace HaDocument.Models {
|
||||
public class Tradition {
|
||||
public string Index { get; } = "";
|
||||
public string Element { get; } = "";
|
||||
|
||||
public Tradition(
|
||||
string index,
|
||||
string element
|
||||
) {
|
||||
Index = index;
|
||||
Element = element;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Archive/HaDocument/Models/ZHInfo.cs
Normal file
22
Archive/HaDocument/Models/ZHInfo.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace HaDocument.Models
|
||||
{
|
||||
|
||||
public class ZHInfo
|
||||
{
|
||||
public bool alternativeLineNumbering { get; } = false;
|
||||
public bool dateChanged { get; } = false;
|
||||
public string Volume { get; } = "";
|
||||
public string Page { get; } = "";
|
||||
|
||||
public ZHInfo(bool alternativeLineNumbering, bool dateChanged, string Volume, string Page) {
|
||||
this.alternativeLineNumbering = alternativeLineNumbering;
|
||||
this.dateChanged = dateChanged;
|
||||
this.Volume = Volume;
|
||||
this.Page = Page;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user