Initial Commit

This commit is contained in:
vysitor 2025-02-28 18:40:12 +01:00
parent ac74b9797f
commit 9c1ae91afe
62 changed files with 5266 additions and 0 deletions

BIN
src/main/.DS_Store vendored Normal file

Binary file not shown.

BIN
src/main/java/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -0,0 +1,117 @@
package org.texttechnologylab.project.gruppe_05_1;
import com.mongodb.client.MongoDatabase;
import org.texttechnologylab.project.gruppe_05_1.database.MongoDBHandler;
import org.texttechnologylab.project.gruppe_05_1.database.MongoObjectFactory;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Mdb;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.MdbDocument;
import org.texttechnologylab.project.gruppe_05_1.rest.RESTHandler;
import org.texttechnologylab.project.gruppe_05_1.util.PPRUtils;
import org.texttechnologylab.project.gruppe_05_1.util.PropertiesUtils;
import org.texttechnologylab.project.gruppe_05_1.util.XmlUtils;
import org.texttechnologylab.project.gruppe_05_1.xml.FileObjectFactory;
import org.w3c.dom.Element;
import java.util.List;
import java.util.Properties;
/*
import com.mongodb.client.*;
import org.bson.Document;
import org.texttechnologylab.project.Schelp_Valentin.database.MongoDBHandler;
import org.texttechnologylab.project.Schelp_Valentin.database.MongoObjectFactory;
import org.texttechnologylab.project.Schelp_Valentin.domain.mdb.MdbDocument;
import org.texttechnologylab.project.Schelp_Valentin.domain.mdb.Mdb;
import org.texttechnologylab.project.Schelp_Valentin.domain.reden.PlenarProtokoll;
import org.texttechnologylab.project.Schelp_Valentin.html.HtmlGenerationUtils;
import org.texttechnologylab.project.Schelp_Valentin.html.SortPossibilities;
import org.texttechnologylab.project.Schelp_Valentin.util.FileUtils;
import org.texttechnologylab.project.Schelp_Valentin.util.PPRUtils;
import org.texttechnologylab.project.Schelp_Valentin.util.PropertiesUtils;
import org.texttechnologylab.project.Schelp_Valentin.util.XmlUtils;
import org.texttechnologylab.project.Schelp_Valentin.xml.FileObjectFactory;
import org.texttechnologylab.project.Schelp_Valentin.xml.reden.PlenarProtokoll_File_Impl;
import org.w3c.dom.Element;
import java.util.*;
import java.util.stream.Collectors;
*/
public class Main {
public static final String RESOURCES_DIR="src/main/resources/";
private static final FileObjectFactory xmlFactory = FileObjectFactory.getFactory();
private static final MongoObjectFactory mongoFactory = MongoObjectFactory.getFactory();
public static void main(String[] args) {
// Stellt fest, dass alle nötigen Datenbank-Collections existieren
PPRUtils.ensureCollectionExist();
// Alle Informationen (Parlamentarier, Reden, Kommentare etc.) lesen und in die Mongo-DB einfügen, falls diese noch nicht vorhanden sind.
PPRUtils.parlamentExplorerInit(xmlFactory, mongoFactory);
// NLP-Verarbeitung - TODO
RESTHandler restHandler = new RESTHandler();
restHandler.startJavalin();
}
/* Auskommentiert aber nicht gelöscht, damit meine Methodik/Anwendung nachvollzogen werden kann
public static void main(String[] args) {
// Plenarprotokolle lesen und in die MongoDB schreiben
Set<String> protokollFileNames = FileUtils.listFilesInDirectory(PROTOKOLLE_DIRNAME)
.stream()
.filter(file -> file.endsWith(".xml"))
.collect(Collectors.toSet());
;
String collectionName = "speeches";
// MongoDBHandler.createCollectionIfNotExist(database, collectionName);
MongoDBHandler.createOrTrancateCollection(database, collectionName);
MongoCollection<Document> collection = database.getCollection(collectionName);
for (String filename : protokollFileNames) {
// for (String filename : Arrays.asList("1.XML", "2.XML")) { // für Testzwecke,,,
System.out.println("Plenarprotokoll wird aus " + filename + " gelesen");
Element redenRoot = XmlUtils.getRootDocument("src/main/resources/plenarprotokolle/" + filename);
PlenarProtokoll redenDoc = new PlenarProtokoll_File_Impl().fromXmlNode(redenRoot);
MongoDBHandler.createPlenarprotokoll(collection, redenDoc);
}
// wichtige Datenstrukturen erzeugen: Listen, Zuordnungen
Map<String, List<Mdb>> pareiMdbZuordnung = PPRUtils.createMdbParteiZuordnung(mdbList);
// HTML-Generierung
// Vorbereitung
HtmlGenerationUtils.prepareHtmlGeneration();
// index.html
/*
* Hier wird bestimmt, wie die index.html-Seite aufgebaut wird, je nach verwendete Enum aus SortPossibilities:
* - MDB_ALPHABETISCH: parteiübergreifend alphabetisch sortiert
* - nach Partei gruppiert, innerhalb der Partei alphabetisch sortiert:
* - PARTEI_MDB_ALPHABETISCH: die Parteien erscheinen in alphabetischen Reihenfolge
* - PARTEI_NACH_GROESSE: die Parteien erscheinen nach Anzahl ihrer dBs sortiert
* TODO: CLOSE COMMENT
HtmlGenerationUtils.generateIndexHtml(mdbList, pareiMdbZuordnung, SortPossibilities.MDB_ALPHABETISCH);
HtmlGenerationUtils.generateMdbPages(mdbList);
}
*/
}

View file

@ -0,0 +1,365 @@
package org.texttechnologylab.project.gruppe_05_1.database;
import com.mongodb.MongoClientSettings;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Updates;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.bson.types.ObjectId;
import org.texttechnologylab.project.gruppe_05_1.util.PropertiesUtils;
import java.util.*;
import static com.mongodb.client.model.Filters.eq;
public class MongoDBHandler {
public static final String propertiesFileName = "mongoDB.properties";
private static MongoDatabase mongoDatabase = null;
public final static Class<? extends List> DOC_LIST_CLASS = new ArrayList<Document>().getClass();
private static String localServer; // z.B mongodb://localhost:27017
private static String remoteServer;
private static String user;
private static String password;
private static String port;
private static String collection;
private static String databaseName;
/**
* Get the MongoDB according to properties.
* If a local server URI is defined, use it. Otherwise, use remote server.
* @return MongoDatabase
*/
static public MongoDatabase getMongoDatabase() {
if (mongoDatabase == null) {
Properties mongoProperties = PropertiesUtils.readPropertiesFromResource(propertiesFileName);
// Zugangsdaten
localServer = mongoProperties.getProperty("localserver");
remoteServer = mongoProperties.getProperty("remote_host");
user = mongoProperties.getProperty("remote_user");
password = mongoProperties.getProperty("remote_password");
port = mongoProperties.getProperty("remote_port");
collection = mongoProperties.getProperty("remote_collection");
databaseName = mongoProperties.getProperty("remote_database");
}
// MongoDBClient erzeugen
// String uri = mongoServer + "://" + mongoUser + ":" + mongoPassword + "@" + mongoNeetwork; // cluster, network, user...
// URI für lokale Datenbank oder für eine Datenbank auf dem Server
String uri;
if ( (localServer != null) && (! localServer.isBlank())) {
uri = localServer;
MongoClient mongoClient = MongoClients.create(uri);
// Connect
MongoDatabase mongoDatabase = mongoClient.getDatabase(databaseName);
return mongoDatabase;
} else {
MongoCredential credential = MongoCredential.createCredential(user, databaseName, password.toCharArray());
// Build MongoClientSettings
MongoClientSettings settings = MongoClientSettings.builder()
.applyToClusterSettings(builder ->
builder.hosts(Collections.singletonList(new ServerAddress(remoteServer,
Integer.parseInt(port)))))
.credential(credential)
.build();
// Create MongoClient
MongoClient mongoClient = MongoClients.create(settings);
mongoDatabase = mongoClient.getDatabase(databaseName);
}
return mongoDatabase;
}
/*
* Collection Operations
* =====================
*/
/**
*
* @return List<String> with the names of all collections
*/
static public Set<String> getCollectionNames() {
// return getMongoDatabase().listCollectionNames().into(new ArrayList<>());
return getMongoDatabase().listCollectionNames().into(new HashSet<>());
}
/**
*
* @param name Name of collection to check for existance
* @return does the collection exist
*/
static public boolean collectionExists(String name) {
return getMongoDatabase().listCollectionNames().into(new ArrayList<>()).contains(name);
}
/**
* Tries to create a collection. If the collection exists and contains documents, throw an exception
* @param database
* @param collectionName
*/
static public void createCollectionIfNotExist(MongoDatabase database, String collectionName) {
if (collectionName.isBlank()) {
throw new IllegalArgumentException("Collection name for MongoDB may not be blank");
} else {
MongoCollection<Document> collection = database.getCollection(collectionName);
if (collection.countDocuments() > 0) {
throw new IllegalArgumentException("Collection '" + collectionName + "' is not empty");
} else {
database.createCollection(collectionName);
}
}
}
static public void createCollectionIfNotExist(String collectionName) {
createCollectionIfNotExist(getMongoDatabase(), collectionName);
}
/**
* Create Collection
* @param database
* @param collectionName
*/
static public void createCollection(MongoDatabase database, String collectionName) {
if (collectionName.isBlank()) {
throw new IllegalArgumentException("Collection name for MongoDB may not be blank");
} else {
database.createCollection(collectionName);
}
}
static public void createCollection(String collectionName) {
createCollection(getMongoDatabase(), collectionName);
}
/**
* Creates a collection. If the collection exists already, delete all its document
* @param database
* @param collectionName
*/
static public void createOrTrancateCollection(MongoDatabase database, String collectionName) {
if (collectionName.isBlank()) {
throw new IllegalArgumentException("Collection name for MongoDB may not be blank");
} else {
MongoCollection<Document> collection = database.getCollection(collectionName);
if (collection.countDocuments() > 0) {
collection.drop();
}
database.createCollection(collectionName);
}
}
static public void createOrTrancateCollection(String collectionName) {
createOrTrancateCollection(getMongoDatabase(), collectionName);
}
/**
* Does a document with a given ID (for the "_id"-field) exists in a given collection?
* @param collection
* @param id
* @return
*/
static public boolean existsDocument(MongoCollection<Document> collection, String id) {
ObjectId idToFind = new ObjectId(id);
Document foundDocument = collection.find(new Document("_id", idToFind)).first();
return (foundDocument != null);
}
/**
* Find a document with a given ID (for the "_id"-field) in a given collection
* @param collection
* @param id
* @return the document (null if not found)
*/
static public Document findDocumentByIdInCollection(MongoCollection<Document> collection, String id) {
ObjectId idToFind = new ObjectId(id);
Document foundDocument = collection.find(new Document("_id", idToFind)).first();
return foundDocument;
}
/**
*
* @param collection
* @return count of documents in the collection
*/
static public long size(MongoCollection<Document> collection) {
if (null == collection) {
throw new IllegalArgumentException("Collection may not be null");
} else {
return collection.countDocuments();
}
}
/**
*
* @param database
* @param collectionName
* @return count of documents in the collection
*/
static public long size(MongoDatabase database, String collectionName) {
if (collectionName.isBlank()) {
throw new IllegalArgumentException("Collection name for MongoDB may not be blank");
} else {
return database.getCollection(collectionName).countDocuments();
}
}
/**
*
* @param database
* @param collectionName
*/
static public void dropCollection(MongoDatabase database, String collectionName) {
if (collectionName.isBlank()) {
throw new IllegalArgumentException("Collection name for MongoDB may not be blank");
} else {
database.getCollection(collectionName).drop();
}
}
/*
* Document Operations
* ===================
*/
/**
* Creates a BSON document containing only simple fields according to fields given in a map
* @param attributes
* @return
*/
static public Document createDocument(boolean createIdField, Map<String, Object> attributes) {
Document doc = new Document();
if (createIdField) {
doc.append("_id", new ObjectId());
}
for (Map.Entry<String, Object> entry : attributes.entrySet()) {
doc.append(entry.getKey(), entry.getValue());
}
return doc;
}
/**
* Creates a BSON document containing simple fields (attributes) as well as other (possibly nested) objects
* @param attributes the simple fields
* @param fields the (possibly nested) objects
* @return
*/
static public Document createDocument(boolean createIdField, Map<String, String> attributes, Map<String, Object> fields) {
Document doc = new Document();
if (createIdField) {
doc.append("_id", new ObjectId());
}
if ( ! attributes.isEmpty()) {
Map<String, Object> attributesMap = new HashMap<>();
for (Map.Entry<String, String> entry : attributes.entrySet()) {
attributesMap.put(entry.getKey(), entry.getValue());
}
Document attributeChild = createDocument(createIdField, attributesMap);
doc.append("attributes", attributeChild);
}
for (Map.Entry<String, Object> entry : fields.entrySet()) {
doc.append(entry.getKey(), entry.getValue());
}
return doc;
}
/*
* Weitere CRUD Operations
* =======================
*/
/**
*
* @param collection
* @param doc
* @return
*/
static public void insertDocument(MongoCollection<Document> collection, Document doc) {
collection.insertOne(doc);
}
/**
*
* @param collection
* @param docs
* @return
*/
static public void insertDocuments(MongoCollection<Document> collection, List<Document> docs) {
collection.insertMany(docs);
}
/**
*
* @param collection
* @param fieldName
* @param fieldValue
* @return
*/
static public Document findFirstDocumentInCollection(MongoCollection<Document> collection, String fieldName, String fieldValue) {
return collection.find(eq(fieldName, fieldValue)).first();
}
/**
* Searches a document and performs an update on it
* The document to update must be matched by name and value of a certain field
* @param collection
* @param searchCriteriaName search criteria: name of the field
* @param searchCriteriaValue search criteria: value of the field
* @param newOrUpdatedFieldName name of new field
* @param newOrUpdatedFieldValue value of new field
*/
static public void updateDocument(MongoCollection<Document> collection,
String searchCriteriaName, String searchCriteriaValue,
String newOrUpdatedFieldName, Object newOrUpdatedFieldValue){
Document updateQuery = new Document().append(searchCriteriaName, searchCriteriaValue);
Bson updates = Updates.combine(
Updates.addToSet(newOrUpdatedFieldName, newOrUpdatedFieldValue));
collection.updateOne(updateQuery, updates);
}
/**
*
* @param collection
* @param searchCriteriaName search criteria: name of the field
* @param searchCriteriaValue search criteria: value of the field
*/
static public void deleteOneDocument(MongoCollection<Document> collection, String searchCriteriaName, String searchCriteriaValue) {
Bson deleteQuery = eq(searchCriteriaName, searchCriteriaValue);
collection.deleteOne(deleteQuery);
}
}

View file

@ -0,0 +1,65 @@
package org.texttechnologylab.project.gruppe_05_1.database;
import org.bson.Document;
import org.texttechnologylab.project.gruppe_05_1.database.domainimpl.mdb.*;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.*;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Membership;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Speaker;
import java.util.List;
public class MongoObjectFactory {
private static MongoObjectFactory factory = null;
/**
*
* @return MongoObjectFactory
*/
public static MongoObjectFactory getFactory() {
if (factory == null) {
factory = new MongoObjectFactory();
}
return factory;
}
/*
* *** MDB Strukturen ***
* =====================
*/
public Document createBiografischeAngaben(BiografischeAngaben entity) {
return new BiografischeAngaben_Mongo_Impl().createEntity(entity);
}
public Document createInstitution(Institution entity) {
return new Institution_Mongo_Impl().createEntity(entity);
}
public Document createMdb(Mdb entity) {
return new Mdb_Mongo_Impl().createEntity(entity);
}
public Document createMdbName(MdbName entity) {
return new MdbName_Mongo_Impl().createEntity(entity);
}
public Document createWahlperiode(Wahlperiode entity) {
return new Wahlperiode_Mongo_Impl().createEntity(entity);
}
/*
* *** Speaker Strukturen ***
* ========================
*/
public Document createSpeaker(Speaker entity) {
return new Speaker_Mongo_Impl().createEntity(entity);
}
public Document createMembership(Membership entity) {
return new Membership_Mongo_Impl().createEntity(entity);
}
public List<Document> createMemberships(List<Membership> list) {
return new Membership_Mongo_Impl().createList(list);
}
}

View file

@ -0,0 +1,12 @@
package org.texttechnologylab.project.gruppe_05_1.database;
import org.bson.Document;
import org.texttechnologylab.project.gruppe_05_1.xml.FileObjectFactory;
import java.util.List;
public interface MongoOperations<T> {
MongoObjectFactory factory = MongoObjectFactory.getFactory();
public Document createEntity(T entity);
public List<Document> createList(List<T> list);
}

View file

