use of net.heartsome.cat.common.bean.TmxTU in project translationstudio8 by heartsome.
the class TmxReader method read.
public TmxReaderEvent read() {
TmxTU tu = null;
try {
if (tuAp.evalXPath() != -1) {
tu = new TmxTU();
readTuElementAttribute(tu);
readTuNoteElement(tu);
readTuPropElement(tu);
readTuTuvElement(tu);
} else {
return new TmxReaderEvent(null, TmxReaderEvent.END_FILE);
}
} catch (VTDException e) {
return new TmxReaderEvent(null, TmxReaderEvent.READ_EXCEPTION);
}
return new TmxReaderEvent(tu, TmxReaderEvent.NORMAL_READ);
}
use of net.heartsome.cat.common.bean.TmxTU in project translationstudio8 by heartsome.
the class TmUtils method altTransInfoConverter.
/**
* 将从库中获取的匹配转成以 AltTransBean 封装的匹配数据,在转换的过程与当前 AltTrans重复的记录将被忽略
* @param dbMatches
* 从数据库中获取的匹配
* @param currentAltTrans
* 当前已经存原altTrans
* @return 和当前匹配不重复的AltTrans集;
*/
public static Vector<AltTransBean> altTransInfoConverter(List<FuzzySearchResult> dbMatches, Vector<AltTransBean> currentAltTrans) {
Vector<AltTransBean> altTrans = new Vector<AltTransBean>();
Vector<AltTransBean> existAltTrans = new Vector<AltTransBean>();
for (FuzzySearchResult result : dbMatches) {
AltTransBean atb = new AltTransBean();
// Map<String, String> match = tu.getTuInfo();
TmxTU tu = result.getTu();
// 获取源节点内容、属性及纯文本
atb.setSrcText(tu.getSource().getPureText());
atb.setTgtText(tu.getTarget().getPureText());
if (isMatchExist(currentAltTrans, atb, result.getDbName(), existAltTrans)) {
continue;
}
Hashtable<String, String> matchProps = new Hashtable<String, String>();
matchProps.put("match-quality", result.getSimilarity() + "");
matchProps.put("origin", result.getDbName());
matchProps.put("tool-id", "Translation Memory");
matchProps.put("hs:matchType", "TM");
matchProps.put("xml:space", "default");
atb.setMatchProps(matchProps);
Hashtable<String, String> srcProps = new Hashtable<String, String>();
srcProps.put("xml:lang", tu.getSource().getLangCode());
atb.setSrcProps(srcProps);
atb.setSrcContent(tu.getSource().getFullText());
Hashtable<String, String> tgtProps = new Hashtable<String, String>();
tgtProps.put("xml:lang", tu.getTarget().getLangCode());
atb.setTgtProps(tgtProps);
atb.setTgtContent(tu.getTarget().getFullText());
Vector<PropGroupBean> pgs = new Vector<PropGroupBean>();
Vector<PropBean> props = new Vector<PropBean>();
PropBean pb = new PropBean("creationId", tu.getCreationUser());
props.add(pb);
pb = new PropBean("creationDate", tu.getCreationDate());
props.add(pb);
pb = new PropBean("changeId", tu.getChangeUser());
props.add(pb);
pb = new PropBean("changeDate", tu.getChangeDate());
props.add(pb);
List<TmxProp> attrValList = tu.getProps();
for (TmxProp attr : attrValList) {
String name = attr.getName();
if (name == null || name.equals("")) {
continue;
}
String value = attr.getValue();
if (value == null || value.equals("")) {
continue;
}
PropBean prop = new PropBean(name, value);
props.add(prop);
}
PropGroupBean pg = new PropGroupBean(props);
// 获取属性组名称。
pg.setName("hs:prop-group");
pgs.add(pg);
atb.setPropGroups(pgs);
altTrans.add(atb);
}
if (altTrans.size() > 0) {
altTrans.addAll(existAltTrans);
} else {
currentAltTrans.addAll(existAltTrans);
}
return altTrans;
}
Aggregations