Ich hänge momentan über einem Projekt, in dem ich Sätze in XML-Form nach bestimmten Phrasen (Teilsätzen) durchsuchen muss. Die Sätze (in Japanisch) sind als XML-Datei vorhanden. Dummerweise ist die Struktur nicht so optimal, wie sie sein sollte. Die Satzstruktur ist ja normalerweise wie ein Baum aufgebaut und wäre somit für XML auch denk ich bestens geeignet. In der Datei ist es aber so, dass die Baumstruktur nur über Verweise realisiert wurde. Hier mal einen Beispielsatz:
[XML]<sentence id="s6">
<word form="sou" pos="ADVdem" morph="--" func="COMP" parent="500" comment=""></word>
<word form="shitara" pos="Vcnd" morph="--" func="HD" parent="500" comment=""></word>
<word form="toriaezu" pos="ADVtmp" morph="--" func="ADJ" parent="502" comment=""></word>
<word form="mazu" pos="ADVtmp" morph="--" func="ADJ" parent="502" comment=""></word>
<word form="sukejuuru" pos="NN" morph="--" func="COMP" parent="501" comment=""></word>
<word form="kara" pos="P" morph="--" func="HD" parent="501" comment=""></word>
<word form="kimenai" pos="VADJi" morph="--" func="HD" parent="502" comment=""></word>
<word form="to" pos="PSSa" morph="--" func="HD" parent="503" comment=""></word>
<word form="ikenai" pos="ADJifin" morph="--" func="HD" parent="504" comment=""></word>
<word form="no" pos="NF" morph="--" func="HD" parent="505" comment=""></word>
<word form="desu" pos="PVfin" morph="u" func="HD" parent="506" comment=""></word>
<word form="ne" pos="PSE" morph="--" func="MRK" parent="507" comment=""></word>
<word form="." pos="." morph="--" func="--" parent="0" comment=""></word>
<node num="500" cat="VPcnd" func="ADJ" parent="508" comment=""></node>
<node num="501" cat="PP" func="COMP" parent="502" comment=""></node>
<node num="502" cat="AP" func="COMP" parent="503" comment=""></node>
<node num="503" cat="SS" func="COMP" parent="504" comment=""></node>
<node num="504" cat="AP" func="COMP" parent="505" comment=""></node>
<node num="505" cat="NP" func="COMP" parent="506" comment=""></node>
<node num="506" cat="VPfin" func="HD" parent="507" comment=""></node>
<node num="507" cat="S" func="HD" parent="508" comment=""></node>
<node num="508" cat="S" func="--" parent="0" comment=""></node>
</sentence
>[/XML]
Wie man sehen kann sind die Verweise hier das Attribut "parent". Wenn ich es richtig interpretiere, würde eine besser geschachtelte XML-Datei folgendermaßen aussehen:
[XML]<sentence id="s6">
<node cat="S" func="--" comment="">
<node cat="VPcnd" func="ADJ" comment="">
<word form="sou" pos="ADVdem" morph="--" func="COMP" comment=""></word>
<word form="shitara" pos="Vcnd" morph="--" func="HD" comment=""></word>
</node>
<node cat="VPfin" func="HD" comment="">
<node cat="NP" func="COMP" comment="">
<node cat="AP" func="COMP" comment="">
<node cat="SS" func="COMP" comment="">
<node cat="AP" func="COMP" comment="">
<word form="toriaezu" pos="ADVtmp" morph="--" func="ADJ" comment=""></word>
<word form="mazu" pos="ADVtmp" morph="--" func="ADJ" comment=""></word>
</node>
<node cat="AP" func="COMP" comment="">
<node cat="PP" func="COMP" comment="">
<word form="sukejuuru" pos="NN" morph="--" func="COMP" comment=""></word>
<word form="kara" pos="P" morph="--" func="HD" comment=""></word>
</node>
<word form="kimenai" pos="VADJi" morph="--" func="HD" comment=""></word>
</node>
<word form="to" pos="PSSa" morph="--" func="HD" comment=""></word>
</node>
<word form="ikenai" pos="ADJifin" morph="--" func="HD" comment=""></word>
</node>
<word form="no" pos="NF" morph="--" func="HD" comment=""></word>
</node>
<word form="desu" pos="PVfin" morph="u" func="HD" comment=""></word>
</node>
<word form="ne" pos="PSE" morph="--" func="MRK" comment=""></word>
<word form="." pos="." morph="--" func="--" comment=""></word>
</node>
</sentence>[/XML]
Nun die eigentliche Fragestellung: Ich bin mir unsicher, wie ich das Ganze am Besten umsetzen soll. Ich wollte mit JDOM arbeiten und so schon mal die Ursprungsdatei einlesen. Die nun aber irgendwie in die neue Schachtelung umbauen? Oder lieber einen ganz anderen Ansatz in Java mit einer Baum-Datenstruktur? Hab in dem Bereich noch nicht wirklich programmiert und da bin ich noch unsicher, wie ich das Alles angehen soll. Was würdet Ihr denn machen? Ich würde mich über Tipps und Anregungen freuen .
oO(ich hoffe, ich konnte das halbwegs verständlich erklären )
[XML]<sentence id="s6">
<word form="sou" pos="ADVdem" morph="--" func="COMP" parent="500" comment=""></word>
<word form="shitara" pos="Vcnd" morph="--" func="HD" parent="500" comment=""></word>
<word form="toriaezu" pos="ADVtmp" morph="--" func="ADJ" parent="502" comment=""></word>
<word form="mazu" pos="ADVtmp" morph="--" func="ADJ" parent="502" comment=""></word>
<word form="sukejuuru" pos="NN" morph="--" func="COMP" parent="501" comment=""></word>
<word form="kara" pos="P" morph="--" func="HD" parent="501" comment=""></word>
<word form="kimenai" pos="VADJi" morph="--" func="HD" parent="502" comment=""></word>
<word form="to" pos="PSSa" morph="--" func="HD" parent="503" comment=""></word>
<word form="ikenai" pos="ADJifin" morph="--" func="HD" parent="504" comment=""></word>
<word form="no" pos="NF" morph="--" func="HD" parent="505" comment=""></word>
<word form="desu" pos="PVfin" morph="u" func="HD" parent="506" comment=""></word>
<word form="ne" pos="PSE" morph="--" func="MRK" parent="507" comment=""></word>
<word form="." pos="." morph="--" func="--" parent="0" comment=""></word>
<node num="500" cat="VPcnd" func="ADJ" parent="508" comment=""></node>
<node num="501" cat="PP" func="COMP" parent="502" comment=""></node>
<node num="502" cat="AP" func="COMP" parent="503" comment=""></node>
<node num="503" cat="SS" func="COMP" parent="504" comment=""></node>
<node num="504" cat="AP" func="COMP" parent="505" comment=""></node>
<node num="505" cat="NP" func="COMP" parent="506" comment=""></node>
<node num="506" cat="VPfin" func="HD" parent="507" comment=""></node>
<node num="507" cat="S" func="HD" parent="508" comment=""></node>
<node num="508" cat="S" func="--" parent="0" comment=""></node>
</sentence
>[/XML]
Wie man sehen kann sind die Verweise hier das Attribut "parent". Wenn ich es richtig interpretiere, würde eine besser geschachtelte XML-Datei folgendermaßen aussehen:
[XML]<sentence id="s6">
<node cat="S" func="--" comment="">
<node cat="VPcnd" func="ADJ" comment="">
<word form="sou" pos="ADVdem" morph="--" func="COMP" comment=""></word>
<word form="shitara" pos="Vcnd" morph="--" func="HD" comment=""></word>
</node>
<node cat="VPfin" func="HD" comment="">
<node cat="NP" func="COMP" comment="">
<node cat="AP" func="COMP" comment="">
<node cat="SS" func="COMP" comment="">
<node cat="AP" func="COMP" comment="">
<word form="toriaezu" pos="ADVtmp" morph="--" func="ADJ" comment=""></word>
<word form="mazu" pos="ADVtmp" morph="--" func="ADJ" comment=""></word>
</node>
<node cat="AP" func="COMP" comment="">
<node cat="PP" func="COMP" comment="">
<word form="sukejuuru" pos="NN" morph="--" func="COMP" comment=""></word>
<word form="kara" pos="P" morph="--" func="HD" comment=""></word>
</node>
<word form="kimenai" pos="VADJi" morph="--" func="HD" comment=""></word>
</node>
<word form="to" pos="PSSa" morph="--" func="HD" comment=""></word>
</node>
<word form="ikenai" pos="ADJifin" morph="--" func="HD" comment=""></word>
</node>
<word form="no" pos="NF" morph="--" func="HD" comment=""></word>
</node>
<word form="desu" pos="PVfin" morph="u" func="HD" comment=""></word>
</node>
<word form="ne" pos="PSE" morph="--" func="MRK" comment=""></word>
<word form="." pos="." morph="--" func="--" comment=""></word>
</node>
</sentence>[/XML]
Nun die eigentliche Fragestellung: Ich bin mir unsicher, wie ich das Ganze am Besten umsetzen soll. Ich wollte mit JDOM arbeiten und so schon mal die Ursprungsdatei einlesen. Die nun aber irgendwie in die neue Schachtelung umbauen? Oder lieber einen ganz anderen Ansatz in Java mit einer Baum-Datenstruktur? Hab in dem Bereich noch nicht wirklich programmiert und da bin ich noch unsicher, wie ich das Alles angehen soll. Was würdet Ihr denn machen? Ich würde mich über Tipps und Anregungen freuen .
oO(ich hoffe, ich konnte das halbwegs verständlich erklären )