@ -0,0 +1,254 @@
package org.texttechnologylab.project.gruppe_05_1.database;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import org.bson.Document;
import org.texttechnologylab.project.gruppe_05_1.domain.html.Parlamentarier;
import org.texttechnologylab.project.gruppe_05_1.domain.html.ParlamentarierDetails;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Membership;
import org.texttechnologylab.project.gruppe_05_1.domain.speech.Speech;
import org.texttechnologylab.project.gruppe_05_1.util.PPRUtils;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* Diese Klasse beinhaltet Mongo-Utilities, welche spezifisch für die PPR-Datenstrukturen sind.
*
* Mongo-Utilities genereller Natur stehen in der Klasse MongoDBHandler.
*/
public class MongoPprUtils {
/*
* Collection-Information und-zugang
* =======================================================================
*/
public static final String SPEAKER_COLLECTION_NAME = "speaker";
public static final String SPEECH_COLLECTION_NAME = "speech";
public static final String PICTURES_COLLECTION_NAME = "pictures";
public static final String COMMENT_COLLECTION_NAME = "comment";
private static MongoCollection<Document> speakerCollecion = null;
private static MongoCollection<Document> speechCollecion = null;
private static MongoCollection<Document> picturesCollecion = null;
private static MongoCollection<Document> commentCollecion = null;
public static MongoCollection<Document> getSpeakerCollection() {
if (speakerCollecion == null) speakerCollecion = MongoDBHandler.getMongoDatabase().getCollection(SPEAKER_COLLECTION_NAME);
return speakerCollecion;
}
public static MongoCollection<Document> getSpeechCollection() {
if (speechCollecion == null) speechCollecion = MongoDBHandler.getMongoDatabase().getCollection(SPEECH_COLLECTION_NAME);
return speechCollecion;
}
public static MongoCollection<Document> getPicturesCollection() {
if (picturesCollecion == null) picturesCollecion = MongoDBHandler.getMongoDatabase().getCollection(PICTURES_COLLECTION_NAME);
return picturesCollecion;
}
public static MongoCollection<Document> getCommentCollection() {
if (commentCollecion == null) commentCollecion = MongoDBHandler.getMongoDatabase().getCollection(COMMENT_COLLECTION_NAME);
return commentCollecion;
}
/*
* Parlamentarier
* =======================================================================
*/
/**
* Holt alle Parlamentarier, die einen Suchkriterium erfüllen.
* Das Suchkriterium wird auf allen Feldern angewandt: Vorname, Nachname, Partei.
* Ist das Suchkriterium leer, werden alle Parlamentarier zurückgeliefert
* @param filter (optional): Suchkriterium
* @return List<Parlamentarier>
*/
public static List<Parlamentarier> getAllParlamentarier(String filter) {
List<Parlamentarier> plist = new ArrayList<>();
MongoCursor<Document> cursor;
if (filter== null || filter.isBlank()) {
cursor = getSpeakerCollection().find().iterator();
} else {
String pattern = ".*" + filter + ".*";
Document searchDocument = new Document("$or", List.of(
new Document("name", new Document("$regex", pattern).append("$options", "i")),
new Document("firstName", new Document("$regex", pattern).append("$options", "i")),
new Document("party", new Document("$regex", pattern).append("$options", "i")),
new Document("_id", new Document("$regex", pattern).append("$options", "i"))
));
cursor = getSpeakerCollection().find(searchDocument).cursor();
}
try {
while (cursor.hasNext()) {
Parlamentarier p = readParlamentarierFromSpeaker(cursor.next());
plist.add(p);
}
} catch (Throwable t) {
System.err.println(t);
} finally {
cursor.close();
}
return plist;
}
/**
* Liest einen Parlamentarier von der MongoDB
* @param doc - MongoDB Dokument eines Parlamentariers
* @return Parlamentarier
*/
private static Parlamentarier readParlamentarierFromSpeaker(Document doc) {
Parlamentarier p = new Parlamentarier();
p.setId((String) doc.get("_id"));
p.setNachname((String) doc.get("name"));
p.setVorname((String) doc.get("firstName"));
String partei = (String) doc.get("party");
if (partei == null) {
p.setPartei("(parteilos)");
} else {
p.setPartei(partei);
}
return p;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ParlamentarierDetails
/**
* Holt die Details eines Parlamentariers
* @param id Parlamentarier-ID (String)
* @return ParlamentarierDetails
*/
public static ParlamentarierDetails getParlamentarierDetailsByID(String id) {
Document doc = MongoDBHandler.findFirstDocumentInCollection(getSpeakerCollection(), "_id", id);
ParlamentarierDetails p = readParlamentarierDetailsFromSpeaker(doc);
return p;
}
/**
* Holt die Details eines Parlamentariers
* @param id Parlamentarier-ID (Integer)
* @return ParlamentarierDetails
*/
public static ParlamentarierDetails getParlamentarierDetailsByID(Integer id) {
Document doc = MongoDBHandler.findFirstDocumentInCollection(getSpeakerCollection(), "_id", id.toString());
ParlamentarierDetails p = readParlamentarierDetailsFromSpeaker(doc);
return p;
}
/**
* Liest die Details eines Parlamentariers aus MongoDB, reiche diese mit Bildinformationen aus dem "pictures"-Collection, falls vorhanden, an
* @param doc - MongoDB Dokument eines Parlamentariers
* @return ParlamentarierDetails
*/
private static ParlamentarierDetails readParlamentarierDetailsFromSpeaker(Document doc) {
ParlamentarierDetails p = new ParlamentarierDetails();
String pid = (String) doc.get("_id");
p.setId(pid);
p.setNachname((String) doc.get("name"));
p.setVorname((String) doc.get("firstName"));
String partei = (String) doc.get("party");
if (partei == null) {
p.setPartei("(parteilos)");
} else {
p.setPartei(partei);
}
p.setTitle((String) doc.get("title"));
p.setGeburtsort((String) doc.get("geburtsort"));
p.setGeschlecht((String) doc.get("geschlecht"));
p.setBeruf((String) doc.get("beruf"));
p.setAkademischertitel((String) doc.get("akademischertitel"));
p.setFamilienstand((String) doc.get("familienstand"));
p.setReligion((String) doc.get("religion"));
p.setVita((String) doc.get("vita"));
p.setPrimaryFoto((String) doc.get("primaryFoto"));
Date geburtsdatum = (Date) doc.get("geburtsdatum");
if (geburtsdatum != null) {
p.setGeburtsdatum(LocalDate.ofInstant(geburtsdatum.toInstant(), ZoneId.systemDefault()));
}
Date sterbedatum = (Date) doc.get("sterbedatum");
if (sterbedatum != null) {
p.setSterbedatum(LocalDate.ofInstant(sterbedatum.toInstant(), ZoneId.systemDefault()));
}
List<Document> membershipDocList = doc.get("memberships", MongoDBHandler.DOC_LIST_CLASS);
if (membershipDocList == null) {
p.setMemberships(new ArrayList<>());
} else {
p.setMemberships(getMemberships(membershipDocList));
}
/* - TODO
List<Speech> reden = readSpeechesOfParlamentarier(pid);
PPRUtils.sortSpeechByDate(reden);
p.setReden(reden);
*/
return p;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ParlamentarierDetails - Memberships
/**
* Liest die Memberships eines Parlamentariers
* @param doclist Liste von MongoDB-Dokumente für die Memberships
* @return List<Membership>
*/
private static List<Membership> getMemberships(List<Document> doclist) {
List<Membership> memberships = new ArrayList<>();
for (Document doc : doclist) {
memberships.add(getMembership(doc));
}
return memberships;
}
/**
* Liest eine Memberships
* @param doc MongoDB-Dokument für eine Membership
* @return Membership
*/
private static Membership getMembership(Document doc) {
Membership m = new Membership();
Date begin = (Date) doc.get("begin");
if (begin != null) {
m.setBegin(LocalDate.ofInstant(begin.toInstant(), ZoneId.systemDefault()));
}
Date end = (Date) doc.get("end");
if (end != null) {
m.setEnd(LocalDate.ofInstant(end.toInstant(), ZoneId.systemDefault()));
}
m.setRole((String) doc.get("role"));
m.setMember((String) doc.get("member"));
m.setLabel((String) doc.get("label"));
m.setWp((Integer) doc.get("wp"));
return m;
}
// TODO: kopiere die Speech-Sachen von Übung 4 hierher!
}

View file

@ -0,0 +1,41 @@
package org.texttechnologylab.project.gruppe_05_1.database.domainimpl.mdb;
import org.bson.Document;
import org.texttechnologylab.project.gruppe_05_1.database.MongoDBHandler;
import org.texttechnologylab.project.gruppe_05_1.database.MongoOperations;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.BiografischeAngaben;
import org.texttechnologylab.project.gruppe_05_1.util.GeneralUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class BiografischeAngaben_Mongo_Impl extends BiografischeAngaben implements MongoOperations<BiografischeAngaben> {
@Override
public Document createEntity(BiografischeAngaben entity) {
Map<String, Object> fields = new HashMap<>();
fields.put("geburtsdatum", GeneralUtils.formatDate(entity.getSterbedatum()));
fields.put("geburtsort", entity.getGeburtsort());
fields.put("geburtsland", entity.getGeburtsland());
fields.put("sterbedatum", GeneralUtils.formatDate(entity.getSterbedatum()));
fields.put("gender", entity.getGender());
fields.put("maritalStatus", entity.getFamilienstand());
fields.put("religion", entity.getReligion());
fields.put("beruf", entity.getBeruf());
fields.put("parteiKuerzel", entity.getParteiKuerzel());
fields.put("vitaKurz", entity.getVitaKurz());
fields.put("veroeffentlichungspflichtiges", entity.getVeroeffentlichungspflichtiges());
Document doc = MongoDBHandler.createDocument(false, fields);
return doc;
}
@Override
public List<Document> createList(List<BiografischeAngaben> list) {
List<Document> result = new ArrayList<>();
for (BiografischeAngaben bio : list) {
result.add(createEntity(bio));
}
return result;
}
}

View file

@ -0,0 +1,37 @@
package org.texttechnologylab.project.gruppe_05_1.database.domainimpl.mdb;
import org.bson.Document;
import org.texttechnologylab.project.gruppe_05_1.database.MongoDBHandler;
import org.texttechnologylab.project.gruppe_05_1.database.MongoOperations;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Institution;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Institution_Mongo_Impl extends Institution implements MongoOperations<Institution> {
@Override
public Document createEntity(Institution entity) {
Map<String, Object> fields = new HashMap<>();
fields.put("insartLang", entity.getInsartLang());
fields.put("insLang", entity.getInsLang());
fields.put("mdbinsVon", entity.getMdbinsVon());
fields.put("mdbinsBis", entity.getMdbinsBis());
fields.put("fktLang", entity.getFktLang());
fields.put("fktinsVon", entity.getFktinsVon());
fields.put("fktinsBis", entity.getFktinsBis());
Document doc = MongoDBHandler.createDocument(false, fields);
return doc;
}
@Override
public List<Document> createList(List<Institution> list) {
List<Document> result = new ArrayList<>();
for (Institution inst : list) {
result.add(createEntity(inst));
}
return result;
}
}

View file

@ -0,0 +1,37 @@
package org.texttechnologylab.project.gruppe_05_1.database.domainimpl.mdb;
import org.bson.Document;
import org.texttechnologylab.project.gruppe_05_1.database.MongoDBHandler;
import org.texttechnologylab.project.gruppe_05_1.database.MongoOperations;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.MdbName;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MdbName_Mongo_Impl extends MdbName implements MongoOperations<MdbName> {
@Override
public Document createEntity(MdbName entity) {
Map<String, Object> fields = new HashMap<>();
fields.put("nachname", entity.getNachname());
fields.put("vorname", entity.getVorname());
fields.put("ortszusatz", entity.getOrtszusatz());
fields.put("adel", entity.getAdel());
fields.put("praefix", entity.getPraefix());
fields.put("andereTitel", entity.getAndereTitel());
fields.put("akadTitel", entity.getAkadTitel());
fields.put("historieVon", entity.getHistorieVon());
fields.put("historieBis", entity.getHistorieBis());
return MongoDBHandler.createDocument(false, fields);
}
@Override
public List<Document> createList(List<MdbName> list) {
List<Document> result = new ArrayList<>();
for (MdbName mdbName : list) {
result.add(createEntity(mdbName));
}
return result;
}
}

View file

@ -0,0 +1,50 @@
package org.texttechnologylab.project.gruppe_05_1.database.domainimpl.mdb;
import org.bson.Document;
import org.texttechnologylab.project.gruppe_05_1.database.MongoDBHandler;
import org.texttechnologylab.project.gruppe_05_1.database.MongoOperations;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Mdb;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.MdbName;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Wahlperiode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Mdb_Mongo_Impl extends Mdb implements MongoOperations<Mdb> {
@Override
public Document createEntity(Mdb entity) {
Document bioDoc = factory.createBiografischeAngaben(entity.getBio());
List<MdbName> namen= entity.getNamen();
List<Document> namenDocs = new ArrayList<>();
for (MdbName mdbName : namen) {
namenDocs.add(factory.createMdbName(mdbName));
}
List<Wahlperiode> wps= entity.getWahlperioden();
List<Document> wpDocs = new ArrayList<>();
for (Wahlperiode wp : wps) {
wpDocs.add(factory.createWahlperiode(wp));
}
Map<String, Object> fields = Map.of(
"id", entity.getId(),
"namen", namenDocs,
"bio", bioDoc,
"wahlperioden", wpDocs
);
Document doc = MongoDBHandler.createDocument(false, fields);
return doc;
}
@Override
public List<Document> createList(List<Mdb> list) {
List<Document> result = new ArrayList<>();
for (Mdb mdb : list) {
result.add(createEntity(mdb));
}
return result;
}
}

View file

@ -0,0 +1,40 @@
package org.texttechnologylab.project.gruppe_05_1.database.domainimpl.mdb;
import org.bson.Document;
import org.texttechnologylab.project.gruppe_05_1.database.MongoDBHandler;
import org.texttechnologylab.project.gruppe_05_1.database.MongoOperations;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.MdbName;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Wahlperiode;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Membership;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Speaker;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Membership_Mongo_Impl extends Membership implements MongoOperations<Membership> {
@Override
public Document createEntity(Membership entity) {
Map<String, Object> fields = new HashMap<>();
fields.put("begin", entity.getBegin());
fields.put("end", entity.getEnd());
fields.put("role", entity.getRole());
fields.put("label", entity.getLabel());
fields.put("member", entity.getMember()); // TODO: wahrscheinlich nicht nötig
Document doc = MongoDBHandler.createDocument(false, fields);
return doc;
}
@Override
public List<Document> createList(List<Membership> list) {
List<Document> result = new ArrayList<>();
for (Membership membership : list) {
result.add(createEntity(membership));
}
return result;
}
}

View file

@ -0,0 +1,51 @@
package org.texttechnologylab.project.gruppe_05_1.database.domainimpl.mdb;
import org.bson.Document;
import org.texttechnologylab.project.gruppe_05_1.database.MongoDBHandler;
import org.texttechnologylab.project.gruppe_05_1.database.MongoOperations;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Membership;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Speaker;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Speaker_Mongo_Impl extends Speaker implements MongoOperations<Speaker> {
@Override
public Document createEntity(Speaker entity) {
List<Membership> memberships= entity.getMemberships();
List<Document> membershipDocs = factory.createMemberships(memberships);
Map<String, Object> fields = new HashMap<>();
fields.put("_id", entity.getId());
fields.put("name", entity.getName());
fields.put("firstName", entity.getFirstName());
fields.put("title", entity.getTitle());
fields.put("geburtsdatum", entity.getGeburtsdatum());
fields.put("geburtsort", entity.getGeburtsort());
fields.put("sterbedatum", entity.getSterbedatum());
fields.put("geschlecht", entity.getGeschlecht());
fields.put("beruf", entity.getBeruf());
fields.put("akademischertitel", entity.getAkademischertitel());
fields.put("familienstand", entity.getFamilienstand());
fields.put("religion", entity.getReligion());
fields.put("vita", entity.getVita());
fields.put("party", entity.getParty());
fields.put("memberships", membershipDocs);
Document doc = MongoDBHandler.createDocument(false, fields);
return doc;
}
@Override
public List<Document> createList(List<Speaker> list) {
List<Document> result = new ArrayList<>();
for (Speaker speaker : list) {
result.add(createEntity(speaker));
}
return result;
}
}

View file

@ -0,0 +1,47 @@
package org.texttechnologylab.project.gruppe_05_1.database.domainimpl.mdb;
import org.bson.Document;
import org.texttechnologylab.project.gruppe_05_1.database.MongoDBHandler;
import org.texttechnologylab.project.gruppe_05_1.database.MongoOperations;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Institution;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Wahlperiode;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Wahlperiode_Mongo_Impl extends Wahlperiode implements MongoOperations<Wahlperiode> {
@Override
public Document createEntity(Wahlperiode entity) {
Map<String, Object> fields = new HashMap<>();
fields.put("wp", entity.getWp());
fields.put("mdbWpVon", entity.getMdbWpVon());
fields.put("mdbWpBis", entity.getMdbWpBis());
fields.put("wknNr", entity.getWknNr());
fields.put("wkrName", entity.getWkrName());
fields.put("wkrLand", entity.getWkrLand());
fields.put("liste", entity.getListe());
fields.put("mandatsart", entity.getMandatsart().name());
List<Institution> institutionen = entity.getInstitutionen();
List<Document> instDocs = new ArrayList<>();
for (Institution inst : institutionen) {
instDocs.add(factory.createInstitution(inst));
}
fields.put("institutionen", instDocs);
Document doc = MongoDBHandler.createDocument(false, fields);
return doc;
}
@Override
public List<Document> createList(List<Wahlperiode> list) {
List<Document> result = new ArrayList<>();
for (Wahlperiode wp : list) {
result.add(createEntity(wp));
}
return result;
}
}

View file

@ -0,0 +1,24 @@
package org.texttechnologylab.project.gruppe_05_1.domain;
public enum Gender { // TODO: Delete
M("männlich"),
F("weiblich"), // nur diese beide Werte sind in der XML-Datei vorhanden!
NA("") // falls Daten nicht vorhanden
;
private final String text;
public String getText() {
return this.text;
}
private Gender(String text) {this.text = text;}
public static Gender byText(String text) {
if (null == text) return NA;
if (text.equalsIgnoreCase(M.text)) return M;
if (text.equalsIgnoreCase(F.text)) return F;
return NA;
}
}

View file

@ -0,0 +1,65 @@
package org.texttechnologylab.project.gruppe_05_1.domain.html;
import java.util.Objects;
import java.util.StringJoiner;
public class Parlamentarier {
String id;
String vorname;
String nachname;
String partei;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getVorname() {
return vorname;
}
public void setVorname(String vorname) {
this.vorname = vorname;
}
public String getNachname() {
return nachname;
}
public void setNachname(String nachname) {
this.nachname = nachname;
}
public String getPartei() {
return partei;
}
public void setPartei(String partei) {
this.partei = partei;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Parlamentarier that)) return false;
return Objects.equals(id, that.id) && Objects.equals(vorname, that.vorname) && Objects.equals(nachname, that.nachname) && Objects.equals(partei, that.partei);
}
@Override
public int hashCode() {
return Objects.hash(id, vorname, nachname, partei);
}
@Override
public String toString() {
return new StringJoiner(", ", Parlamentarier.class.getSimpleName() + "[", "]")
.add("id='" + id + "'")
.add("vorname='" + vorname + "'")
.add("nachname='" + nachname + "'")
.add("partei='" + partei + "'")
.toString();
}
}

