Slight restructuring
This commit is contained in:
parent
bf0a242265
commit
5d6cb314a1
2 changed files with 16 additions and 2 deletions
|
@ -8,6 +8,7 @@ import org.texttechnologylab.project.gruppe_05_1.database.MongoPprUtils;
|
|||
import org.texttechnologylab.project.gruppe_05_1.domain.html.HtmlSpeech;
|
||||
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.nlp.Sentiment;
|
||||
import org.texttechnologylab.project.gruppe_05_1.domain.nlp.Token;
|
||||
import org.texttechnologylab.project.gruppe_05_1.domain.nlp.Topic;
|
||||
import org.texttechnologylab.project.gruppe_05_1.domain.speech.SpeechMetaData;
|
||||
|
@ -151,6 +152,7 @@ public class FrontEndController {
|
|||
@OpenApiResponse(status = "200", content = {@OpenApiContent(from = Speech.class)})
|
||||
})
|
||||
public static void showSpeech(Context ctx) {
|
||||
String parlamentarierId = ctx.pathParam("id");
|
||||
String redeId = ctx.pathParam("redeId");
|
||||
|
||||
Map<String, Object> attributes = new HashMap<>();
|
||||
|
@ -158,6 +160,10 @@ public class FrontEndController {
|
|||
HtmlSpeech speech = MongoPprUtils.getSpeechByKey(redeId);
|
||||
attributes.put("s", speech);
|
||||
|
||||
// Foto des Abgeordnetes
|
||||
String picture = MongoPprUtils.getParlamentarierPictureByID(parlamentarierId);
|
||||
attributes.put("picture", picture);
|
||||
|
||||
// NLP: Topic
|
||||
if ((speech.getNlp() != null) && (speech.getNlp().getTopics() != null)) {
|
||||
Map<String, Double> topics = Topic.condenseTopicInformation(speech.getNlp().getTopics()); // Daten "verdichten"...
|
||||
|
@ -187,8 +193,16 @@ public class FrontEndController {
|
|||
speech.getNlp().setPosList((List) new ArrayList<Token>()); // Ensure it's never null
|
||||
}
|
||||
|
||||
// TODO: Token wird momentan etwas komisch abgespeichert, da im Attribut text die POS art steht, und in pos die Anzahl dieser POS arten. Umstrukturieren damit keine Verwirrung herrscht
|
||||
// NLP: Sentiments
|
||||
Sentiment speechSentiment = null;
|
||||
if (speech.getNlp() != null && speech.getNlp().getSentiments() != null && !speech.getNlp().getSentiments().isEmpty()) {
|
||||
speechSentiment = speech.getNlp().getSentiments().get(0); // Get the first sentiment
|
||||
}
|
||||
|
||||
System.out.println("DEBUG: Speech Sentiment - " + speechSentiment);
|
||||
|
||||
// ✅ Pass sentiment data to FreeMarker
|
||||
attributes.put("sentiment", speechSentiment);
|
||||
|
||||
ctx.render("speech.ftl", attributes);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class RESTHandler {
|
|||
|
||||
// Reden
|
||||
app.get("/reden/{id}", FrontEndController::listSpeeches); // zeige Reden eines Parlamentariers an
|
||||
app.get("/reden/{id}/{redeId}", SpeechController::showSpeech); // zeige eine bestimmte Rede des Parlamentariers an
|
||||
app.get("/reden/{id}/{redeId}", FrontEndController::showSpeech); // zeige eine bestimmte Rede des Parlamentariers an
|
||||
|
||||
app.get("/reden", SpeechController::listAllSpeeches); // zeige alle Reden an (Filtern möglich)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue