Ich verwende TMX-Dateien (XML-Datei für Übersetzungsdaten) als meine Quelle in Logstash, um Daten in Elasticsearch zu indizieren.Wie analysiere ich eine TMX-Datei (XML-Datei für Übersetzungsdaten) in logstash
Eine Probe TMX-Datei wie folgt aussieht,
<?xml version="1.0" encoding="UTF-8"?>
<tmx version="1.4">
<header creationtool="ModernMT - modernmt.eu" creationtoolversion="1.0" datatype="plaintext" o-tmf="ModernMT" segtype="sentence" adminlang="en-us" srclang="en-GB"/>
<body>
<tu srclang="en-GB" datatype="plaintext" creationdate="20121019T114713Z">
<tuv xml:lang="en-GB">
<seg>The purpose of the standard is to establish and define the requirements for the provision of quality services by translation service providers.</seg>
</tuv>
<tuv xml:lang="it">
<seg>L'obiettivo dello standard è stabilire e definire i requisiti affinché i fornitori di servizi di traduzione garantiscano servizi di qualità.</seg>
</tuv>
</tu>
<tu srclang="en-GB" datatype="plaintext" creationdate="20111223T112746Z">
<tuv xml:lang="en-GB">
<seg>With 1,800 experienced and qualified resources translating regularly into over 200 language combinations, you can count on us for high quality professional translation services.</seg>
</tuv>
<tuv xml:lang="it">
<seg>Abbiamo 1.800 professionisti esperti e qualificati che traducono regolarmente in oltre 200 combinazioni linguistiche; perciò, se cercate la qualità, potete contare su di noi.</seg>
</tuv>
</tu>
<tu srclang="en-GB" datatype="plaintext" creationdate="20111223T112746Z">
<tuv xml:lang="en-GB">
<seg>Access our section of useful links</seg>
</tuv>
<tuv xml:lang="it">
<seg>Da qui potrete accedere a una sezione che propone link a siti che possono essere di vostro interesse</seg>
</tuv>
</tu>
Was ich hier tun müssen, ist, jeden <tu>
Block als ein Ereignis zuzugreifen, wobei die beiden <tuv>
innerhalb Blöcke werden als die Datenfelder verwendet werden. Die im ersten tuv
-Block gespeicherten Daten werden in ES als Quellsprachen-Datenfeld indiziert, und die im zweiten tuv
-Block gespeicherten Daten sind das Datenfeld der Zielsprache.
Ein TMX-Dokument kann mehr als 10000 tuv
Blöcke enthalten.
Ich habe Probleme die XML-Filter verwenden und es so aussieht jetzt,
input {
file {
path => "/en-gb_pt-pt/81384/81384.xml"
start_position => "beginning"
codec => multiline {
pattern => "<tu>"
negate => "true"
what => "previous"
}
}
}
filter {
xml {
source => "message"
target => "xml_content"
xpath => [ "//seg", "seg" ]
}
}
output {
stdout {
#codec => json
codec => rubydebug
}
}
Hier ist ein Teil meiner Index-Vorlage,
"segment": {
"_parent": {
"type": "tm"
},
"_routing": {
"required": "true"
},
"properties": {
"@timestamp": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"@version": {
"type": "string"
},
"source": {
"type": "string",
"store": "true",
"fields": {
"length": {
"type": "token_count",
"analyzer": "standard"
}
}
},
"target": {
"type": "string",
"store": "true",
"fields": {
"length": {
"type": "token_count",
"analyzer": "standard"
}
}
}
}
}