View file

@ -0,0 +1,219 @@
package org.texttechnologylab.project.gruppe_05_1.domain.html;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Membership;
import org.texttechnologylab.project.gruppe_05_1.domain.speech.Speech;
import org.texttechnologylab.project.gruppe_05_1.util.GeneralUtils;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
public class ParlamentarierDetails {
String id;
String vorname;
String nachname;
String partei;
String title;
LocalDate geburtsdatum;
String geburtsort;
LocalDate sterbedatum;
String geschlecht;
String beruf;
String akademischertitel;
String familienstand;
String religion;
String vita;
String primaryFoto; // war nicht ursprünglich in der Datenbank, wurde hinzugefügt, um das primäres Bild zu speichern
String party;
List<Membership> memberships;
List<Speech> reden;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getVorname() {
return vorname;
}
public void setVorname(String vorname) {
this.vorname = vorname;
}
public String getNachname() {
return nachname;
}
public void setNachname(String nachname) {
this.nachname = nachname;
}
public String getPartei() {
return partei;
}
public void setPartei(String partei) {
this.partei = partei;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public LocalDate getGeburtsdatum() {
return geburtsdatum;
}
public String getGeburtsdatumPP() {
if (geburtsdatum == null) return null;
return GeneralUtils.formatDate(geburtsdatum);
}
public void setGeburtsdatum(LocalDate geburtsdatum) {
this.geburtsdatum = geburtsdatum;
}
public String getGeburtsort() {
return geburtsort;
}
public void setGeburtsort(String geburtsort) {
this.geburtsort = geburtsort;
}
public LocalDate getSterbedatum() {
return sterbedatum;
}
public void setSterbedatum(LocalDate sterbedatum) {
this.sterbedatum = sterbedatum;
}
public String getGeschlecht() {
return geschlecht;
}
public void setGeschlecht(String geschlecht) {
this.geschlecht = geschlecht;
}
public String getBeruf() {
return beruf;
}
public void setBeruf(String beruf) {
this.beruf = beruf;
}
public String getAkademischertitel() {
return akademischertitel;
}
public void setAkademischertitel(String akademischertitel) {
this.akademischertitel = akademischertitel;
}
public String getFamilienstand() {
return familienstand;
}
public void setFamilienstand(String familienstand) {
this.familienstand = familienstand;
}
public String getReligion() {
return religion;
}
public void setReligion(String religion) {
this.religion = religion;
}
public String getVita() {
return vita;
}
public void setVita(String vita) {
this.vita = vita;
}
public String getParty() {
return party;
}
public void setParty(String party) {
this.party = party;
}
public String getPrimaryFoto() {
return primaryFoto;
}
public void setPrimaryFoto(String primaryFoto) {
this.primaryFoto = primaryFoto;
}
public List<Membership> getMemberships() {
return memberships;
}
public void setMemberships(List<Membership> memberships) {
this.memberships = memberships;
}
public List<Speech> getReden() {
return reden;
}
public void setReden(List<Speech> reden) {
this.reden = reden;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ParlamentarierDetails)) return false;
ParlamentarierDetails that = (ParlamentarierDetails) o;
return Objects.equals(id, that.id) ;
}
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public String toString() {
return new StringJoiner(", ", ParlamentarierDetails.class.getSimpleName() + "[", "]")
.add("id='" + id + "'")
.add("vorname='" + vorname + "'")
.add("nachname='" + nachname + "'")
.add("partei='" + partei + "'")
.add("title='" + title + "'")
.add("geburtsdatum=" + geburtsdatum)
.add("geburtsort='" + geburtsort + "'")
.add("sterbedatum=" + sterbedatum)
.add("geschlecht='" + geschlecht + "'")
.add("beruf='" + beruf + "'")
.add("akademischertitel='" + akademischertitel + "'")
.add("familienstand='" + familienstand + "'")
.add("religion='" + religion + "'")
.add("vita='" + vita + "'")
.add("primaryFoto='" + primaryFoto + "'")
.add("party='" + party + "'")
// .add("memberships=" + memberships)
.add("reden=" + reden)
.toString();
}
}

View file

@ -0,0 +1,140 @@
package org.texttechnologylab.project.gruppe_05_1.domain.mdb;
import java.time.LocalDate;
import java.util.Objects;
import java.util.StringJoiner;
import org.texttechnologylab.project.gruppe_05_1.domain.Gender;
public abstract class BiografischeAngaben {
private LocalDate geburtsdatum;
private String geburtsort;
private String geburtsland;
private LocalDate sterbedatum;
private String gender;
private String familienstand; // String und kein Enum, weil über 60 Werte wie "alleinerziehend, 3 Kinder", "eheähnl. Lebensgemeinschaft, 3 Kinder", "verheiratet, 12 Kinder" vorkommen...
private String religion;
private String beruf;
private String parteiKuerzel;
private String vitaKurz;
private String veroeffentlichungspflichtiges;
public LocalDate getGeburtsdatum() {
return geburtsdatum;
}
public void setGeburtsdatum(LocalDate geburtsdatum) {
this.geburtsdatum = geburtsdatum;
}
public String getGeburtsort() {
return geburtsort;
}
public void setGeburtsort(String geburtsort) {
this.geburtsort = geburtsort;
}
public String getGeburtsland() {
return geburtsland;
}
public void setGeburtsland(String geburtsland) {
this.geburtsland = geburtsland;
}
public LocalDate getSterbedatum() {
return sterbedatum;
}
public void setSterbedatum(LocalDate sterbedatum) {
this.sterbedatum = sterbedatum;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getFamilienstand() {
return familienstand;
}
public void setFamilienstand(String familienstand) {
this.familienstand = familienstand;
}
public String getReligion() {
return religion;
}
public void setReligion(String religion) {
this.religion = religion;
}
public String getBeruf() {
return beruf;
}
public void setBeruf(String beruf) {
this.beruf = beruf;
}
public String getParteiKuerzel() {
return parteiKuerzel;
}
public void setParteiKuerzel(String parteiKuerzel) {
this.parteiKuerzel = parteiKuerzel;
}
public String getVitaKurz() {
return vitaKurz;
}
public void setVitaKurz(String vitaKurz) {
this.vitaKurz = vitaKurz;
}
public String getVeroeffentlichungspflichtiges() {
return veroeffentlichungspflichtiges;
}
public void setVeroeffentlichungspflichtiges(String veroeffentlichungspflichtiges) {
this.veroeffentlichungspflichtiges = veroeffentlichungspflichtiges;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof BiografischeAngaben)) return false;
BiografischeAngaben that = (BiografischeAngaben) o;
return Objects.equals(geburtsdatum, that.geburtsdatum) && Objects.equals(geburtsort, that.geburtsort) && Objects.equals(geburtsland, that.geburtsland) && Objects.equals(sterbedatum, that.sterbedatum) && gender == that.gender && familienstand == that.familienstand && religion == that.religion && Objects.equals(beruf, that.beruf) && Objects.equals(parteiKuerzel, that.parteiKuerzel) && Objects.equals(vitaKurz, that.vitaKurz) && Objects.equals(veroeffentlichungspflichtiges, that.veroeffentlichungspflichtiges);
}
@Override
public int hashCode() {
return Objects.hash(geburtsdatum, geburtsort, geburtsland, sterbedatum, gender, familienstand, religion, beruf, parteiKuerzel, vitaKurz, veroeffentlichungspflichtiges);
}
@Override
public String toString() {
return new StringJoiner(", ", BiografischeAngaben.class.getSimpleName() + "[", "]")
.add("geburtsdatum=" + geburtsdatum)
.add("geburtsort='" + geburtsort + "'")
.add("geburtsland='" + geburtsland + "'")
.add("sterbedatum=" + sterbedatum)
.add("gender=" + gender)
.add("maritalStatus=" + familienstand)
.add("religion=" + religion)
.add("beruf='" + beruf + "'")
.add("parteiKuerzel='" + parteiKuerzel + "'")
.add("vitaKurz='" + vitaKurz + "'")
.add("veroeffentlichungspflichtiges='" + veroeffentlichungspflichtiges + "'")
.toString();
}
}

View file

@ -0,0 +1,98 @@
package org.texttechnologylab.project.gruppe_05_1.domain.mdb;
import java.time.LocalDate;
import java.util.Objects;
import java.util.StringJoiner;
public abstract class Institution {
private String insartLang;
private String insLang;
private LocalDate mdbinsVon;
private LocalDate mdbinsBis;
private String fktLang;
private LocalDate fktinsVon;
private LocalDate fktinsBis;
public String getInsartLang() {
return insartLang;
}
public void setInsartLang(String insartLang) {
this.insartLang = insartLang;
}
public String getInsLang() {
return insLang;
}
public void setInsLang(String insLang) {
this.insLang = insLang;
}
public LocalDate getMdbinsVon() {
return mdbinsVon;
}
public void setMdbinsVon(LocalDate mdbinsVon) {
this.mdbinsVon = mdbinsVon;
}
public LocalDate getMdbinsBis() {
return mdbinsBis;
}
public void setMdbinsBis(LocalDate mdbinsBis) {
this.mdbinsBis = mdbinsBis;
}
public String getFktLang() {
return fktLang;
}
public void setFktLang(String fktLang) {
this.fktLang = fktLang;
}
public LocalDate getFktinsVon() {
return fktinsVon;
}
public void setFktinsVon(LocalDate fktinsVon) {
this.fktinsVon = fktinsVon;
}
public LocalDate getFktinsBis() {
return fktinsBis;
}
public void setFktinsBis(LocalDate fktinsBis) {
this.fktinsBis = fktinsBis;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Institution)) return false;
Institution that = (Institution) o;
return Objects.equals(insartLang, that.insartLang) && Objects.equals(insLang, that.insLang) && Objects.equals(mdbinsVon, that.mdbinsVon) && Objects.equals(mdbinsBis, that.mdbinsBis) && Objects.equals(fktLang, that.fktLang) && Objects.equals(fktinsVon, that.fktinsVon) && Objects.equals(fktinsBis, that.fktinsBis);
}
@Override
public int hashCode() {
return Objects.hash(insartLang, insLang, mdbinsVon, mdbinsBis, fktLang, fktinsVon, fktinsBis);
}
@Override
public String toString() {
return new StringJoiner(", ", Institution.class.getSimpleName() + "[", "]")
.add("insartLang='" + insartLang + "'")
.add("insLang='" + insLang + "'")
.add("mdbinsVon=" + mdbinsVon)
.add("mdbinsBis=" + mdbinsBis)
.add("fktLang='" + fktLang + "'")
.add("fktinsVon=" + fktinsVon)
.add("fktinsBis=" + fktinsBis)
.toString();
}
}

View file

@ -0,0 +1,22 @@
package org.texttechnologylab.project.gruppe_05_1.domain.mdb;
public enum Mandatsart {
DIREKT("Direktwahl"),
LANDESLISTE("Landesliste"),
VOLKSKAMMER("Volkskammer"),
NA("") // falls Daten nicht vorhanden
;
private final String text;
private Mandatsart(String text) {this.text = text;}
public static Mandatsart byText(String text) {
if (null == text) return NA;
if (text.equalsIgnoreCase(DIREKT.text)) return DIREKT;
if (text.equalsIgnoreCase(LANDESLISTE.text)) return LANDESLISTE;
if (text.equalsIgnoreCase(VOLKSKAMMER.text)) return VOLKSKAMMER;
return NA;
}
}

View file

@ -0,0 +1,68 @@
package org.texttechnologylab.project.gruppe_05_1.domain.mdb;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
public abstract class Mdb {
private String id;
private List<MdbName> namen;
private BiografischeAngaben bio;
private List<Wahlperiode> wahlperioden;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public List<MdbName> getNamen() {
return namen;
}
public void setNamen(List<MdbName> namen) {
this.namen = namen;
}
public BiografischeAngaben getBio() {
return bio;
}
public void setBio(BiografischeAngaben bio) {
this.bio = bio;
}
public List<Wahlperiode> getWahlperioden() {
return wahlperioden;
}
public void setWahlperioden(List<Wahlperiode> wahlperioden) {
this.wahlperioden = wahlperioden;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Mdb)) return false;
Mdb mdb = (Mdb) o;
return Objects.equals(id, mdb.id) && Objects.equals(namen, mdb.namen) && Objects.equals(bio, mdb.bio) && Objects.equals(wahlperioden, mdb.wahlperioden);
}
@Override
public int hashCode() {
return Objects.hash(id, namen, bio, wahlperioden);
}
@Override
public String toString() {
return new StringJoiner(", ", Mdb.class.getSimpleName() + "[", "]")
.add("id='" + id + "'")
.add("namen=" + namen)
.add("bio=" + bio)
.add("wahlperioden=" + wahlperioden)
.toString();
}
}

View file

@ -0,0 +1,48 @@
package org.texttechnologylab.project.gruppe_05_1.domain.mdb;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
public abstract class MdbDocument {
private String version;
private List<Mdb> mdbs;
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public List<Mdb> getMdbs() {
return mdbs;
}
public void setMdbs(List<Mdb> mdbs) {
this.mdbs = mdbs;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof MdbDocument)) return false;
MdbDocument that = (MdbDocument) o;
return Objects.equals(version, that.version) && Objects.equals(mdbs, that.mdbs);
}
@Override
public int hashCode() {
return Objects.hash(version, mdbs);
}
@Override
public String toString() {
return new StringJoiner(", ", MdbDocument.class.getSimpleName() + "[", "]")
.add("version='" + version + "'")
.add("mdbs=" + mdbs)
.toString();
}
}

View file

@ -0,0 +1,119 @@
package org.texttechnologylab.project.gruppe_05_1.domain.mdb;
import java.time.LocalDate;
import java.util.Objects;
import java.util.StringJoiner;
public abstract class MdbName {
private String nachname;
private String vorname;
private String ortszusatz;
private String adel;
private String praefix;
private String andereTitel;
private String akadTitel;
private LocalDate historieVon;
private LocalDate historieBis;
public String getNachname() {
return nachname;
}
public void setNachname(String nachname) {
this.nachname = nachname;
}
public String getVorname() {
return vorname;
}
public void setVorname(String vorname) {
this.vorname = vorname;
}
public String getOrtszusatz() {
return ortszusatz;
}
public void setOrtszusatz(String ortszusatz) {
this.ortszusatz = ortszusatz;
}
public String getAdel() {
return adel;
}
public void setAdel(String adel) {
this.adel = adel;
}
public String getPraefix() {
return praefix;
}
public void setPraefix(String praefix) {
this.praefix = praefix;
}
public String getAndereTitel() {
return andereTitel;
}
public void setAndereTitel(String andereTitel) {
this.andereTitel = andereTitel;
}
public String getAkadTitel() {
return akadTitel;
}
public void setAkadTitel(String akadTitel) {
this.akadTitel = akadTitel;
}
public LocalDate getHistorieVon() {
return historieVon;
}
public void setHistorieVon(LocalDate historieVon) {
this.historieVon = historieVon;
}
public LocalDate getHistorieBis() {
return historieBis;
}
public void setHistorieBis(LocalDate historieBis) {
this.historieBis = historieBis;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof MdbName)) return false;
MdbName name = (MdbName) o;
return Objects.equals(nachname, name.nachname) && Objects.equals(vorname, name.vorname) && Objects.equals(ortszusatz, name.ortszusatz) && Objects.equals(adel, name.adel) && Objects.equals(praefix, name.praefix) && Objects.equals(andereTitel, name.andereTitel) && Objects.equals(akadTitel, name.akadTitel) && Objects.equals(historieVon, name.historieVon) && Objects.equals(historieBis, name.historieBis);
}
@Override
public int hashCode() {
return Objects.hash(nachname, vorname, ortszusatz, adel, praefix, andereTitel, akadTitel, historieVon, historieBis);
}
@Override
public String toString() {
return new StringJoiner(", ", MdbName.class.getSimpleName() + "[", "]")
.add("nachname='" + nachname + "'")
.add("vorname='" + vorname + "'")
.add("ortszusatz='" + ortszusatz + "'")
.add("adel='" + adel + "'")
.add("praefix='" + praefix + "'")
.add("andereTitel='" + andereTitel + "'")
.add("akadTitel='" + akadTitel + "'")
.add("historieVon=" + historieVon)
.add("historieBis=" + historieBis)
.toString();
}
}

View file

