- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中net.sf.okapi.common.XMLWriter
类的一些代码示例,展示了XMLWriter
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLWriter
类的具体详情如下:
包路径:net.sf.okapi.common.XMLWriter
类名称:XMLWriter
[英]Helper class to write XML documents.
IMPORTANT: flush() or close() must always be called to assure all content is flushed to the underlying streams.
If a StringWriter is used the flush() or close() must be be called before calling the toString() method
[中]帮助类来编写XML文档。
重要提示:必须始终调用flush()或close(),以确保将所有内容刷新到底层流。
如果使用StringWriter,则必须在调用toString()方法之前调用flush()或close()
代码示例来源:origin: net.sf.okapi.connectors/okapi-connector-microsoft
public String toXML() {
StringWriter sw = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(sw);
xmlWriter.writeStartDocument();
xmlWriter.writeStartElement("GetTranslationsArrayRequest");
xmlWriter.writeElementString("AppId", "");
xmlWriter.writeElementString("From", srcLang);
xmlWriter.writeStartElement("Options");
xmlWriter.writeAttributeString("xmlns:o", "http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2");
xmlWriter.writeElementString("o:Category", category);
xmlWriter.writeElementString("o:ContentType", contentType);
xmlWriter.writeElementString("o:ReservedFlags", "");
xmlWriter.writeElementString("o:State", "");
xmlWriter.writeElementString("o:Uri", "");
xmlWriter.writeElementString("o:User", "");
xmlWriter.writeEndElement(); // Options
xmlWriter.writeStartElement("Texts");
xmlWriter.writeAttributeString("xmlns:s", "http://schemas.microsoft.com/2003/10/Serialization/Arrays");
for (String text : texts) {
xmlWriter.writeStartElement("s:string");
xmlWriter.writeString(text);
xmlWriter.writeEndElement();
xmlWriter.writeEndElement(); // !Texts
xmlWriter.writeElementString("To", trgLang);
xmlWriter.writeElementString("MaxTranslations", String.valueOf(maxHits));
xmlWriter.writeEndElement(); // !GetTranslationsArrayRequest
xmlWriter.writeEndDocument();
xmlWriter.close();
return sw.toString();
代码示例来源:origin: net.sf.okapi.steps/okapi-step-gttbatchtranslation
private void startExtractedBlock () {
try {
File tmpFile = File.createTempFile("~okapi-45_gttbt_", ".html");
blocks.add(tmpFile);
// Create the HTML file
htmlWriter = new XMLWriter(tmpFile.getPath());
// Start building the source file
htmlWriter.writeStartElement("html");
htmlWriter.writeStartElement("meta");
htmlWriter.writeAttributeString("http-equiv", "Content-Type");
htmlWriter.writeAttributeString("content", "text/html; charset=UTF-8");
htmlWriter.writeEndElementLineBreak();
count = 100; // Roughly
}
catch ( IOException e ) {
throw new OkapiIOException("Error creating extraction file.", e);
}
}
代码示例来源:origin: net.sf.okapi.steps/okapi-step-translationcomparison
private void printBracket (int index,
String range)
{
writer.writeRawXML("<tr "+
((index % 2)==0 ? "" : "bgcolor=#FFFFCC")
+ "><td>"+range+"</td>"); //$NON-NLS-1$
writer.writeRawXML(String.format("<td align='right'>%d</td>", edBrackets[index])); //$NON-NLS-1$
// ED-Scores
writer.writeRawXML(((itemCount == 0) ? "<td align='right'>NA</td>" : String.format("<td align='right'>%.0f</td>", (float)edBrackets[index]/itemCount*100))); //$NON-NLS-1$
writer.writeRawXML(String.format("<td align='right'>%d</td>", edWCBrackets[index])); //$NON-NLS-1$
writer.writeRawXML(((wcTotal == 0) ? "<td align='right'>NA</td>" : String.format("<td align='right'>%.0f</td>", (float)edWCBrackets[index]/wcTotal*100))); //$NON-NLS-1$
writer.writeRawXML(String.format("<td align='right'>%d</td>", fmBrackets[index])); //$NON-NLS-1$
// FM-Scores
writer.writeRawXML(((itemCount == 0) ? "<td align='right'>NA</td>" : String.format("<td align='right'>%.0f</td>", (float)fmBrackets[index]/itemCount*100))); //$NON-NLS-1$
writer.writeRawXML(String.format("<td align='right'>%d</td>", fmWCBrackets[index])); //$NON-NLS-1$
writer.writeRawXML(((wcTotal == 0) ? "<td align='right'>NA</td>" : String.format("<td align='right'>%.0f</td>", (float)fmWCBrackets[index]/wcTotal*100))); //$NON-NLS-1$
writer.writeRawXML("</tr>\n"); //$NON-NLS-1$
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Writes the end of the TMX document.
*/
public void writeEndDocument () {
writer.writeEndElementLineBreak(); // body
writer.writeEndElementLineBreak(); // tmx
writer.writeEndDocument();
}
代码示例来源:origin: net.sf.okapi.lib/okapi-lib-persistence
@Override
protected void endWriting(OutputStream outStream) {
writer.writeEndElementLineBreak(); // body
writer.writeEndDocument();
writer.close();
}
代码示例来源:origin: net.sf.okapi.lib/okapi-lib-persistence
@Override
protected void startWriting(OutputStream outStream) {
//this.outStream = outStream;
prWriter = new PrintWriter(outStream);
writer = new XMLWriter(prWriter);
writer.writeStartDocument();
writer.writeStartElement("body");
writer.writeLineBreak();
}
代码示例来源:origin: net.sf.okapi.steps/okapi-step-rainbowkit
XR = new XMLWriter(projectSaveFile);
XR.writeStartDocument();
XR.writeStartElement("omegat");
XR.writeStartElement("project");
XR.writeAttributeString("version", "1.0");
XR.writeStartElement("source_dir");
XR.writeRawXML("__DEFAULT__");
XR.writeEndElementLineBreak(); // source_dir
XR.writeStartElement("target_dir");
XR.writeRawXML("__DEFAULT__");
XR.writeEndElementLineBreak(); // target_dir
XR.writeStartElement("tm_dir");
XR.writeRawXML("__DEFAULT__");
XR.writeEndElementLineBreak(); // tm_dir
XR.writeStartElement("glossary_dir");
XR.writeRawXML("__DEFAULT__");
XR.writeEndElementLineBreak(); // glossary_dir
XR.writeStartElement("dictionary_dir");
XR.writeRawXML("__DEFAULT__");
XR.writeEndElementLineBreak(); // dictionary_dir
XR.writeStartElement("source_lang");
XR.writeRawXML(manifest.getSourceLocale().toString());
XR.writeEndElementLineBreak(); // source_lang
代码示例来源:origin: net.sf.okapi/okapi-core
writer.writeStartElement("tu");
if ( !Util.isEmpty(tuid) ) {
writer.writeAttributeString("tuid", tuid);
writer.writeLineBreak();
writer.writeStartElement("prop");
writer.writeAttributeString("type", name);
writer.writeString(attributes.get(name));
writer.writeEndElementLineBreak(); // prop
writer.writeStartElement("tuv");
writer.writeAttributeString("xml:lang", srcLoc.toBCP47());
writer.writeStartElement("seg");
writer.writeRawXML(tmxCont.setContent(source).toString());
writer.writeEndElement(); // seg
writer.writeEndElementLineBreak(); // tuv
writer.writeStartElement("tuv");
writer.writeAttributeString("xml:lang",
((altTrgLoc != null) ? altTrgLoc.toBCP47() : trgLoc.toBCP47()));
writer.writeAttributeString(CREATIONID, attributes.get(CREATIONID));
writer.writeStartElement("seg");
writer.writeRawXML(tmxCont.setContent(target).toString());
writer.writeEndElement(); // seg
writer.writeEndElementLineBreak(); // tuv
代码示例来源:origin: net.sf.okapi.lib/okapi-lib-segmentation
private void saveRules(XMLWriter writer, boolean saveExtensions, boolean saveNonValidInfo) {
try {
writer.writeStartDocument();
if (docComment != null) {
writer.writeComment(docComment, true);
writer.writeStartElement("srx");
writer.writeAttributeString("xmlns", NSURI_SRX20);
if (saveExtensions) {
writer.writeAttributeString("xmlns:" + NSPREFIX_OKPSRX, NSURI_OKPSRX);
writer.writeAttributeString("version", "2.0");
version = "2.0";
writer.writeLineBreak();
writer.writeComment(headerComment, true);
writer.writeStartElement("header");
writer.writeAttributeString("segmentsubflows", (segmentSubFlows ? "yes" : "no"));
writer.writeAttributeString("cascade", (cascade ? "yes" : "no"));
writer.writeLineBreak();
writer.writeStartElement("formathandle");
writer.writeAttributeString("type", "start");
writer.writeAttributeString("include", (includeStartCodes ? "yes" : "no"));
writer.writeEndElementLineBreak(); // formathandle
writer.writeStartElement("formathandle");
writer.writeAttributeString("type", "end");
writer.writeAttributeString("include", (includeEndCodes ? "yes" : "no"));
代码示例来源:origin: net.sf.okapi.connectors/okapi-connector-microsoft
public String toXML() {
StringWriter sw = new StringWriter();
XMLWriter xml = new XMLWriter(sw);
xml.writeStartDocument();
xml.writeStartElement("TranslateOptions");
xml.writeAttributeString("xmlns", "http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2");
xml.writeStartElement("Category");
xml.writeString(this.category);
xml.writeEndElement();
xml.writeStartElement("ContentType");
xml.writeString(this.contentType);
xml.writeEndElement();
xml.writeStartElement("ReservedFlags");
xml.writeEndElement();
xml.writeStartElement("State");
xml.writeEndElement();
xml.writeStartElement("Uri");
xml.writeEndElement();
xml.writeStartElement("User");
xml.writeString("defaultUser");
xml.writeEndElement();
xml.writeEndElement(); // !TranslateOptions
xml.close();
return sw.toString();
}
}
代码示例来源:origin: net.sf.okapi.steps/okapi-step-translationcomparison
if ( writer != null ) writer.close();
if ( prnWriter != null ) prnWriter.close();
writer = new XMLWriter(getOutputFilename()); //$NON-NLS-1$
writer.writeStartDocument();
writer.writeStartElement("html"); //$NON-NLS-1$
writer.writeStartElement("head"); //$NON-NLS-1$
writer.writeRawXML("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"); //$NON-NLS-1$
writer.writeRawXML("<style>td { font-family: monospace } td { vertical-align: top; white-space: pre } td.p { border-top-style: solid; border-top-width: 1px;}</style>"); //$NON-NLS-1$
writer.writeEndElement(); // head
writer.writeStartElement("body"); //$NON-NLS-1$
writer.writeStartElement("h1"); //$NON-NLS-1$
writer.writeString("Translation Comparison");
writer.writeEndElement();
writer.writeStartElement("p"); //$NON-NLS-1$
writer.writeString(String.format("Base document (%s): %s",
params.getDocument1Label(), baseDocumentPath));
writer.writeRawXML("<br>");
writer.writeString(String.format("Comparison 1 (%s): %s",
params.getDocument2Label(), compDocumentPath));
if ( rawDoc3 != null ) {
writer.writeRawXML("<br>");
writer.writeString(String.format("Comparison 2 (%s): %s",
params.getDocument3Label(), rawDoc3.getInputURI().getPath()));
writer.writeString(".");
writer.writeEndElement();
writer.writeRawXML("<p>ED-Score = Edit distance score, FM-Score = Fuzzy Match score.<br/>For details see: "
+"<a href='"+WIKIURL+"'>"+WIKIURL+"</a>.</p>");
代码示例来源:origin: net.sf.okapi.steps/okapi-step-translationcomparison
writer.writeEndElement(); // table
writer.writeElementString("p", String.format("", itemCount));
if ( itemCount > 0 ) {
writer.writeStartElement("h2"); //$NON-NLS-1$
writer.writeAttributeString("id", "summary");
writer.writeString("Summary");
writer.writeEndElement();
writer.writeElementString("p", String.format("Repartition for %s to %s:", params.getDocument1Label(), params.getDocument2Label()));
writer.writeRawXML("<table border=1 cellspacing=0 cellpadding=5>"); //$NON-NLS-1$
writer.writeRawXML("<tr><th rowspan=2>Scores</th><th colspan=4>ED-Scores</th><th colspan=4>FM-Scores</th></tr>");
writer.writeRawXML("<tr>"
+ "<th style=\"text-align: right; width: 100px;\">Segments </th>"
+ "<th style=\"text-align: right; width: 100px;\">% </th>"
printBracket(1, "10 - 19");
printBracket(0, "0 - 9");
writer.writeRawXML("<tr><td>Total</td>"); //$NON-NLS-1$
writer.writeRawXML(String.format("<td align='right'>%d</td>", itemCount)); //$NON-NLS-1$
writer.writeRawXML("<td align='right'>100%</td>"); //$NON-NLS-1$
writer.writeRawXML(String.format("<td align='right'>%d</td>", wcTotal)); //$NON-NLS-1$
writer.writeRawXML("<td align='right'>100%</td>"); //$NON-NLS-1$
writer.writeRawXML(String.format("<td align='right'>%d</td>", itemCount)); //$NON-NLS-1$
writer.writeRawXML("<td align='right'>100%</td>"); //$NON-NLS-1$
writer.writeRawXML(String.format("<td align='right'>%d</td>", wcTotal)); //$NON-NLS-1$
writer.writeRawXML("<td align='right'>100%</td>"); //$NON-NLS-1$
writer.writeRawXML("</tr>\n"); //$NON-NLS-1$
代码示例来源:origin: net.sf.okapi.steps/okapi-step-gttbatchtranslation
htmlWriter.writeStartElement("p");
String out = String.format("%d:%s:%s", subDocId, tu.getId(), seg.id);
count += (out.length() + 10);
htmlWriter.writeAttributeString("id", out);
out = qutil.toCodedHTML(seg.text);
try {
htmlWriter.writeRawXML(out);
htmlWriter.writeEndElementLineBreak(); // p
代码示例来源:origin: net.sf.okapi/okapi-core
writer = new XMLWriter(xliffPath);
} else if ( outputStream != null ) {
writer = new XMLWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8));
writer.writeStartDocument();
writer.writeStartElement("xliff");
writer.writeAttributeString("version", "1.2");
writer.writeAttributeString("xmlns", Namespaces.NS_XLIFF12);
writer.writeAttributeString("xmlns:okp", Namespaces.NS_XLIFFOKAPI);
if ( params.getIncludeIts() ) {
writer.writeAttributeString("xmlns:"+Namespaces.ITS_NS_PREFIX, Namespaces.ITS_NS_URI);
writer.writeAttributeString("xmlns:"+Namespaces.ITSXLF_NS_PREFIX, Namespaces.ITSXLF_NS_URI);
writer.writeAttributeString(Namespaces.ITS_NS_PREFIX+":version", "2.0");
writer.writeLineBreak();
writer.writeComment(message, false);
writer.writeLineBreak();
代码示例来源:origin: net.sf.okapi/okapi-core
writer.writeStartDocument();
writer.writeStartElement("tmx");
writer.writeAttributeString("version", "1.4");
writer.writeStartElement("header");
writer.writeAttributeString("creationtool",
(creationTool == null) ? "unknown" : creationTool);
writer.writeAttributeString("creationtoolversion",
(creationToolVersion == null) ? "unknown" : creationToolVersion);
writer.writeAttributeString("segtype",
(segType == null) ? "paragraph" : segType);
writer.writeAttributeString("o-tmf",
(originalTMFormat == null) ? "unknown" : originalTMFormat);
writer.writeAttributeString("adminlang", "en");
writer.writeAttributeString("srclang", srcLoc.toBCP47());
writer.writeAttributeString("datatype",
(dataType == null) ? "unknown" : dataType);
Property p = startDocument.getProperty(n);
if ("note".equalsIgnoreCase(p.getName())) {
writer.writeStartElement("note");
writer.writeString(p.getValue());
writer.writeEndElement();
} else {
writer.writeStartElement("prop");
writer.writeAttributeString("type", p.getName());
writer.writeString(p.getValue());
writer.writeEndElement();
代码示例来源:origin: net.sf.okapi/okapi-core
writer.writeStartElement("trans-unit");
writer.writeAttributeString("id", tu.getId());
String tmp = tu.getName();
if ( !Util.isEmpty(tmp) ) {
writer.writeAttributeString("resname", tmp);
writer.writeAttributeString("coord", tu.getProperty(Property.COORDINATES).getValue());
writer.writeAttributeString("restype", tmp);
writer.writeAttributeString("restype", "x-"+tmp);
writer.writeAttributeString("translate", "no");
String value = ann.getString(GenericAnnotationType.LOCFILTER_VALUE);
if ( !ITSContent.isExtendedMatch(value, trgLoc.toBCP47()) ) {
writer.writeAttributeString("translate", "no");
writer.writeAttributeString("phase-name", phaseName);
if ( tu.hasTargetProperty(trgLoc, Property.APPROVED) ) {
if ( tu.getTargetProperty(trgLoc, Property.APPROVED).getValue().equals("yes") ) {
writer.writeAttributeString(Property.APPROVED, "yes");
writer.writeAttributeString("xml:space", "preserve");
writer.appendRawXML(sbITS.toString());
writer.writeLineBreak();
代码示例来源:origin: net.sf.okapi/okapi-core
protected void writeProp(String name, String value) {
// Write out the property
if (expandDuplicateProps) {
StringTokenizer st = new StringTokenizer(value, propValueSep, false);
while (st.hasMoreTokens()) {
writer.writeStartElement("prop");
writer.writeAttributeString("type", name);
writer.writeString(st.nextToken());
writer.writeEndElementLineBreak(); // prop
}
} else {
writer.writeStartElement("prop");
writer.writeAttributeString("type", name);
writer.writeString(value);
writer.writeEndElementLineBreak(); // prop
}
}
代码示例来源:origin: net.sf.okapi.steps/okapi-step-rainbowkit
report = new XMLWriter(reportPath);
report.writeStartDocument();
report.writeRawXML("<h1>Transifex Package Summary</h1>");
report.writeLineBreak();
report.writeRawXML(String.format("<p>Resources uploaded to Transifex in the project "
+ "<b><a target='_blank' href='%s'>%s</a></b></p>",
options.getServerWithoutAPI() + "projects/p/" + options.getProjectId() + "/",
options.getProjectName()));
report.writeLineBreak();
report.writeRawXML("<table border='1' cellspacing='0' cellpadding='5'>");
report.writeRawXML("<tr><th>Transifex Resource</th><th>Original Source File</th></tr>");
report.writeLineBreak();
report.writeRawXML(String.format("<tr><td><a target='_blank' href=\"%s\">%s</a></td>",
options.getServerWithoutAPI() + "projects/p/" + options.getProjectId() + "/language/"+manifest.getSourceLocale().toPOSIXLocaleId()+"/",
resourceFile));
report.writeRawXML(String.format("<td>%s</td></tr>", info.getRelativeInputPath()));
report.writeLineBreak();
report.writeRawXML("</table>");
report.writeRawXML("<p>For more information about this package, see: "
+ "<a target='_blank' href='http://www.opentag.com/okapi/wiki/index.php?title=Rainbow_TKit_-_Transifex_Project'>"
+ "Rainbow TKit - Transifex Project</a>.");
report.writeRawXML("<p><font size='2'>Note: This report was generated when creating the translation package, "
+ "the Transifex project may have been updated with other files since.</font></p>");
report.close();
if ( report != null ) report.close();
if ( pw != null ) pw.close();
代码示例来源:origin: net.sf.okapi/okapi-core
writer.writeStartElement("tu");
if ( srcCont.contentIsOneSegment() ) {
writer.writeAttributeString("tuid", tuid);
writer.writeAttributeString("tuid", String.format("%s_%s", tuid, srcSeg.id));
writer.writeLineBreak();
writer.writeEndElementLineBreak(); // tu
writer.flush();
代码示例来源:origin: net.sf.okapi.steps/okapi-step-leveraging
private void finishTemporaryFiles (XMLWriter htmlWriter) {
// Close the temporary source input
if ( htmlWriter != null ) {
htmlWriter.writeEndElement(); // html
htmlWriter.writeEndDocument();
htmlWriter.close();
// htmlWriter should be reset to null by the caller
}
// Close the original entry store
if ( store != null ) {
store.close();
}
}
我正在尝试用 python 实现 Okapi BM25。虽然我看过一些教程如何做到这一点,但我似乎陷入了这个过程。 所以我收集了文档(并且具有“id”和“text”列)和查询(并且具有“id”和“te
本文整理了Java中net.sf.okapi.common.XMLWriter类的一些代码示例,展示了XMLWriter类的具体用法。这些代码示例主要来源于Github/Stackoverflow/M
我正在研究 Okapi BMS25 模型。我明白一切,但两个困惑。同时计算文档长度(dl)和平均文档长度(avdl)。我发现文档长度是 所以它是我在特定文档中的关键字/术语的总和。但是当我看到维基的定
我正在使用 elasticsearch 进行研究。我原计划使用余弦相似度,但我注意到它不可用,而是我们将 BM25 作为默认评分函数。 这有什么原因吗?余弦相似度是否不适用于查询文档?为什么默认选择
我发现 Okapi 相似度度量可用于计算文档相似度 http://www2002.org/CDROM/refereed/643/node6.html以及本文 http://singhal.info/i
本文整理了Java中net.sf.okapi.common.skeleton.ZipSkeleton类的一些代码示例,展示了ZipSkeleton类的具体用法。这些代码示例主要来源于Github/St
本文整理了Java中net.sf.okapi.common.XMLWriter.writeElementString()方法的一些代码示例,展示了XMLWriter.writeElementStrin
本文整理了Java中net.sf.okapi.common.XMLWriter.writeComment()方法的一些代码示例,展示了XMLWriter.writeComment()的具体用法。这些代
本文整理了Java中net.sf.okapi.common.XMLWriter.writeLineBreak()方法的一些代码示例,展示了XMLWriter.writeLineBreak()的具体用法
本文整理了Java中net.sf.okapi.common.XMLWriter.close()方法的一些代码示例,展示了XMLWriter.close()的具体用法。这些代码示例主要来源于Github
本文整理了Java中net.sf.okapi.common.XMLWriter.writeRawXML()方法的一些代码示例,展示了XMLWriter.writeRawXML()的具体用法。这些代码示
本文整理了Java中net.sf.okapi.common.XMLWriter.writeEndElementLineBreak()方法的一些代码示例,展示了XMLWriter.writeEndEle
本文整理了Java中net.sf.okapi.common.XMLWriter.writeEndElement()方法的一些代码示例,展示了XMLWriter.writeEndElement()的具体
本文整理了Java中net.sf.okapi.common.XMLWriter.writeStartElement()方法的一些代码示例,展示了XMLWriter.writeStartElement(
本文整理了Java中net.sf.okapi.common.XMLWriter.writeEndDocument()方法的一些代码示例,展示了XMLWriter.writeEndDocument()的
本文整理了Java中net.sf.okapi.common.XMLWriter.writeStartDocument()方法的一些代码示例,展示了XMLWriter.writeStartDocumen
本文整理了Java中net.sf.okapi.common.XMLWriter.writeAttributeString()方法的一些代码示例,展示了XMLWriter.writeAttributeS
本文整理了Java中net.sf.okapi.common.XMLWriter.()方法的一些代码示例,展示了XMLWriter.()的具体用法。这些代码示例主要来源于Github/Stackover
本文整理了Java中net.sf.okapi.common.XMLWriter.writeString()方法的一些代码示例,展示了XMLWriter.writeString()的具体用法。这些代码示
我想知道如何使用 Okapi 框架/Rainbow 实现以下目标: 将 Java I18N 属性文件转换为 XLIFF 进行翻译,其中某些翻译已存在并且应成为 XLIFF 文件的一部分。 我有两个 J
我是一名优秀的程序员,十分优秀!