@ -0,0 +1,119 @@
package org.texttechnologylab.project.gruppe_05_1.domain.mdb;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
public abstract class Wahlperiode {
private int wp;
private LocalDate mdbWpVon;
private LocalDate mdbWpBis;
private String wknNr; // String, nicht int, weil manchmal leer
private String wkrName;
private String wkrLand;
private String liste;
private Mandatsart mandatsart;
private List<Institution> institutionen;
public int getWp() {
return wp;
}
public void setWp(int wp) {
this.wp = wp;
}
public LocalDate getMdbWpVon() {
return mdbWpVon;
}
public void setMdbWpVon(LocalDate mdbWpVon) {
this.mdbWpVon = mdbWpVon;
}
public LocalDate getMdbWpBis() {
return mdbWpBis;
}
public void setMdbWpBis(LocalDate mdbWpBis) {
this.mdbWpBis = mdbWpBis;
}
public String getWknNr() {
return wknNr;
}
public void setWknNr(String wknNr) {
this.wknNr = wknNr;
}
public String getWkrName() {
return wkrName;
}
public void setWkrName(String wkrName) {
this.wkrName = wkrName;
}
public String getWkrLand() {
return wkrLand;
}
public void setWkrLand(String wkrLand) {
this.wkrLand = wkrLand;
}
public String getListe() {
return liste;
}
public void setListe(String liste) {
this.liste = liste;
}
public Mandatsart getMandatsart() {
return mandatsart;
}
public void setMandatsart(Mandatsart mandatsart) {
this.mandatsart = mandatsart;
}
public List<Institution> getInstitutionen() {
return institutionen;
}
public void setInstitutionen(List<Institution> institutionen) {
this.institutionen = institutionen;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Wahlperiode)) return false;
Wahlperiode that = (Wahlperiode) o;
return wp == that.wp && wknNr == that.wknNr && Objects.equals(mdbWpVon, that.mdbWpVon) && Objects.equals(mdbWpBis, that.mdbWpBis) && Objects.equals(wkrName, that.wkrName) && Objects.equals(wkrLand, that.wkrLand) && Objects.equals(liste, that.liste) && mandatsart == that.mandatsart && Objects.equals(institutionen, that.institutionen);
}
@Override
public int hashCode() {
return Objects.hash(wp, mdbWpVon, mdbWpBis, wknNr, wkrName, wkrLand, liste, mandatsart, institutionen);
}
@Override
public String toString() {
return new StringJoiner(", ", Wahlperiode.class.getSimpleName() + "[", "]")
.add("wp=" + wp)
.add("mdbWpVon=" + mdbWpVon)
.add("mdbWpBis=" + mdbWpBis)
.add("wknNr=" + wknNr)
.add("wkrName='" + wkrName + "'")
.add("wkrLand='" + wkrLand + "'")
.add("liste='" + liste + "'")
.add("mandatsart=" + mandatsart)
.add("institutionen=" + institutionen)
.toString();
}
}

View file

@ -0,0 +1,87 @@
package org.texttechnologylab.project.gruppe_05_1.domain.speaker;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.StringJoiner;
public class Membership {
String role;
String member; // TODO: wozu? Dr. Abrami hat hier die ID des Parlamentariers gespeichert
LocalDate begin; // TODO: in Mongo eigentlich Date?
LocalDate end; // TODO: in Mongo eigentlich Date?
String label;
Integer wp;
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getMember() {
return member;
}
public void setMember(String member) {
this.member = member;
}
public LocalDate getBegin() {
return begin;
}
public void setBegin(LocalDate begin) {
this.begin = begin;
}
public LocalDate getEnd() {
return end;
}
public void setEnd(LocalDate end) {
this.end = end;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public Integer getWp() {
return wp;
}
public void setWp(Integer wp) {
this.wp = wp;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Membership that)) return false;
return Objects.equals(role, that.role) && Objects.equals(member, that.member) && Objects.equals(begin, that.begin) && Objects.equals(end, that.end) && Objects.equals(label, that.label) && Objects.equals(wp, that.wp);
}
@Override
public int hashCode() {
return Objects.hash(role, member, begin, end, label, wp);
}
@Override
public String toString() {
return new StringJoiner(", ", Membership.class.getSimpleName() + "[", "]")
.add("role='" + role + "'")
.add("member='" + member + "'")
.add("begin=" + begin)
.add("end=" + end)
.add("label='" + label + "'")
.add("wp=" + wp)
.toString();
}
}

View file

@ -0,0 +1,198 @@
package org.texttechnologylab.project.gruppe_05_1.domain.speaker;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
public abstract class Speaker {
String id;
String name;
String firstName;
String title;
LocalDate geburtsdatum; // in Mongo eigentlich LocalDateTime, ziemlich sinnlos
String geburtsort;
LocalDate sterbedatum; // in Mongo eigentlich LocalDateTime, ziemlich sinnlos
String geschlecht;
String beruf;
String akademischertitel;
String familienstand;
String religion;
String vita;
String party;
String primaryFoto;
List<Membership> memberships;
// TODO: List<Speech> speeches;
// TODO: Photos
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public LocalDate getGeburtsdatum() {
return geburtsdatum;
}
public void setGeburtsdatum(LocalDate geburtsdatum) {
this.geburtsdatum = geburtsdatum;
}
public String getGeburtsort() {
return geburtsort;
}
public void setGeburtsort(String geburtsort) {
this.geburtsort = geburtsort;
}
public LocalDate getSterbedatum() {
return sterbedatum;
}
public void setSterbedatum(LocalDate sterbedatum) {
this.sterbedatum = sterbedatum;
}
public String getGeschlecht() {
return geschlecht;
}
public void setGeschlecht(String geschlecht) {
this.geschlecht = geschlecht;
}
public String getBeruf() {
return beruf;
}
public void setBeruf(String beruf) {
this.beruf = beruf;
}
public String getAkademischertitel() {
return akademischertitel;
}
public void setAkademischertitel(String akademischertitel) {
this.akademischertitel = akademischertitel;
}
public String getFamilienstand() {
return familienstand;
}
public void setFamilienstand(String familienstand) {
this.familienstand = familienstand;
}
public String getReligion() {
return religion;
}
public void setReligion(String religion) {
this.religion = religion;
}
public String getVita() {
return vita;
}
public void setVita(String vita) {
this.vita = vita;
}
public String getParty() {
return party;
}
public void setParty(String party) {
this.party = party;
}
public String getPrimaryFoto() {
return primaryFoto;
}
public void setPrimaryFoto(String primaryFoto) {
this.primaryFoto = primaryFoto;
}
public List<Membership> getMemberships() {
return memberships;
}
public void setMemberships(List<Membership> memberships) {
this.memberships = memberships;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Speaker speaker)) return false;
return Objects.equals(id, speaker.id) && Objects.equals(name, speaker.name)
&& Objects.equals(firstName, speaker.firstName) && Objects.equals(title, speaker.title)
&& Objects.equals(geburtsdatum, speaker.geburtsdatum) && Objects.equals(geburtsort, speaker.geburtsort)
&& Objects.equals(sterbedatum, speaker.sterbedatum) && Objects.equals(geschlecht, speaker.geschlecht)
&& Objects.equals(beruf, speaker.beruf) && Objects.equals(akademischertitel, speaker.akademischertitel)
&& Objects.equals(familienstand, speaker.familienstand) && Objects.equals(religion, speaker.religion)
&& Objects.equals(vita, speaker.vita) && Objects.equals(party, speaker.party) && Objects.equals(memberships, speaker.memberships);
}
@Override
public int hashCode() {
return Objects.hash(id, name, firstName, title, geburtsdatum, geburtsort, sterbedatum, geschlecht,
beruf, akademischertitel, familienstand, religion, vita, party, memberships);
}
@Override
public String toString() {
return new StringJoiner(", ", Speaker.class.getSimpleName() + "[", "]")
.add("id='" + id + "'")
.add("name='" + name + "'")
.add("firstName='" + firstName + "'")
.add("title='" + title + "'")
.add("geburtsdatum=" + geburtsdatum)
.add("geburtsort='" + geburtsort + "'")
.add("sterbedatum=" + sterbedatum)
.add("geschlecht='" + geschlecht + "'")
.add("beruf='" + beruf + "'")
.add("akademischertitel='" + akademischertitel + "'")
.add("familienstand='" + familienstand + "'")
.add("religion='" + religion + "'")
.add("vita='" + vita + "'")
.add("party='" + party + "'")
.add("primaryFoto='" + primaryFoto + "'")
.add("memberships=" + memberships)
.toString();
}
}

View file

@ -0,0 +1,55 @@
package org.texttechnologylab.project.gruppe_05_1.domain.speech;
import java.util.Objects;
import java.util.StringJoiner;
public abstract class Agenda {
String index;
String id;
String title;
public String getIndex() {
return index;
}
public void setIndex(String index) {
this.index = index;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Agenda agenda)) return false;
return Objects.equals(index, agenda.index) && Objects.equals(id, agenda.id) && Objects.equals(title, agenda.title);
}
@Override
public int hashCode() {
return Objects.hash(index, id, title);
}
@Override
public String toString() {
return new StringJoiner(", ", Agenda.class.getSimpleName() + "[", "]")
.add("index='" + index + "'")
.add("id='" + id + "'")
.add("title='" + title + "'")
.toString();
}
}

View file

@ -0,0 +1,100 @@
package org.texttechnologylab.project.gruppe_05_1.domain.speech;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.Objects;
import java.util.StringJoiner;
public abstract class Protocol {
LocalDate date;
LocalTime starttime;
LocalTime endtime;
Integer index;
String titel;
String place;
Integer wp;
public LocalDate getDate() {
return date;
}
public void setDate(LocalDate date) {
this.date = date;
}
public LocalTime getStarttime() {
return starttime;
}
public void setStarttime(LocalTime starttime) {
this.starttime = starttime;
}
public LocalTime getEndtime() {
return endtime;
}
public void setEndtime(LocalTime endtime) {
this.endtime = endtime;
}
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
public String getTitel() {
return titel;
}
public void setTitel(String titel) {
this.titel = titel;
}
public String getPlace() {
return place;
}
public void setPlace(String place) {
this.place = place;
}
public Integer getWp() {
return wp;
}
public void setWp(Integer wp) {
this.wp = wp;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Protocol protocol)) return false;
return Objects.equals(date, protocol.date) && Objects.equals(starttime, protocol.starttime)
&& Objects.equals(endtime, protocol.endtime) && Objects.equals(index, protocol.index)
&& Objects.equals(titel, protocol.titel) && Objects.equals(place, protocol.place) && Objects.equals(wp, protocol.wp);
}
@Override
public int hashCode() {
return Objects.hash(date, starttime, endtime, index, titel, place, wp);
}
@Override
public String toString() {
return new StringJoiner(", ", Protocol.class.getSimpleName() + "[", "]")
.add("date=" + date)
.add("starttime=" + starttime)
.add("endtime=" + endtime)
.add("index=" + index)
.add("titel='" + titel + "'")
.add("place='" + place + "'")
.add("wp=" + wp)
.toString();
}
}

View file

@ -0,0 +1,86 @@
package org.texttechnologylab.project.gruppe_05_1.domain.speech;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
public abstract class Speech {
String id;
String text;
String speakerId;
Protocol protocol;
List<TextContent> textContents;
Agenda agenda;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getSpeakerId() {
return speakerId;
}
public void setSpeakerId(String speakerId) {
this.speakerId = speakerId;
}
public Protocol getProtocol() {
return protocol;
}
public void setProtocol(Protocol protocol) {
this.protocol = protocol;
}
public List<TextContent> getTextContents() {
return textContents;
}
public void setTextContents(List<TextContent> textContents) {
this.textContents = textContents;
}
public Agenda getAgenda() {
return agenda;
}
public void setAgenda(Agenda agenda) {
this.agenda = agenda;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Speech speech)) return false;
return Objects.equals(id, speech.id) && Objects.equals(text, speech.text) && Objects.equals(speakerId, speech.speakerId) && Objects.equals(protocol, speech.protocol) && Objects.equals(textContents, speech.textContents) && Objects.equals(agenda, speech.agenda);
}
@Override
public int hashCode() {
return Objects.hash(id, text, speakerId, protocol, textContents, agenda);
}
@Override
public String toString() {
return new StringJoiner(", ", Speech.class.getSimpleName() + "[", "]")
.add("id='" + id + "'")
.add("text='" + text + "'")
.add("speakerId='" + speakerId + "'")
.add("protocol=" + protocol)
.add("textContent=" + textContents)
.add("agenda=" + agenda)
.toString();
}
}

View file

@ -0,0 +1,65 @@
package org.texttechnologylab.project.gruppe_05_1.domain.speech;
import java.util.Objects;
import java.util.StringJoiner;
public abstract class TextContent {
String id;
String speakerId;
String text;
String type;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getSpeakerId() {
return speakerId;
}
public void setSpeakerId(String speakerId) {
this.speakerId = speakerId;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof TextContent that)) return false;
return Objects.equals(id, that.id) && Objects.equals(speakerId, that.speakerId) && Objects.equals(text, that.text) && Objects.equals(type, that.type);
}
@Override
public int hashCode() {
return Objects.hash(id, speakerId, text, type);
}
@Override
public String toString() {
return new StringJoiner(", ", TextContent.class.getSimpleName() + "[", "]")
.add("id='" + id + "'")
.add("speakerId='" + speakerId + "'")
.add("text='" + text + "'")
.add("type='" + type + "'")
.toString();
}
}

View file

@ -0,0 +1,313 @@
package org.texttechnologylab.project.gruppe_05_1.nlp;
import de.tudarmstadt.ukp.dkpro.core.api.metadata.type.DocumentMetaData;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Sentence;
import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token;
import org.apache.commons.io.FileUtils;
import org.apache.uima.UIMAException;
import org.apache.uima.cas.CASException;
import org.apache.uima.fit.factory.JCasFactory;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
import org.apache.uima.resource.ResourceInitializationException;
import org.dkpro.core.io.xmi.XmiWriter;
import org.texttechnologylab.DockerUnifiedUIMAInterface.DUUIComposer;
import org.texttechnologylab.DockerUnifiedUIMAInterface.driver.DUUIDockerDriver;
import org.texttechnologylab.DockerUnifiedUIMAInterface.driver.DUUIRemoteDriver;
import org.texttechnologylab.DockerUnifiedUIMAInterface.driver.DUUIUIMADriver;
import org.texttechnologylab.DockerUnifiedUIMAInterface.lua.DUUILuaContext;
import org.texttechnologylab.annotation.NamedEntity;
import org.texttechnologylab.uima.type.Sentiment;
import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Base64;
import java.util.Collection;
import static org.apache.uima.fit.factory.AnalysisEngineFactory.createEngineDescription;
public class NlpUtils {
// common class-attributes
private static DUUIComposer pComposer = null;
private static int iWorkers = 1;
public static void createNlpData() {
// Source: Dr. Abrami - Beispiel TODO
duuiInit();
runDockerDriver();
try {
runVideos();
} catch (Exception e) {
System.err.println("Exception: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
}
// Source:
casInit();
createSentenceInfo();
createNAmedEntities();
createSentimentInfo();
}
private static void duuiInit() {
DUUILuaContext ctx = null;
try {
ctx = new DUUILuaContext().withJsonLibrary();
} catch (IOException e) {
System.err.println("IOException: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
}
try {
pComposer = new DUUIComposer()
.withSkipVerification(true) // wir überspringen die Verifikation aller Componenten =)
.withLuaContext(ctx) // wir setzen den definierten Kontext
.withWorkers(iWorkers); // wir geben dem Composer eine Anzahl an Threads mit.
} catch (URISyntaxException e) {
System.err.println("URISyntaxException: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
}
DUUIUIMADriver uima_driver = new DUUIUIMADriver();
DUUIRemoteDriver remoteDriver = new DUUIRemoteDriver();
DUUIDockerDriver dockerDriver = null;
try {
dockerDriver = new DUUIDockerDriver();
} catch (IOException e) {
System.err.println("IOException: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
} catch (UIMAException e) {
System.err.println("UIMAException: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
} catch (SAXException e) {
System.err.println("SAXException: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
}
// Hinzufügen der einzelnen Driver zum Composer
// pComposer.addDriver(uima_driver, remoteDriver, dockerDriver); // ORIG
pComposer.addDriver(uima_driver);
}
/**
* Initialization of a sample CAS document
* @return
* @throws ResourceInitializationException
* @throws CASException
*/
public static JCas getCas() {
// init a CAS with a static text.
JCas pCas = null;
try {
pCas = JCasFactory.createText("Ich finde dieses Programm läuft sehr gut. Ich überlege wie ich dieses für meine Bachelor-Arbeit nachnutzen kann.", "de");
} catch (ResourceInitializationException e) {
System.err.println("ResourceInitializationException: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
} catch (CASException e) {
System.err.println("CASException: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
}
// Define some metadata to serialize the CAS with the xmi writer
DocumentMetaData dmd = new DocumentMetaData(pCas);
dmd.setDocumentId("test");
dmd.setDocumentTitle("DUUI Test-Dokument");
dmd.addToIndexes();
return pCas;
}
public static void runDockerDriver() {
// reset existing pipeline-components
pComposer.resetPipeline();
// Please note that the Docker images are first downloaded when they are called up for the first time.
try {
pComposer.add(new DUUIDockerDriver.Component("docker.texttechnologylab.org/textimager-duui-spacy-single-de_core_news_sm:0.1.4")
.withImageFetching()
.withScale(iWorkers)
.build());
} catch (Exception e) {
System.err.println("Exception: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
}
try {
pComposer.add(new DUUIDockerDriver.Component("docker.texttechnologylab.org/gervader_duui:1.0.2")
.withParameter("selection", "text") // nessecary
.withImageFetching()
.withScale(iWorkers)
.build());
} catch (Exception e) {
System.err.println("Exception: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
}
JCas tCas = getCas();
try {
pComposer.run(tCas);
} catch (Exception e) {
System.err.println("Exception: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
}
JCasUtil.select(tCas, Sentence.class).stream().forEach(sentence -> {
System.out.println(sentence.getBegin()+"-"+sentence.getEnd()+": "+sentence.getCoveredText());
System.out.println(JCasUtil.selectCovered(org.hucompute.textimager.uima.type.Sentiment.class, sentence));
});
}
private static void casInit() {
JCas jcas = null;
try {
jcas = JCasFactory.createJCas();
} catch (ResourceInitializationException e) {
System.err.println("ResourceInitializationException: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
} catch (CASException e) {
System.err.println("CASException: " + e.getMessage());
System.err.println(e.getStackTrace());
throw new RuntimeException(e);
}
jcas.setDocumentLanguage("de");
jcas.setDocumentText(
"Frau Präsidentin! Liebe Kolleginnen! Liebe Kollegen! Der Jahreswirtschaftsbericht war heute Gegenstand der Kabinettssitzung. Der Kollege Robert Habeck wird ihn im Wirtschaftsausschuss vorstellen, und morgen besteht ja auch hier Gelegenheit zur Debatte. Eine erfreuliche Nachricht ist, dass die Inflation zurückgeht. Eine der größten Bedrohungen für unsere wirtschaftliche Entwicklung und auch für den Lebensstandard der Bürgerinnen und Bürger ist die Geldentwertung. Im Zusammenwirken der Geldpolitik der Europäischen Zentralbank und der moderat restriktiven Fiskalpolitik der Bundesregierung haben wir große Fortschritte erzielt. Ich glaube, wir dürfen sagen: Die Entwicklung der Inflation ist nun beherrschbar geworden. Auf der anderen Seite ist die wirtschaftliche Entwicklung unseres Landes nicht zufriedenstellend. Wir haben eine zu geringe wirtschaftliche Dynamik. Dies hat damit zu tun, dass wir einen steigenden Zins und reduzierte Nachfrage auf den Weltmärkten aufgrund einer sich abkühlenden globalen Konjunktur haben, und auch die Folgen des Ausfalls günstiger fossiler Energieimporte nach Deutschland sind zu verzeichnen. Aber diese gegenwärtige Wachstumsschwäche unseres Landes passt sich ein in ein längeres Bild. In den vergangenen zehn Jahren, seit 2014, ist Deutschland in allen internationalen Standortvergleichen Schritt für Schritt zurückgefallen. Wir haben es also nicht mit einfachen Erklärungen zu tun, sondern mit strukturellen Aufgaben, denen wir uns stellen müssen. Ich leite daraus zwei Dinge ab: Erstens. Einfache Erklärungen sind nicht zutreffend. Zweitens. Alle, die in den vergangenen zehn Jahren Verantwortung getragen haben und heute Verantwortung tragen, sind aufgefordert, daran mitzuwirken, die Wachstumsdynamik in unserem Land zu verbessern. Ich will dazu konkret Folgendes sagen: Erstens. Die Bundesregierung setzt sich für eine Belebung auf unserem Arbeitsmarkt ein; denn der Mangel an Arbeitskräften ist eine Wachstumsbremse. In diesem Zusammenhang haben wir mit dem Fachkräfteeinwanderungsgesetz einen großen Fortschritt erzielt. Ihm müssen nun weitere Anstrengungen bei der Mobilisierung der Reserven unseres Arbeitsmarktes folgen. Zweitens. Die Bürokratiebelastung ist auf einem Allzeithoch seit dem Jahr 2012, in dem erstmals die Bürokratiebelastung gemessen worden ist. Mit den Meseberger Beschlüssen des Bundeskabinetts zum Bürokratieabbau werden diese Belastungen auf ein Allzeittief sinken, und wir müssen weitere Anstrengungen unternehmen, unsere Betriebe zu entfesseln. Drittens. Wir investieren auf einem Rekordniveau in Schiene, Straße, Wasserstraße, digitale Netze und in unsere Energieinfrastruktur. Aber diesen Anstrengungen müssen weitere folgen, insbesondere müssen jetzt die Rahmenbedingungen für private Investitionen und die Mobilisierung privaten Kapitals in Deutschland und Europa optimiert werden. Viertens. Unser steuerliches Umfeld, unsere steuerlichen Rahmenbedingungen müssen wettbewerbsfähiger werden. Die Bundesregierung und der Gesetzgeber haben ja bereits mit dem Zukunftsfinanzierungsgesetz Veränderungen vorgenommen, die sehr positiv wahrgenommen werden. Nun geht es darum, mit dem Wachstumschancengesetz einen weiteren Baustein gemeinsam zu beschließen, um im Bereich von Investitionsanreizen, zum Beispiel in der Baukonjunktur, und durch die Stärkung von privaten Forschungsvorhaben unserer Wirtschaft einen echten Schub zu geben. Hier kommt auch der Opposition eine besondere Verantwortung zu, mit dazu beizutragen, das wirtschaftliche Umfeld zu verbessern. Weitere Anstrengungen im Bereich der Steuerpolitik werden zu diskutieren sein. Liebe Kolleginnen und Kollegen, wir haben es gemeinsam im Zusammenwirken in Europa vermocht, die Geldentwertung unter Kontrolle zu bringen. Nun steht die nächste große Aufgabe vor uns: eine Wirtschaftswende, damit auch die Wachstumsdynamik unseres Landes wieder größer wird. "
);
Collection<Sentence> sentences = JCasUtil.select(jcas, Sentence.class);
for (Sentence sentence : sentences) {
// The text described by an annotation can be output using the getCoveredText() method
sentence.getCoveredText();
// Retrieve nested annotations, for example all tokens of a sentence
Collection<Token> tokens = JCasUtil.selectCovered(Token.class, sentence);
}
for (Token token : JCasUtil.select(jcas, Token.class)) {
System.out.println(token.getCoveredText() + '\t' + token.getPosValue());
}
for (NamedEntity entity : JCasUtil.select(jcas, NamedEntity.class)) {
if (entity.getValue().equals("PER")) {
System.out.println("Person: " + entity.getCoveredText());
}
else if (entity.getValue().equals("LOC")) {
System.out.println("Location: " + entity.getCoveredText());
}
}
for (Sentence sentence : JCasUtil.select(jcas, Sentence.class)) {
System.out.println(sentence.getCoveredText());
for (Sentiment sentiment : JCasUtil.selectCovered(Sentiment.class, sentence)) {
System.out.println("Sentiment: " + sentiment.getSentiment());
}
}
}
/**
* Execution of video processing via DUUI using the RemoteDriver
* @throws Exception
*/
public static void runVideos() throws Exception {
// laden eines Videos aus dem Ressourcen-Ordner
ClassLoader classLoader = NlpUtils.class.getClassLoader();
URL fVideo = classLoader.getResource("example.mp4"); // TODO
// convertieren eines Videos in einen Base64-String
File fFile = new File(fVideo.getPath());
byte[] bFile = FileUtils.readFileToByteArray(fFile);
String encodedString = Base64.getEncoder().encodeToString(bFile);
String pMimeType = Files.probeContentType(Path.of(fVideo.getPath()));
// erzeugng einer Beispiel-Cas
JCas pCas = getCas();
// erstellen einer view namens "video" und setzen des Mimetpes sowie der SofaData
JCas videoCas = pCas.createView("video");
videoCas.setSofaDataString(encodedString, pMimeType);
videoCas.setDocumentLanguage("de");
// erstellen einer weiteren View, für die Transcription
JCas transcriptCas = pCas.createView("transcript");
// this takes some time, because the video is not small, but also not to large.
pComposer.add(new DUUIRemoteDriver.Component("http://whisperx.lehre.texttechnologylab.org")
.withScale(iWorkers)
.withSourceView("video") // where is the video
.withTargetView("transcript") // where the transcript must be annotated
.build());
// alternativ
// pComposer.add(new DUUIDockerDriver.Component("docker.texttechnologylab.org/duui_whisperx:0.1")
// .withScale(iWorkers)
// .withSourceView("video")
// .withTargetView("transcript")
// .build());
// write into XMI for debugging purposes.
pComposer.add(new DUUIUIMADriver.Component(createEngineDescription(XmiWriter.class,
XmiWriter.PARAM_TARGET_LOCATION, "/tmp/",
XmiWriter.PARAM_PRETTY_PRINT, true,
XmiWriter.PARAM_OVERWRITE, true,
XmiWriter.PARAM_VERSION, "1.1",
XmiWriter.PARAM_COMPRESSION, "GZIP"
)).build());
pComposer.run(pCas);
// select some data
JCasUtil.selectAll(videoCas).stream().forEach(videoAnnotation->{
System.out.println(videoAnnotation);
});
// select some data
JCasUtil.selectAll(transcriptCas).stream().forEach(tAnnotation->{
System.out.println(tAnnotation);
});
}
private static void createSentenceInfo() {
}
private static void createNAmedEntities() {
}
private static void createSentimentInfo() {
}
}

View file

@ -0,0 +1,57 @@
package org.texttechnologylab.project.gruppe_05_1.rest;
import org.texttechnologylab.project.gruppe_05_1.util.GeneralUtils;
import org.texttechnologylab.project.gruppe_05_1.util.PropertiesUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
* Diese Klasse dient der Konfiguruerung von Javalin
*/
public class JavalinConfig extends Properties {
private static final String propertiesFileName = "javalin.properties";
/**
* Default Constructor
*/
public JavalinConfig() {
this(propertiesFileName);
}
/**
* Constructor mit Pfad zur Properties-Datei
* @param sPath
*/
public JavalinConfig(String sPath) {
try (InputStream input = PropertiesUtils.class.getClassLoader().getResourceAsStream(propertiesFileName)) {
if (null == input) {
System.err.println("Properties-Datei '" + propertiesFileName + "' konnte nicht gelesen werden");
}
this.load(input);
} catch (IOException ioex) {
System.err.println("Exception beim Lesen der properties-Datei '" + propertiesFileName + "': " + ioex.getLocalizedMessage());
}
}
/**
* Liefert alle Properties zurück
* @return Properties
*/
public Properties getJavalinProperties() {
return this;
}
/**
* Liefert den Port zurück, auf dem Javalin läuft
* @return
*/
public Integer getPort() {
return GeneralUtils.parseInt(getProperty("port"));
}
}

View file

@ -0,0 +1,94 @@
package org.texttechnologylab.project.gruppe_05_1.rest;
import io.javalin.http.Context;
import io.javalin.openapi.*;
import org.texttechnologylab.project.gruppe_05_1.domain.html.Parlamentarier;
import org.texttechnologylab.project.gruppe_05_1.domain.html.ParlamentarierDetails;
import org.texttechnologylab.project.gruppe_05_1.database.MongoPprUtils;
import org.texttechnologylab.project.gruppe_05_1.util.PPRUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Dieser Kontroller zeigt Informationen um den Parlamentariern:
* 1. Die Einstiegsseite: eine Filter-fähige Auflistung der Parlamentariern.
* Angezeigt werden Vor- und Nachname, Partei sowie ID.
* Die Filter-Funktion funktioniert für all diese Felder.
* 2. Ein Parlamentarierportfolio. Dieses beinhaltet:
* - Name und Partei im Header
* - Foto, falls ein Foto als Primärfoto angegeben wurde
* - Die Anzahl der Reden + Link auf die Redenseite des Parlamentariers
* - Persönliche Daten (Titel, Geschlecht, Religion, Beruf, Vita etc.)
* - Eine Auflistung aller Mitgliedschaften
* - Eine Auflistung aller vorhandenen Fototupeln. Für jedes Tupel steht einen Link, um diese zu editieren
*/
public class ParlamentarierController {
/**
* Liste alle Abgeordnete.
* Der Query-Parameter "filter" kann die Menge der Ergebnisse einschränken
* @param ctx JavaLin-Context
*/
@OpenApi(
summary = "Get alle Parlamentarier. Man kann nach Vor-, Nachname oder Partei filtern.",
description = "Listet alle Parlamentarier bzw. diejenige, welche den Filter entsprechen",
operationId = "getAllParlamentarier",
path = "/",
methods = HttpMethod.GET,
tags = {"Parlamentarier"},
queryParams = {
@OpenApiParam(name = "filter", description = "Full-Text-Filter. Kann Vorname, Nachname oder Partei filtern", required = false),
},
responses = {
@OpenApiResponse(status = "200", content = {@OpenApiContent(from = Parlamentarier[].class)})
})
public static void getAllParlamentarier(Context ctx) {
String filter = ctx.queryParam("filter");
System.out.println("Filter: '" + filter + "'");
List<Parlamentarier> parlamentarier = MongoPprUtils.getAllParlamentarier(filter);
PPRUtils.sortParlamentarierByName(parlamentarier);
System.out.println(parlamentarier.size() + " MdBs gefunden");
Map<String, Object> attributes = new HashMap<>();
attributes.put("parlamentarier", parlamentarier);
attributes.put("filter", filter);
ctx.render("parlamentarier.ftl", attributes);
}
/**
* Zeigt die Details eines Parlamentariers an:
* - persönliche Daten (Geburtsdatum, -ort, Vita, Religion etc.).
* - Mitgliederschaften, falls vorhanden
* - Fotos, falls vorhanden
* @param ctx JavaLin-Context
*/
@OpenApi(
summary = "Zeigt die Details eines Parlamentariers an",
description = "Zeigt persönliche Daten, Mitgliederschaften, Fotos",
operationId = "getParlamentarierDetails",
path = "/portfolio/{id}",
methods = HttpMethod.GET,
tags = {"Parlamentarier"},
pathParams = {
@OpenApiParam(name = "id", description = "id des Parlamentariers", required = true),
},
responses = {
@OpenApiResponse(status = "200", content = {@OpenApiContent(from = ParlamentarierDetails.class)})
})
public static void getParlamentarierDetails(Context ctx) {
String id = ctx.pathParam("id");
System.out.println("getParlamentarierDetails, ID = " + id);
ParlamentarierDetails pd = MongoPprUtils.getParlamentarierDetailsByID(id);
Map<String, Object> attributes = new HashMap<>();
attributes.put("p", pd);
attributes.put("speechesCount", pd.getReden() == null ? 0 : pd.getReden().size());
ctx.render("parlamentarierDetails.ftl", attributes);
}
}

View file

@ -0,0 +1,72 @@
package org.texttechnologylab.project.gruppe_05_1.rest;
import freemarker.template.Configuration;
import freemarker.template.TemplateExceptionHandler;
import io.javalin.Javalin;
import io.javalin.http.staticfiles.Location;
import io.javalin.openapi.plugin.OpenApiPlugin;
import io.javalin.openapi.plugin.redoc.ReDocPlugin;
import io.javalin.rendering.template.JavalinFreemarker;
import java.io.File;
import java.io.IOException;
public class RESTHandler {
public static final String TEMPLATE_DIR = "src/main/java/org/texttechnologylab/project/gruppe_05_1/website/templates";
public void startJavalin() {
// Javalin Konfiguration (z.B. port)
JavalinConfig jlConfig = new JavalinConfig();
int port = jlConfig.getPort();
// FreeMarker Konfiguration
Configuration fmConfig = new Configuration(Configuration.VERSION_2_3_33);
fmConfig.setDefaultEncoding("UTF-8");
try {
fmConfig.setDirectoryForTemplateLoading(new File(TEMPLATE_DIR));
} catch (IOException e) {
throw new RuntimeException(e);
}
fmConfig.setLogTemplateExceptions(true);
fmConfig.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
// Erzeuge die Javalin app
Javalin app = Javalin.create(config -> {
config.staticFiles.add("src/main/resources/public", Location.EXTERNAL); // momentan nicht benutzt
config.fileRenderer(new JavalinFreemarker(fmConfig));
config.registerPlugin(new OpenApiPlugin(pluginConfig -> {
// Define OpenAPI spec configuration
pluginConfig.withDefinitionConfiguration((version, definition) -> {
definition.withOpenApiInfo(info -> info.setTitle("Javalin OpenAPI Documentation"));
});
}));
config.registerPlugin(new ReDocPlugin());
})
.start(port);
// Routes
// ======
// Parlamentarier
app.get("/", ParlamentarierController::getAllParlamentarier);
app.get("/portfolio/{id}", ParlamentarierController::getParlamentarierDetails);
/* - TODO
// Fotos
app.get("/editFoto/{id}", FotosController::editFotos);
app.post("/editFoto/updateFotoUrl/{id}/{pictureId}", FotosController::updateFotoUrl);
app.post("/editFoto/defineFotoAsPrimary/{id}", FotosController::defineFotoAsPrimary);
// Reden
app.get("/reden/{id}", RedenController::listSpeeches); // zeige Reden eines Parlamentariers an
app.get("/reden/{id}/{redeId}", RedenController::showSpeech); // zeige eine bestimmte Rede des Parlamentariers an
app.post("/reden/updateComment/{id}/{speechId}/{commentId}", RedenController::updateComment); // aktualisiere Änderung an einer Kommentar
*/
}
}

View file

@ -0,0 +1,134 @@
package org.texttechnologylab.project.gruppe_05_1.util;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public abstract class FileUtils {
/**
* Creates a (possibly nested) directory
* @param dir (e.g. "generated" , "level1/level2/level3" etc.
*/
public static void createDirectoryIFNotExists(String dir) {
File directory = new File(dir);
if (! directory.exists()){
directory.mkdirs();
}
}
/**
* Write a list of Strings to file
* @param fileName
* @param stringsList
*/
public static void writeStringsToFile(String fileName, List<String> stringsList) {
FileWriter fileWriter = null;
try {
fileWriter = new FileWriter(fileName);
} catch (IOException e) {
throw new RuntimeException(e);
}
for (String str : stringsList) {
try {
fileWriter.write(str + System.lineSeparator());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
try {
fileWriter.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
*
* @param fileName
* @param string
*/
public static void writeStringToFile(String fileName, String string) {
FileWriter fileWriter = null;
try {
fileWriter = new FileWriter(fileName);
} catch (IOException e) {
throw new RuntimeException(e);
}
try {
fileWriter.write(string + System.lineSeparator());
} catch (IOException e) {
throw new RuntimeException(e);
}
try {
fileWriter.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
*
* @param fileName
* @return
* @throws IOException
*/
public static FileWriter createFileWriter(String fileName) throws IOException{
FileWriter fileWriter = null;
fileWriter = new FileWriter(fileName);
return fileWriter;
}
/**
*
* @param fileWriter
* @param stringsList
*/
public static void writeStringsToFile(FileWriter fileWriter, List<String> stringsList) {
for (String str : stringsList) {
try {
fileWriter.write(str + System.lineSeparator());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
try {
fileWriter.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
*
* @param dir
* @return
*/
public static Set<String> listFilesInDirectory(String dir) {
try (Stream<Path> stream = Files.list(Paths.get(dir))) {
return stream
.filter(file -> !Files.isDirectory(file))
.map(Path::getFileName)
.map(Path::toString)
.collect(Collectors.toSet());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}

View file

@ -0,0 +1,89 @@
package org.texttechnologylab.project.gruppe_05_1.util;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public abstract class GeneralUtils {
/**
*
* @param integer
* @return
*/
public static Integer parseInt(String integer) {
try {
return Integer.parseInt(integer);
} catch (NumberFormatException ex) {
return null;
}
}
/**
* Parse a date in the format used in Germany
* @param date
* @return
*/
public static LocalDate parseDate(String date) {
try {
return LocalDate.parse(date, DateTimeFormatter.ofPattern("dd.MM.yyyy"));
} catch (DateTimeParseException ex) {
return null;
}
}
/**
* Parse tiem in a give format
* @param date
* @param timeFormat
* @return
*/
public static LocalTime parseTime(String date, String timeFormat) {
try {
return LocalTime.parse(date, DateTimeFormatter.ofPattern(timeFormat));
} catch (DateTimeParseException ex) {
return null;
}
}
/**
* Parse a Formatiere Datumsfelder wie in Deutschland üblich ist.
* @param date
* @return
*/
public static String formatDate(LocalDate date) {
if (null== date) return "";
return date.format(DateTimeFormatter.ofPattern("dd.MM.yyyy"));
}
/**
* Format time in the format used in Germany
* @param time
* @return
*/
public static String formatTime(LocalTime time) {
if (null== time) return "";
return time.format(DateTimeFormatter.ofPattern("HH.mm"));
}
}

View file

@ -0,0 +1,357 @@
package org.texttechnologylab.project.gruppe_05_1.util;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Indexes;
import org.texttechnologylab.project.gruppe_05_1.database.MongoDBHandler;
import org.texttechnologylab.project.gruppe_05_1.database.MongoObjectFactory;
import org.texttechnologylab.project.gruppe_05_1.database.MongoPprUtils;
import org.texttechnologylab.project.gruppe_05_1.domain.html.Parlamentarier;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.BiografischeAngaben;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Mdb;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.MdbDocument;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Speaker;
import org.texttechnologylab.project.gruppe_05_1.nlp.NlpUtils;
import org.texttechnologylab.project.gruppe_05_1.xml.FileObjectFactory;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.*;
import java.net.URL;
import java.util.*;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public abstract class PPRUtils {
public static final String PARTEILOS_KUERZEL = "Parteilos";
/**
* Prüfe, ob die Collections existieren. Falls nicht: erzeuge sie und lege Indizes an
*/
public static void ensureCollectionExist() {
Set<String> existingCollectionNames = MongoDBHandler.getCollectionNames();
if (existingCollectionNames.contains(MongoPprUtils.SPEAKER_COLLECTION_NAME)) {
MongoDBHandler.createCollection(MongoPprUtils.SPEAKER_COLLECTION_NAME);
// Add Indexes
MongoCollection<org.bson.Document> speakerCollection = MongoPprUtils.getSpeakerCollection();
// MongoDB creates automatically an index on "_id"
speakerCollection.createIndex(Indexes.ascending("name"));
speakerCollection.createIndex(Indexes.ascending("firstName"));
speakerCollection.createIndex(Indexes.ascending("party"));
}
if (existingCollectionNames.contains(MongoPprUtils.SPEECH_COLLECTION_NAME)) {
MongoDBHandler.createCollection(MongoPprUtils.SPEECH_COLLECTION_NAME);
// Add Indexes
MongoCollection<org.bson.Document> speechCollection = MongoPprUtils.getSpeechCollection();
// MongoDB creates automatically an index on "_id"
speechCollection.createIndex(Indexes.ascending("speaker"));
}
if (existingCollectionNames.contains(MongoPprUtils.COMMENT_COLLECTION_NAME)) {
MongoDBHandler.createCollection(MongoPprUtils.COMMENT_COLLECTION_NAME);
// TODO: Add Indexes
MongoCollection<org.bson.Document> commentCollection = MongoPprUtils.getCommentCollection();
// MongoDB creates automatically an index on "_id"
// commentCollection.createIndex(Indexes.ascending("???"));
}
if (existingCollectionNames.contains(MongoPprUtils.PICTURES_COLLECTION_NAME)) {
MongoDBHandler.createCollection(MongoPprUtils.PICTURES_COLLECTION_NAME);
// TODO: Add Indexes
MongoCollection<org.bson.Document> pictureCollection = MongoPprUtils.getPicturesCollection();
// MongoDB creates automatically an index on "_id"
// pictureCollection.createIndex(Indexes.ascending("???"));
}
}
/**
* Alle Informationen lesen...
* - Parlamentarier
* - Reden
* - Kommentare
* - etc.
* ... und in die Mongo-DB persistieren, falls noch nicht vorhanden sind.
* @param xmlFactory
*/
public static void parlamentExplorerInit(FileObjectFactory xmlFactory, MongoObjectFactory mongoFactory) {
//
Properties xmlProperties = PropertiesUtils.readPropertiesFromResource("xml.properties");
// MdB lesen: MDBs werden nur dann gelesen und persistiert, wenn die Collection noch leer ist
String mdbUrl = xmlProperties.getProperty("mdb_url");
if (MongoPprUtils.getSpeakerCollection().countDocuments() == 0) {
readAndPersistMdbs(mdbUrl, xmlFactory, mongoFactory);
} else {
System.out.println("MDBs (Speakers) werden nicht gelesen, da sie bereits in der Datenbank stehen");
}
// Reden und Kommentare einlesen und persistieren - TODO
readSpeechesAndComments(xmlFactory, mongoFactory);
// Fotos hochladen - TODO
readPhotos(mongoFactory);
// NLP-Analyse (Text und Video)
// TODO: Anpassung notwendig, Daten aus dem NEtz statt aus resources holen
// Achtung: läuft nicht unter Windows. Verwende Linux (nativ oder im Virtual Box)
// NlpUtils.createNlpData();
}
/**
* Fotos hochladen - TODO
* @param mongoFactory
*/
public static void readPhotos(MongoObjectFactory mongoFactory) {
}
/**
* Reden und Kommentare einlesen - TODO
* @param xmlFactory
* @param mongoFactory
*/
public static void readSpeechesAndComments(FileObjectFactory xmlFactory, MongoObjectFactory mongoFactory) {
}
/**
* Liest die MdBs aus der Bundestag-Seite und persistiere sie in die MongoDB
* @param mdbUrl
* @param xmlFactory
*/
public static void readAndPersistMdbs(String mdbUrl, FileObjectFactory xmlFactory, MongoObjectFactory mongoFactory) {
org.w3c.dom.Document mdbRoot = getMdbFromRemoteXmlZipfile(mdbUrl);
Element rootElement = mdbRoot.getDocumentElement();
// TODO: optional! persist the metadata of the <VERSION>1723434311</VERSION> element
MdbDocument doc = xmlFactory.createMdbDocument(rootElement);
List<Mdb> mdbList = doc.getMdbs();
List<Node> mdbNodes = XmlUtils.getChildrenByName(rootElement, "MDB");
for (Node mdbNode : mdbNodes) {
Speaker speaker = xmlFactory.createSpeaker(mdbNode);
System.out.println("Speaker " + speaker.getId() + " (" + speaker.getFirstName() + " " + speaker.getName() + ", " + speaker.getParty() + ")");
org.bson.Document speakerDoc = mongoFactory.createSpeaker(speaker);
MongoDBHandler.insertDocument(MongoPprUtils.getSpeakerCollection(), speakerDoc);
}
// TODO: persist each speaker!
// TODO: guard: if not in the DB already
}
/**
* Liest die MDB aus einer Zip-Datei der bundestag,de-Seite
* @param zipUrl
* @return
*/
private static org.w3c.dom.Document getMdbFromRemoteXmlZipfile(String zipUrl) {
URL url = null;
InputStream urlInputStream = null;
try {
url = new URL(zipUrl);
urlInputStream = url.openStream();
ZipInputStream zipInputStream = new ZipInputStream(urlInputStream);
ZipEntry entry;
// Temporary storage for XML and DTD content
ByteArrayOutputStream xmlOutputStream = new ByteArrayOutputStream();
ByteArrayOutputStream dtdOutputStream = new ByteArrayOutputStream();
while ((entry = zipInputStream.getNextEntry()) != null) {
String entryName = entry.getName();
if (entryName.equals("MDB_STAMMDATEN.XML")) {
copyStream(zipInputStream, xmlOutputStream); // copy the XML InputStream
} else if (entryName.equals("MDB_STAMMDATEN.DTD")) {
copyStream(zipInputStream, dtdOutputStream);// copy theDTD InputStream
}
zipInputStream.closeEntry();
}
if (xmlOutputStream.size() == 0 || dtdOutputStream.size() == 0) { // TODO
// throw new FileNotFoundException("XML or DTD not found in the ZIP archive");
}
InputStream xmlInputStreamFinal = new ByteArrayInputStream(xmlOutputStream.toByteArray());
InputStream dtdInputStreamFinal = new ByteArrayInputStream(dtdOutputStream.toByteArray());
org.w3c.dom.Document doc = XmlUtils.loadXmlDocumentFromRemoteZip(entry, xmlInputStreamFinal, dtdInputStreamFinal);
// Cleanup
zipInputStream.close();
urlInputStream.close();
return doc;
} catch (IOException e) {
// TODO
throw new RuntimeException(e);
}
}
/**
* Helper method to save a stream for a later use.
* We use it to save the DTD and the XML files of the MDBs, which are within a zipfile on the bundestag.de site
* @param input
* @param output
* @throws IOException
*/
private static void copyStream(InputStream input, OutputStream output) throws IOException {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = input.read(buffer)) != -1) {
output.write(buffer, 0, bytesRead);
}
}
/**
* Eine Liste von Parlamentariern nach Namen (erst nach Nachnamen, dann nach Vornamen) sortieren (aufsteigend)
* @param mdbList
*/
public static void sortParlamentarierByName(List<Parlamentarier> mdbList) {
mdbList.sort((o1, o2) -> {
int compareNachname = o1.getNachname().compareTo(o2.getNachname());
if (0 == compareNachname) {
return o1.getVorname().compareTo(o2.getVorname());
} else {
return compareNachname;
}
});
}
// TODO: altes Zeug, sortieren...
/**
* Alle Parteien (aus einer Liste der MdBs) herausfinden.
* null-Einträge durch einen Platzhalter ersetzen, damit später keine null pointer exceptions auftretten
* @param mdbList
* @return
*/
public static Set<String> getFraktionenFromMdbList(List<Mdb> mdbList) {
/* mdb --> BIOGRAFISCHE_ANGABEN --> PARTEI_KURZ ergibt die aussagekräftige Ergebnisse
* parteiKurz: [null, DRP, SPD, DPS, DP, WAV, BP, FU, SRP, CSUS, FDP, DIE LINKE., CDU, PDS/LL, GRÜNE,
* PDS, AfD, CSU, DIE GRÜNEN/BÜNDNIS 90, Plos, DSU, BSW, BÜNDNIS 90/DIE GRÜNEN, LKR,
* GB/ BHE, SSW, DPB, Die PARTEI, DZP, CVP, KPD]
*/
Set<String> parteikuerzel=
mdbList.stream()
.map(Mdb::getBio)
.map(BiografischeAngaben::getParteiKuerzel)
.collect(Collectors.toSet());
// Parteilose dabei?
if (parteikuerzel.contains(null)) {
parteikuerzel.remove(null);
parteikuerzel.add(PARTEILOS_KUERZEL);
}
return parteikuerzel;
}
/**
* Eine Zuordnung zwischen Partei und deren Mitgliedern erzeugen. Ein Mitglied ist hier die MDB-Struktur
* @param mdbList
* @return
*/
public static Map<String, List<Mdb>> createMdbParteiZuordnung(List<Mdb> mdbList) {
Map<String, List<Mdb>> zuordnung = new HashMap<>();
for (Mdb mdb : mdbList) {
String partei = mdb.getBio().getParteiKuerzel();
if (null == partei) {
partei = PARTEILOS_KUERZEL;
}
if (zuordnung.containsKey(partei)) {
zuordnung.get(partei).add(mdb);
} else {
zuordnung.put(partei, new ArrayList<>());
zuordnung.get(partei).add(mdb);
}
}
return zuordnung;
}
/**
* Eine Zuordnung zwischen Partei und deren Mitgliedern erzeugen. Ein Mitglied wird hier durch seine ID erfaßt
* @param parteien
* @param mdbList
* @return
*/
public static Map<String, List<String>> getMdbParteiZuordnung(Set<String> parteien, List<Mdb> mdbList) {
Map<String, List<String>> zuordnung = new HashMap<>();
for (String partei : parteien) {
if (partei.equals(PARTEILOS_KUERZEL)) {
List<String> ids = mdbList.stream()
.filter(mdb -> (null == mdb.getBio().getParteiKuerzel()))
.map(Mdb::getId)
.collect(Collectors.toList());
zuordnung.put(partei, ids);
} else {
List<String> ids = mdbList.stream()
.filter(mdb -> (( null != mdb.getBio().getParteiKuerzel() ) && (mdb.getBio().getParteiKuerzel().equals(partei))))
.map(Mdb::getId)
.collect(Collectors.toList());
zuordnung.put(partei, ids);
}
}
return zuordnung;
}
/**
* Eine Zuordnung zwischen MdB (repräsentiert durch seine ID) und seien biographischen Daten erzeugen.
* @param mdbList
* @return
*/
public static Map<String, BiografischeAngaben> getMdbParteiZuordnung(List<Mdb> mdbList) {
Map<String, BiografischeAngaben> zuordnung = new HashMap<>();
for (Mdb mdb : mdbList) {
zuordnung.put(mdb.getId(), mdb.getBio());
}
return zuordnung;
}
/**
* Eine Liste von MdBs nach Namen (erst nach Nachnamen, dann nach Vornamen) sortieren (aufsteigend)
* @param mdbList
*/
public static void sortMdbByName(List<Mdb> mdbList) {
mdbList.sort((o1, o2) -> {
int compareNachname = o1.getNamen().get(0).getNachname().compareTo(o2.getNamen().get(0).getNachname());
if (0 == compareNachname) {
return o1.getNamen().get(0).getVorname().compareTo(o2.getNamen().get(0).getVorname());
} else {
return compareNachname;
}
});
}
}

View file

@ -0,0 +1,24 @@
package org.texttechnologylab.project.gruppe_05_1.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public abstract class PropertiesUtils {
public static Properties readPropertiesFromResource(String propertiesFileName) {
Properties properties = new Properties();
try (InputStream input = PropertiesUtils.class.getClassLoader().getResourceAsStream(propertiesFileName)) {
if (null == input) {
System.err.println("Properties-Datei '" + propertiesFileName + "' konnte nicht gelesen werden");
}
properties.load(input);
} catch (IOException ioex) {
System.err.println("Exception beim Lesen der properties-Datei '" + propertiesFileName + "': " + ioex.getLocalizedMessage());
}
return properties;
}
}

View file

@ -0,0 +1,252 @@
package org.texttechnologylab.project.gruppe_05_1.util;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public abstract class XmlUtils {
public static Document loadXmlDocumentFromRemoteZip(ZipEntry zipEntry,
InputStream xmlInputStream,
InputStream dtdInputStream) {
Document document = null;
// Set up a DocumentBuilderFactory and enable DTD validation
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
DocumentBuilder builder = null;
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
}
builder.setEntityResolver((publicId, systemId) -> {
if (systemId != null && systemId.endsWith(".DTD")) {
return new InputSource(dtdInputStream);
}
return null;
});
try {
document = builder.parse(xmlInputStream);
// TODO: Error handling...
} catch (SAXException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
document.getDocumentElement().normalize();
return document;
}
/**
* Read an XML document from a given path
* @param filePath (example: src/main/resources/myData.xml)
* @return
*/
public static Document loadXmlDocument(String filePath) {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
try {
builder = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
}
Document doc = null;
try {
doc = builder.parse(new File(filePath)); // systemID = "MDB_STAMMDATEN.DTD"
} catch (SAXException e) {
throw new RuntimeException(e);
} catch (IOException e) {
System.err.println(e);
System.err.println("\n");
System.err.println(e.getLocalizedMessage());
throw new RuntimeException(e);
}
doc.getDocumentElement().normalize();
return doc;
}
/**
* Read an XML document and return its root element
* @param filePath
* @return the root element of document
*/
public static Element getRootDocument(String filePath) {
Document doc = loadXmlDocument(filePath);
return doc.getDocumentElement();
}
/**
* Get a list of children nodes
* @param origin
* @return list of children nodes
*/
public static List<Node> getChildren(Element origin) {
NodeList nl = origin.getChildNodes();
for (int i=0 ; i< nl.getLength() ; i++) {
Node n = nl.item(i);
System.out.println(nl.item(i));
}
List<Node> list = new ArrayList<>();
Node current = origin.getFirstChild();
while (null != current) {
list.add(current);
current = current.getNextSibling();
}
return list;
}
/**
* Get a list of children nodes which have the specified name
* @param origin
* @param name
* @return list of children nodes with a specified name
*/
public static List<Node> getChildrenByName(Node origin, String name) {
List<Node> list = new ArrayList<>();
Node current = origin.getFirstChild();
while (null != current) {
if (current.getNodeName().equals(name)) {
list.add(current);
}
current = current.getNextSibling();
}
return list;
}
/**
* Get first child nodes which has the specified name
* @param origin
* @param name
* @return first child node with a specified name
*/
public static Node getFirstChildByName(Node origin, String name) {
Node current = origin.getFirstChild();
while (null != current) {
if (current.getNodeName().equals(name)) {
return current;
}
current = current.getNextSibling();
}
return null;
}
/**
*
* @param node
* @return attributes of the given node
*/
public static Map<String, String> getNodeAttributes(Node node) {
NamedNodeMap attributes = node.getAttributes();
Map<String, String> attributesList = new HashMap<>();
for (int i=0 ; i< attributes.getLength() ; i++) {
Node attributeNode = attributes.item(i);
attributesList.put(attributeNode.getNodeName(), attributeNode.getNodeValue());
}
return attributesList;
}
/**
*
* @param node
* @param attributeName
* @return
*/
public static String getNodeAttributeByName(Node node, String attributeName) {
NamedNodeMap attributes = node.getAttributes();
for (int i=0 ; i< attributes.getLength() ; i++) {
Node attributeNode = attributes.item(i);
if (attributeNode.getNodeName().equals(attributeName)) return attributeNode.getNodeValue();
}
return null;
}
/**
* Return the content of a Node as raw text
* @param node
* @return String
*/
public static String getRawText(Node node) {
return getRawText(node, 0);
}
private static String getRawText(Node node, int depth) {
StringBuilder sb = new StringBuilder();
String padding = " ".repeat(2 * depth);
switch (node.getNodeType()) {
case Node.TEXT_NODE: // 3
if ( ! node.getNodeValue().trim().isBlank()) {
sb.append(node.getNodeValue());
}
break;
case Node.ELEMENT_NODE: // 1
// Print tag
sb.append('\n').append(padding).append('<').append(node.getNodeName());
// Print attributes, if any
Map<String, String> attributes = getNodeAttributes(node);
if (attributes.isEmpty()) {
sb.append('>');
} else {
for (Map.Entry<String, String> entry : attributes.entrySet()) {
sb.append(' ').append(entry.getKey()).append("=\"").append(entry.getValue()).append('"');
}
sb.append('>');
}
// Visit all Children
NodeList children = node.getChildNodes();
for (int i=0 ; i < children.getLength() ; i++) {
Node child = children.item(i);
sb.append(getRawText(child, depth+1));
}
// Print closing tag
sb.append('\n').append(padding).append("</").append(node.getNodeName()).append('>');
break;
default:
System.out.println("Unknown type in getRawText(), depth " + depth
+"Type = " + node.getNodeType()
+ " / Name = '" + node.getNodeName()
+ "' / Value = '" + node.getNodeValue()
+ "' / Context = '" + node.getTextContent()
+ "'");
}
return sb.toString();
}
}

View file

@ -0,0 +1,23 @@
<tr>
<td>
${m.begin!'-'}
</td>
<td>
${m.end!'-'}
</td>
<td>
<#if m.label??>
${m.label}
</#if>
<#if m.role??>
<br>
Role: ${m.role}
</#if>
<#if m.wp??>
<br>
(WP: ${m.wp})
</#if>
</td>
</tr>

View file

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Abgeordnete Übersicht</title>
<link rel="stylesheet" href="styles.css">
<style type="text/css">
th, td {
padding: 12px;
text-align: center; /* Center-aligns both header and data cells */
border: 1px solid #ddd;
}
</style>
</head>
<body>
<header>
<h1>Abgeordnete (alphabetisch sortiert)</h1>
</header>
<main>
<form name="searchForm" action="/" method="get">
Name : <input type="text" name="filter" value="${filter!' '}" />
<input type="submit" value="Suche" />
</form>
<br>
<table>
<thead>
<tr>
<th>Name</th>
<th>Partei</th>
<th>ID</th>
</tr>
</thead>
<tbody>
<#list parlamentarier as p>
<tr>
<td><a href="portfolio/${p.id}">${p.nachname}, ${p.vorname}</a></td>
<td>${p.partei}</td>
<td>${p.id}</td>
</tr>
</#list>
</tbody>
</table>
<a href="/" class="back-link">Zurück zum Anfang</a>
</main>
</body>
</html>

View file

@ -0,0 +1,6 @@
<#if value??>
<tr>
<td> ${title} </td>
<td align=left> ${value} </td>
</tr>
</#if>

View file

@ -0,0 +1,101 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${p.vorname} ${p.nachname} (${p.partei})</title>
<style type="text/css">
th, td {
padding: 12px;
text-align: center; /* Center-aligns both header and data cells */
border: 1px solid #ddd;
}
</style>
</head>
<body>
<header>
<h1>${p.vorname} ${p.nachname} (${p.partei})</h1>
</header>
<br>
<#if p.primaryFoto??>
<img style="max-width: 400px; height: auto; " src="${p.primaryFoto}" alt="Abgeordneterfoto" >
<br> <br>
</#if>
<main>
<section>
<h2>Reden</h2>
<#if p.reden??>
<a href="/reden/${p.id}">${speechesCount} Reden vorhanden</a>
<#else>
Keine Reden
</#if>
<br> <br>
</section>
<section>
<h2>Persönliche Daten</h2>
<#include "persoenlicheDaten.ftl">
</section>
<br> <br> <br>
<#if p.memberships??>
<section>
<h2>Mitgliedschaften</h2>
<table>
<thead>
<tr>
<th>Von</th>
<th>Bis</th>
<th>Beschreibung</th>
</tr>
</thead>
<tbody>
<#list p.memberships as m>
<#include "memberships.ftl">
</#list>
</tbody>
</table>
</section>
</#if>
<br> <br> <br>
<#if p.pictures??>
<section>
<h2>Fotos</h2>
<table>
<thead>
<tr>
<th>Datum</th>
<th>Beschreibung</th>
<th>Foto (HP)</th>
<th>Foto (HQ)</th>
<th></th>
</tr>
</thead>
<tbody>
<#list p.pictures as pic>
<#include "pictures.ftl">
</#list>
</tbody>
</table>
</section>
</#if>
<br>
<form name="zurueck" action="/" method="get">
<br>
<input type="submit" value="Zurück" />
</form>
<br>
</main>
</body>
</html>

View file

@ -0,0 +1,64 @@
<table>
<tbody>
<#if p.akademischertitel??>
<#assign title = "Akademischer Titel">
<#assign value = "${p.akademischertitel}">
<#include "parlamentarierAttribut.ftl">
</#if>
<#if p.title??>
<#assign title = "Titel">
<#assign value = "${p.title}">
<#include "parlamentarierAttribut.ftl">
</#if>
<#if p.geschlecht??>
<#assign title = "Geschlecht">
<#assign value = "${p.geschlecht}">
<#include "parlamentarierAttribut.ftl">
</#if>
<#if p.familienstand??>
<#assign title = "Familienstand">
<#assign value = "${p.familienstand}">
<#include "parlamentarierAttribut.ftl">
</#if>
<#if p.beruf??>
<#assign title = "Beruf">
<#assign value = "${p.beruf}">
<#include "parlamentarierAttribut.ftl">
</#if>
<#if p.religion??>
<#assign title = "Religion">
<#assign value = "${p.religion}">
<#include "parlamentarierAttribut.ftl">
</#if>
<#if p.geburtsdatum??>
<#assign title = "Geburtsdatum">
<#assign value = "${p.geburtsdatum}">
<#include "parlamentarierAttribut.ftl">
</#if>
<#if p.geburtsort??>
<#assign title = "Geburtsort">
<#assign value = "${p.geburtsort}">
<#include "parlamentarierAttribut.ftl">
</#if>
<#if p.sterbedatum??>
<#assign title = "Sterbedatum">
<#assign value = "${p.sterbedatum}">
<#include "parlamentarierAttribut.ftl">
</#if>
<#if p.vita??>
<#assign title = "Vita">
<#assign value = "${p.vita}">
<#include "parlamentarierAttribut.ftl">
</#if>
</tbody>
</table>

View file

@ -0,0 +1,63 @@
package org.texttechnologylab.project.gruppe_05_1.xml;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.*;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Speaker;
import org.texttechnologylab.project.gruppe_05_1.xml.mdb.*;
import org.texttechnologylab.project.gruppe_05_1.xml.speaker.Speaker_File_Impl;
import org.w3c.dom.Node;
public class FileObjectFactory {
private static FileObjectFactory oFactory = null;
/**
*
* @return FileObjectFactory
*/
public static FileObjectFactory getFactory() {
if (oFactory == null) {
oFactory = new FileObjectFactory();
}
return oFactory;
}
/*
* *** MDB Strukturen ***
* =====================
*/
public BiografischeAngaben createBiografischeAngaben(Node node) {
return new BiografischeAngaben_File_Impl().fromXmlNode(node);
}
public Institution createInstitution(Node node) {
return new Institution_File_Impl().fromXmlNode(node);
}
public Mdb createMdb(Node node) {
return new Mdb_File_Impl().fromXmlNode(node);
}
public MdbDocument createMdbDocument(Node node) {
return new MdbDocument_File_Impl().fromXmlNode(node);
}
public MdbName createMdbName(Node node) {
return new MdbName_File_Impl().fromXmlNode(node);
}
public Wahlperiode createWahlperiode(Node node) {
return new Wahlperiode_File_Impl().fromXmlNode(node);
}
/*
* *** Redner- Strukturen ***
* =====================
*/
public Speaker createSpeaker(Node node) {
return new Speaker_File_Impl().fromXmlNode(node);
}
}

View file

@ -0,0 +1,8 @@
package org.texttechnologylab.project.gruppe_05_1.xml;
import org.w3c.dom.Node;
public interface XmlOperations {
FileObjectFactory factory = FileObjectFactory.getFactory();
public Object fromXmlNode(Node node);
}

View file

@ -0,0 +1,74 @@
package org.texttechnologylab.project.gruppe_05_1.xml.mdb;
import org.texttechnologylab.project.gruppe_05_1.domain.Gender;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.BiografischeAngaben;
import org.texttechnologylab.project.gruppe_05_1.util.GeneralUtils;
import org.texttechnologylab.project.gruppe_05_1.xml.XmlOperations;
import org.w3c.dom.Node;
public class BiografischeAngaben_File_Impl extends BiografischeAngaben implements XmlOperations {
@Override
public BiografischeAngaben fromXmlNode(Node node) {
Node current = node.getFirstChild();
Node child;
BiografischeAngaben bio = new BiografischeAngaben_File_Impl();
while (null != current) {
child = current.getFirstChild();
switch (current.getNodeName()) {
case "GEBURTSDATUM":
bio.setGeburtsdatum(null == child ? null : GeneralUtils.parseDate(child.getNodeValue()));
break;
case "GEBURTSORT":
bio.setGeburtsort(null == child ? null : child.getNodeValue());
break;
case "GEBURTSLAND":
bio.setGeburtsland(null == child ? null : child.getNodeValue());
break;
case "STERBEDATUM":
bio.setSterbedatum(null == child ? null : GeneralUtils.parseDate(child.getNodeValue()));
break;
case "GESCHLECHT":
bio.setGender(null == child ? null : child.getNodeValue());
break;
case "FAMILIENSTAND":
bio.setFamilienstand(null == child ? null : child.getNodeValue());
break;
case "RELIGION":
bio.setReligion(null == child ? null : child.getNodeValue());
break;
case "BERUF":
bio.setBeruf(null == child ? null : child.getNodeValue());
break;
case "PARTEI_KURZ":
bio.setParteiKuerzel(null == child ? null : child.getNodeValue());
break;
case "VITA_KURZ":
bio.setVitaKurz(null == child ? null : child.getNodeValue());
break;
case "VEROEFFENTLICHUNGSPFLICHTIGES":
bio.setVeroeffentlichungspflichtiges(null == child ? null : child.getNodeValue());
break;
case "#text":
break;
default:
System.err.println("Node name does not match anything known in BiografischeAngaben: " + current.getNodeName());
}
current = current.getNextSibling();
}
return bio;
}
}

View file

@ -0,0 +1,58 @@
package org.texttechnologylab.project.gruppe_05_1.xml.mdb;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Institution;
import org.texttechnologylab.project.gruppe_05_1.util.GeneralUtils;
import org.texttechnologylab.project.gruppe_05_1.xml.XmlOperations;
import org.w3c.dom.Node;
public class Institution_File_Impl extends Institution implements XmlOperations {
@Override
public Institution fromXmlNode(Node node) {
Node current = node.getFirstChild();
Node child;
Institution inst = new Institution_File_Impl();
while (null != current) {
child = current.getFirstChild();
switch (current.getNodeName()) {
case "INSART_LANG":
inst.setInsartLang(null == child ? null : child.getNodeValue());
break;
case "INS_LANG":
inst.setInsLang(null == child ? null : child.getNodeValue());
break;
case "MDBINS_VON":
inst.setMdbinsVon(null == child ? null : GeneralUtils.parseDate(child.getNodeValue()));
break;
case "MDBINS_BIS":
inst.setMdbinsBis(null == child ? null : GeneralUtils.parseDate(child.getNodeValue()));
break;
case "FKT_LANG":
inst.setFktLang(null == child ? null : child.getNodeValue());
break;
case "FKTINS_VON":
inst.setFktinsVon(null == child ? null : GeneralUtils.parseDate(child.getNodeValue()));
break;
case "FKTINS_BIS":
inst.setFktinsBis(null == child ? null : GeneralUtils.parseDate(child.getNodeValue()));
break;
case "#text":
break;
default:
System.err.println("Node name does not match anything known in Institution: " + current.getNodeName());
}
current = current.getNextSibling();
}
return inst;
}
}

View file

@ -0,0 +1,30 @@
package org.texttechnologylab.project.gruppe_05_1.xml.mdb;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Mdb;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.MdbDocument;
import org.texttechnologylab.project.gruppe_05_1.util.XmlUtils;
import org.texttechnologylab.project.gruppe_05_1.xml.XmlOperations;
import org.w3c.dom.Node;
import java.util.ArrayList;
import java.util.List;
public class MdbDocument_File_Impl extends MdbDocument implements XmlOperations {
@Override
public MdbDocument fromXmlNode(Node node) {
MdbDocument doc = new MdbDocument_File_Impl();
Node versionNode = XmlUtils.getFirstChildByName(node, "VERSION");
doc.setVersion(versionNode.getFirstChild().getNodeValue());
List<Mdb> mdbs = new ArrayList<>();
List<Node> mdbNodeList = XmlUtils.getChildrenByName(node, "MDB");
for (Node mdbNode : mdbNodeList) {
Mdb mdb = factory.createMdb(mdbNode);
mdbs.add(mdb);
}
doc.setMdbs(mdbs);
return doc;
}
}

View file

@ -0,0 +1,66 @@
package org.texttechnologylab.project.gruppe_05_1.xml.mdb;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.MdbName;
import org.texttechnologylab.project.gruppe_05_1.util.GeneralUtils;
import org.texttechnologylab.project.gruppe_05_1.xml.XmlOperations;
import org.w3c.dom.Node;
public class MdbName_File_Impl extends MdbName implements XmlOperations {
@Override
public MdbName fromXmlNode(Node node) {
Node current = node.getFirstChild();
Node child;
MdbName name = new MdbName_File_Impl();
while (null != current) {
child = current.getFirstChild();
switch (current.getNodeName()) {
case "NACHNAME":
name.setNachname(null == child ? null : child.getNodeValue());
break;
case "VORNAME":
name.setVorname(null == child ? null : child.getNodeValue());
break;
case "ORTSZUSATZ":
name.setOrtszusatz(null == child ? null : child.getNodeValue());
break;
case "ADEL":
name.setAdel(null == child ? null : child.getNodeValue());
break;
case "PRAEFIX":
name.setPraefix(null == child ? null : child.getNodeValue());
break;
case "ANREDE_TITEL":
name.setAndereTitel(null == child ? null : child.getNodeValue());
break;
case "AKAD_TITEL":
name.setAkadTitel(null == child ? null : child.getNodeValue());
break;
case "HISTORIE_VON":
name.setHistorieVon(null == child ? null : GeneralUtils.parseDate(child.getNodeValue()));
break;
case "HISTORIE_BIS":
name.setHistorieBis(null == child ? null : GeneralUtils.parseDate(child.getNodeValue()));
break;
case "#text":
break;
default:
System.err.println("Node name does not match anything known in Name: " + current.getNodeName());
}
current = current.getNextSibling();
}
return name;
}
}

View file

@ -0,0 +1,44 @@
package org.texttechnologylab.project.gruppe_05_1.xml.mdb;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Mdb;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.MdbName;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.Wahlperiode;
import org.texttechnologylab.project.gruppe_05_1.util.XmlUtils;
import org.texttechnologylab.project.gruppe_05_1.xml.XmlOperations;
import org.w3c.dom.Node;
import java.util.ArrayList;
import java.util.List;
public class Mdb_File_Impl extends Mdb implements XmlOperations {
@Override
public Mdb fromXmlNode(Node node) {
Mdb mdb = new Mdb_File_Impl();
Node idNode = XmlUtils.getFirstChildByName(node, "ID");
mdb.setId(idNode.getFirstChild().getNodeValue());
Node namenNode = XmlUtils.getFirstChildByName(node, "NAMEN");
List<Node> nameNodeList = XmlUtils.getChildrenByName(namenNode, "NAME");
List<MdbName> mdbNameList = new ArrayList<>();
for (Node nameNode : nameNodeList) {
MdbName mdbName = factory.createMdbName(nameNode);
mdbNameList.add(mdbName);
}
mdb.setNamen(mdbNameList);
Node bioNode = XmlUtils.getFirstChildByName(node, "BIOGRAFISCHE_ANGABEN");
mdb.setBio(factory.createBiografischeAngaben(bioNode));
Node wpenNode = XmlUtils.getFirstChildByName(node, "WAHLPERIODEN");
List<Node> wpNodeList = XmlUtils.getChildrenByName(wpenNode, "WAHLPERIODE");
List<Wahlperiode> wpList = new ArrayList<>();
for (Node wpNode : wpNodeList) {
Wahlperiode wp = factory.createWahlperiode(wpNode);
wpList.add(wp);
}
mdb.setWahlperioden(wpList);
return mdb;
}
}

View file

@ -0,0 +1,82 @@
package org.texttechnologylab.project.gruppe_05_1.xml.mdb;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.*;
import org.texttechnologylab.project.gruppe_05_1.util.GeneralUtils;
import org.texttechnologylab.project.gruppe_05_1.util.XmlUtils;
import org.texttechnologylab.project.gruppe_05_1.xml.XmlOperations;
import org.w3c.dom.Node;
import java.util.ArrayList;
import java.util.List;
public class Wahlperiode_File_Impl extends Wahlperiode implements XmlOperations {
@Override
public Wahlperiode fromXmlNode(Node node) {
Node current = node.getFirstChild();
Node child;
Wahlperiode wp = new Wahlperiode_File_Impl();
while (null != current) {
child = current.getFirstChild();
switch (current.getNodeName()) {
case "WP":
wp.setWp(null == child ? null : GeneralUtils.parseInt(child.getNodeValue()));
break;
case "MDBWP_VON":
wp.setMdbWpVon(null == child ? null : GeneralUtils.parseDate(child.getNodeValue()));
break;
case "MDBWP_BIS":
wp.setMdbWpBis(null == child ? null : GeneralUtils.parseDate(child.getNodeValue()));
break;
case "WKR_NUMMER":
wp.setWknNr(null == child ? null : child.getNodeValue());
break;
case "WKR_NAME":
wp.setWkrName(null == child ? null : child.getNodeValue());
break;
case "WKR_LAND":
wp.setWkrLand(null == child ? null : child.getNodeValue());
break;
case "LISTE":
wp.setListe(null == child ? null : child.getNodeValue());
break;
case "MANDATSART":
if (null == child) {
wp.setMandatsart(Mandatsart.NA);
} else {
wp.setMandatsart(Mandatsart.byText(child.getNodeValue()));
}
break;
case "INSTITUTIONEN":
// Node institutionenNode = XmlUtils.getFirstChildByName(node, "INSTITUTIONEN");
List<Node> institutionNodeList = XmlUtils.getChildrenByName(current, "INSTITUTION");
List<Institution> institutionList = new ArrayList<>();
for (Node institutionNode : institutionNodeList) {
Institution inst = factory.createInstitution(institutionNode);
institutionList.add(inst);
}
wp.setInstitutionen(institutionList);
break;
case "#text":
break;
default:
System.err.println("Node name does not match anything known in Wahlperiode: " + current.getNodeName());
}
current = current.getNextSibling();
}
return wp;
}
}

View file

@ -0,0 +1,89 @@
package org.texttechnologylab.project.gruppe_05_1.xml.speaker;
import org.texttechnologylab.project.gruppe_05_1.domain.mdb.*;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Membership;
import org.texttechnologylab.project.gruppe_05_1.domain.speaker.Speaker;
import org.texttechnologylab.project.gruppe_05_1.util.GeneralUtils;
import org.texttechnologylab.project.gruppe_05_1.util.PPRUtils;
import org.texttechnologylab.project.gruppe_05_1.util.XmlUtils;
import org.texttechnologylab.project.gruppe_05_1.xml.XmlOperations;
import org.w3c.dom.Node;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
public class Speaker_File_Impl extends Speaker implements XmlOperations {
@Override
public Speaker fromXmlNode(Node node) {
Speaker speaker = new Speaker_File_Impl();
// ID
Node idNode = XmlUtils.getFirstChildByName(node, "ID");
speaker.setId(idNode.getFirstChild().getNodeValue());
// Name: alle Namen lesen, nur den letzten berücksichtigen
Node namenNode = XmlUtils.getFirstChildByName(node, "NAMEN");
List<Node> nameNodeList = XmlUtils.getChildrenByName(namenNode, "NAME");
List<MdbName> mdbNameList = new ArrayList<>();
for (Node nameNode : nameNodeList) {
MdbName mdbName = factory.createMdbName(nameNode);
mdbNameList.add(mdbName);
}
mdbNameList.sort((n1, n2 )-> n2.getHistorieVon().compareTo(n1.getHistorieVon())); // Descending order
MdbName newestMdbName = mdbNameList.get(0); // TODO
speaker.setName(newestMdbName.getNachname());
speaker.setFirstName(newestMdbName.getVorname());
speaker.setAkademischertitel(newestMdbName.getAkadTitel());
speaker.setTitle(newestMdbName.getAndereTitel());
// Biografische Daten:
Node bioNode = XmlUtils.getFirstChildByName(node, "BIOGRAFISCHE_ANGABEN");
BiografischeAngaben bio = factory.createBiografischeAngaben(bioNode);
if (bio.getGeburtsland() == null || bio.getGeburtsland().isBlank()) {
speaker.setGeburtsort(bio.getGeburtsort());
} else {
speaker.setGeburtsort(bio.getGeburtsort() + " (" + bio.getGeburtsland() + ")");
}
speaker.setGeburtsdatum(bio.getGeburtsdatum());
speaker.setSterbedatum(bio.getSterbedatum());
speaker.setGeschlecht(bio.getGender());
speaker.setBeruf(bio.getBeruf());
speaker.setFamilienstand(bio.getFamilienstand());
speaker.setReligion(bio.getReligion());
speaker.setVita(bio.getVitaKurz());
// Da wir nach Partei sortieren und vergleichen, darf das Feld nicht null sein...
speaker.setParty(bio.getParteiKuerzel() == null ? PPRUtils.PARTEILOS_KUERZEL : bio.getParteiKuerzel());
// Memberships
Node wpenNode = XmlUtils.getFirstChildByName(node, "WAHLPERIODEN");
List<Node> wpNodeList = XmlUtils.getChildrenByName(wpenNode, "WAHLPERIODE");
List<Wahlperiode> wpList = new ArrayList<>();
for (Node wpNode : wpNodeList) {
Wahlperiode wp = factory.createWahlperiode(wpNode);
wpList.add(wp);
}
wpList.sort((wp1, wp2 )-> wp2.getMdbWpVon().compareTo(wp1.getMdbWpVon())); // Descending order
List<Membership> memberships = new ArrayList<>();
for (Wahlperiode wp : wpList) {
LocalDate mdbwpVon = wp.getMdbWpVon();
LocalDate mdbwpBis = wp.getMdbWpBis();
for (Institution inst : wp.getInstitutionen()) {
Membership m = new Membership();
m.setBegin(inst.getMdbinsVon() == null? mdbwpVon : inst.getMdbinsVon());
m.setEnd(inst.getFktinsBis() == null? mdbwpBis : inst.getFktinsBis());
m.setRole(inst.getFktLang());
m.setLabel(inst.getInsLang());
m.setWp(wp.getWp());
memberships.add(m);
}
}
speaker.setMemberships(memberships);
return speaker;
}
}

BIN
src/main/resources/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -0,0 +1 @@
port=5876

View file

@ -0,0 +1,7 @@
localserver_x_nur_testing=mongodb://localhost:27017
remote_host = ppr.lehre.texttechnologylab.org
remote_database = PPR_WiSe24_Project_5_1
remote_user = PPR_WiSe24_Project_5_1_rw
remote_password = E7H3ICPG
remote_port = 27020
remote_collection = speeches

View file

@ -0,0 +1,7 @@
localserver=mongodb://localhost:27017
remote_host=ppr.lehre.texttechnologylab.org
remote_database=PPR_WiSe24_264
remote_user=PPR_WiSe24_264_rw
remote_password=XPs5GfDf
remote_port=27020
remote_collection=speeches

View file

@ -0,0 +1,298 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--DTD für Plenar-Protokolle des Deutschen Bundestags
Erstellt von: SRZ - Satz-Rechen-Zentrum Hartmann+Heenemann GmbH&Co. KG
Aktualisiert von: SRZ Berlin
Version: 1.0.2
Stand: 05.09.2023
<!DOCTYPE dbtplenarprotokoll SYSTEM "dbtplenarprotokoll.dtd">
-->
<!ENTITY % inline-elemente "xref | sub | sup | fussnote | a" >
<!ELEMENT sub (#PCDATA) >
<!ELEMENT sup (#PCDATA) >
<!ELEMENT dbtplenarprotokoll (vorspann, sitzungsverlauf, anlagen, rednerliste) >
<!ATTLIST dbtplenarprotokoll
wahlperiode CDATA #REQUIRED
sitzung-nr CDATA #REQUIRED
sitzung-datum CDATA #REQUIRED
sitzung-start-uhrzeit CDATA #REQUIRED
sitzung-ende-uhrzeit CDATA #REQUIRED
sitzung-naechste-datum CDATA #REQUIRED
sitzung-ort CDATA #FIXED "Berlin"
herausgeber CDATA #FIXED "Deutscher Bundestag"
herstellung CDATA #REQUIRED
vertrieb CDATA #FIXED "Bundesanzeiger Verlag GmbH, Postfach 1 0 05 34, 50445 Köln, Telefon (02 21) 97 66 83 40, Fax (02 21) 97 66 83 44, www.bundesanzeiger-verlag.de"
issn CDATA #FIXED "0722-7980"
start-seitennr CDATA #REQUIRED
version CDATA #IMPLIED
status (erfasst | korrektur | freigegeben) #IMPLIED
kommentare CDATA #IMPLIED
>
<!-- VORSPANN ===================================-->
<!ELEMENT vorspann (kopfdaten, inhaltsverzeichnis) >
<!ELEMENT kopfdaten (plenarprotokoll-nummer, herausgeber, berichtart, sitzungstitel, sitzungstitel-zusatz?, veranstaltungsdaten) >
<!-- "Plenarprotokoll 17/228" 1. Seite oben rechts -->
<!ELEMENT plenarprotokoll-nummer (#PCDATA | wahlperiode | sitzungsnr )* >
<!ELEMENT wahlperiode (#PCDATA) >
<!ELEMENT sitzungsnr (#PCDATA) >
<!-- "Deutscher Bundestag" -->
<!ELEMENT herausgeber (#PCDATA) >
<!-- "Stenografischer Bericht" -->
<!ELEMENT berichtart (#PCDATA) >
<!-- "228. Sitzung" -->
<!ELEMENT sitzungstitel (#PCDATA | sitzungsnr)* >
<!-- "zugleich 955. Sitzung des Bundesrates" -->
<!ELEMENT sitzungstitel-zusatz (#PCDATA) >
<!-- "Berlin, Donnerstag, den 14. März 2013" -->
<!ELEMENT veranstaltungsdaten (#PCDATA | ort | datum)* >
<!-- "Berlin" -->
<!ELEMENT ort (#PCDATA) >
<!-- "Donnerstag, den 14. März 2013", Attribut date im Format TT.MM.JJJJ -->
<!ELEMENT datum (#PCDATA) >
<!ATTLIST datum
date CDATA #REQUIRED >
<!-- INHALTSVERZEICHNIS ===============================-->
<!ELEMENT inhaltsverzeichnis (ivz-titel, (ivz-block | ivz-eintrag)+) >
<!-- "Inhalt:" -->
<!ELEMENT ivz-titel (#PCDATA) >
<!ELEMENT ivz-block (ivz-block-titel?, (ivz-eintrag | ivz-block | p)+) >
<!ELEMENT ivz-block-titel (#PCDATA) >
<!ELEMENT ivz-eintrag (#PCDATA | ivz-eintrag-inhalt | xref | a)* >
<!ELEMENT ivz-eintrag-inhalt (#PCDATA | redner | a)* >
<!ELEMENT a (#PCDATA | seite | seitenbereich)* >
<!ATTLIST a
typ (druckseitennummer | bild | tabelle) #IMPLIED
id CDATA #IMPLIED
name CDATA #IMPLIED
href CDATA #IMPLIED
>
<!ELEMENT seite (#PCDATA) >
<!ELEMENT seitenbereich (#PCDATA) >
<!ELEMENT xref (#PCDATA | a)* >
<!ATTLIST xref
ref-type (rede | kommentar | anlage) #REQUIRED
rid CDATA #REQUIRED
pnr CDATA #REQUIRED
div CDATA #IMPLIED
>
<!-- SITZUNGSVERLAUF =============================-->
<!ELEMENT sitzungsverlauf (sitzungsbeginn?, rede*, tagesordnungspunkt+, sitzungsende?) >
<!ELEMENT sitzungsbeginn (#PCDATA | p | zitat | kommentar | a | name)* >
<!ATTLIST sitzungsbeginn sitzung-start-uhrzeit CDATA #REQUIRED >
<!ELEMENT tagesordnungspunkt (top-titel | name | rede | p | zitat | kommentar | a)* >
<!ATTLIST tagesordnungspunkt top-id CDATA #IMPLIED >
<!ELEMENT top-titel (#PCDATA | p | a)* >
<!ELEMENT sitzungsende (#PCDATA | p | a)* >
<!ATTLIST sitzungsende sitzung-ende-uhrzeit CDATA #REQUIRED >
<!-- REDE =======================================-->
<!ELEMENT rede (name | p | kommentar | zitat | a)+ >
<!ATTLIST rede
id ID #REQUIRED
redeart (plenum | zu_protokoll | zu_protokoll_anlage) #IMPLIED
>
<!ELEMENT redner (name)>
<!ATTLIST redner
id CDATA #REQUIRED
>
<!-- NAME
-->
<!ELEMENT name (#PCDATA | titel | vorname | nachname | namenszusatz | ortszusatz | fraktion | rolle | bdland)* >
<!ELEMENT titel (#PCDATA) >
<!ELEMENT vorname (#PCDATA) >
<!ELEMENT namenszusatz (#PCDATA) >
<!ELEMENT nachname (#PCDATA) >
<!ELEMENT ortszusatz (#PCDATA) >
<!ELEMENT fraktion (#PCDATA) >
<!ELEMENT rolle (rolle_lang | rolle_kurz)* >
<!ELEMENT rolle_lang (#PCDATA) >
<!ELEMENT rolle_kurz (#PCDATA) >
<!ELEMENT bdland (#PCDATA) >
<!-- Kommentar entsteht aus "K", "K-block", "K_klein" mit jedem Span -->
<!ELEMENT kommentar (#PCDATA | p | %inline-elemente;)* >
<!-- P (WIE PARAGRAF/ABSATZ)-->
<!ELEMENT p (#PCDATA | redner | table | %inline-elemente;)* >
<!ATTLIST p
klasse CDATA #IMPLIED
>
<!-- FUSSNOTE -->
<!ELEMENT fussnote (#PCDATA | p)* >
<!-- ZITAT -->
<!ELEMENT zitat (#PCDATA | p | %inline-elemente;)* >
<!-- ANLAGEN ===================================-->
<!ELEMENT anlagen (anlagen-titel?, anlage+) >
<!ELEMENT anlage (anlagen-titel?, anlagen-text+) >
<!ELEMENT anlagen-titel (#PCDATA | p | %inline-elemente;)* >
<!ELEMENT anlagen-text (#PCDATA | p | kommentar | rede | table | zitat | %inline-elemente;)* >
<!ATTLIST anlagen-text anlagen-typ CDATA #IMPLIED >
<!-- REDNERLISTE ===============================-->
<!ELEMENT rednerliste (redner+) >
<!ATTLIST rednerliste
sitzung-datum CDATA #REQUIRED
>
<!-- Tables ===================================-->
<!ENTITY % TFrame "(void|above|below|hsides|lhs|rhs|vsides|box|border)">
<!ENTITY % TRules "(none | groups | rows | cols | all)">
<!ENTITY % TAlign "(left|center|right)">
<!ENTITY % Character "CDATA">
<!ENTITY % Number "CDATA">
<!ENTITY % Length "CDATA">
<!ENTITY % MultiLength "CDATA">
<!ENTITY % MultiLengths "CDATA">
<!ENTITY % Pixels "CDATA">
<!ENTITY % Text "CDATA">
<!ENTITY % Color "CDATA">
<!ENTITY % cellhalign
"align (left|center|right|justify|char) #IMPLIED
char %Character; #IMPLIED
charoff %Length; #IMPLIED"
>
<!ENTITY % cellvalign
"valign (top|middle|bottom|baseline) #IMPLIED"
>
<!ENTITY % Scope "(row|col|rowgroup|colgroup)">
<!ELEMENT table (caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+)) >
<!ELEMENT caption (#PCDATA) >
<!ELEMENT thead (tr)+ >
<!ELEMENT tfoot (tr)+ >
<!ELEMENT tbody (tr)+ >
<!ELEMENT colgroup (col)* >
<!ELEMENT col EMPTY>
<!ELEMENT tr (th|td)+ >
<!ELEMENT th (#PCDATA | %inline-elemente;)* >
<!ELEMENT td (#PCDATA | %inline-elemente;)* >
<!ATTLIST table
summary %Text; #IMPLIED
width %Length; #IMPLIED
border %Pixels; #IMPLIED
frame %TFrame; #IMPLIED
rules %TRules; #IMPLIED
cellspacing %Length; #IMPLIED
cellpadding %Length; #IMPLIED
align %TAlign; #IMPLIED
bgcolor %Color; #IMPLIED
>
<!ENTITY % CAlign "(top|bottom|left|right)" >
<!ATTLIST caption
align %CAlign; #IMPLIED
>
<!ATTLIST colgroup
span %Number; "1"
width %MultiLength; #IMPLIED
%cellhalign;
%cellvalign;
>
<!ATTLIST col
span %Number; "1"
width %MultiLength; #IMPLIED
%cellhalign;
%cellvalign;
>
<!ATTLIST thead
%cellhalign;
%cellvalign;
>
<!ATTLIST tfoot
%cellhalign;
%cellvalign;
>
<!ATTLIST tbody
%cellhalign;
%cellvalign;
>
<!ATTLIST tr
%cellhalign;
%cellvalign;
bgcolor %Color; #IMPLIED
>
<!ATTLIST th
abbr %Text; #IMPLIED
axis CDATA #IMPLIED
headers IDREFS #IMPLIED
scope %Scope; #IMPLIED
rowspan %Number; "1"
colspan %Number; "1"
%cellhalign;
%cellvalign;
nowrap (nowrap) #IMPLIED
bgcolor %Color; #IMPLIED
width %Pixels; #IMPLIED
height %Pixels; #IMPLIED
>
<!ATTLIST td
abbr %Text; #IMPLIED
axis CDATA #IMPLIED
headers IDREFS #IMPLIED
scope %Scope; #IMPLIED
rowspan %Number; "1"
colspan %Number; "1"
%cellhalign;
%cellvalign;
nowrap (nowrap) #IMPLIED
bgcolor %Color; #IMPLIED
width %Pixels; #IMPLIED
height %Pixels; #IMPLIED
>

View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<body>
<h1>Heading</h1>
<p>paragraph.</p>
</body>
</html>

View file

@ -0,0 +1,7 @@
mdb_url=https://www.bundestag.de/resource/blob/472878/4d360eba29319547ed7fce385335a326/MdB-Stammdaten-data.zip
# TODO: cleanup...
mdb_file_name=mdb/MDB_STAMMDATEN.XML
mdb_full_file_name=mdb/MDB_STAMMDATEN.XML
mdb_short_file_name=mdb/MDB_STAMMDATEN_SHORT.XML
protokolle_dir=plenarprotokolle