本文整理了Java中nu.xom.Element.<init>()
方法的一些代码示例,展示了Element.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.<init>()
方法的具体详情如下:
包路径:nu.xom.Element
类名称:Element
方法名:<init>
暂无
代码示例来源:origin: wiztools/rest-client
static Element getDigestAuthElement(DigestAuth auth) {
Element e = new Element("digest");
populateBasicDigestElement(e, auth);
return e;
}
代码示例来源:origin: wiztools/rest-client
static Element getBasicAuthElement(BasicAuth auth) {
Element e = new Element("basic");
populateBasicDigestElement(e, auth);
return e;
}
代码示例来源:origin: stanfordnlp/CoreNLP
private static Element makeProbabilitiesElement(ExtractionObject object, String curNS) {
Element probs = new Element("probabilities", curNS);
if (object.getTypeProbabilities() != null){
List<Pair<String, Double>> sorted = Counters.toDescendingMagnitudeSortedListWithCounts(object.getTypeProbabilities());
for(Pair<String, Double> lv: sorted) {
Element prob = new Element("probability", curNS);
Element label = new Element("label", curNS);
label.appendChild(lv.first);
Element value = new Element("value", curNS);
value.appendChild(lv.second.toString());
prob.appendChild(label);
prob.appendChild(value);
probs.appendChild(prob);
}
}
return probs;
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Helper method for addWordInfo(). If the value is not null,
* creates an element of the given name and namespace and adds it to the
* tokenElement.
*
* @param tokenElement This is the element to which the newly created element will be added
* @param elemName This is the name for the new XML element
* @param curNS The current namespace
* @param value This is its value
*/
private static void setSingleElement(Element tokenElement, String elemName, String curNS, String value) {
if (value != null) {
Element cur = new Element(elemName, curNS);
cur.appendChild(value);
tokenElement.appendChild(cur);
}
}
代码示例来源:origin: wiztools/rest-client
private Element getRootElement() {
Element eRoot = new Element("rest-client");
// set version attributes to rest-client root tag
eRoot.addAttribute(new Attribute("version", Versions.CURRENT));
return eRoot;
}
代码示例来源:origin: wiztools/rest-client
static Element getOAuth2BearerElement(OAuth2BearerAuth auth) {
Element e = new Element("oauth2-bearer");
if(StringUtil.isNotEmpty(auth.getOAuth2BearerToken())) {
Element eToken = new Element("token");
eToken.appendChild(auth.getOAuth2BearerToken());
e.appendChild(eToken);
}
return e;
}
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Generates the XML content for the coreference chain object.
*/
private static boolean addCorefGraphInfo
(Options options, Element corefInfo, List<CoreMap> sentences, Map<Integer, CorefChain> corefChains, String curNS) {
boolean foundCoref = false;
for (CorefChain chain : corefChains.values()) {
if (!options.printSingletons && chain.getMentionsInTextualOrder().size() <= 1)
continue;
foundCoref = true;
Element chainElem = new Element("coreference", curNS);
CorefChain.CorefMention source = chain.getRepresentativeMention();
addCorefMention(options, chainElem, curNS, sentences, source, true);
for (CorefChain.CorefMention mention : chain.getMentionsInTextualOrder()) {
if (mention == source)
continue;
addCorefMention(options, chainElem, curNS, sentences, mention, false);
}
corefInfo.appendChild(chainElem);
}
return foundCoref;
}
代码示例来源:origin: stanfordnlp/CoreNLP
private static void addDependencyInfo(Element depInfo, String rel, boolean isExtra, int source, String sourceWord, Integer sourceCopy, int target, String targetWord, Integer targetCopy, String curNS) {
Element depElem = new Element("dep", curNS);
depElem.addAttribute(new Attribute("type", rel));
if (isExtra) {
depElem.addAttribute(new Attribute("extra", "true"));
}
Element govElem = new Element("governor", curNS);
govElem.addAttribute(new Attribute("idx", Integer.toString(source)));
govElem.appendChild(sourceWord);
if (sourceCopy != null && sourceCopy > 0) {
govElem.addAttribute(new Attribute("copy", Integer.toString(sourceCopy)));
}
depElem.appendChild(govElem);
Element dependElem = new Element("dependent", curNS);
dependElem.addAttribute(new Attribute("idx", Integer.toString(target)));
dependElem.appendChild(targetWord);
if (targetCopy != null && targetCopy > 0) {
dependElem.addAttribute(new Attribute("copy", Integer.toString(targetCopy)));
}
depElem.appendChild(dependElem);
depInfo.appendChild(depElem);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
protected Object createNode(final String name) {
final Element newNode = new Element(encodeNode(name));
final Element top = top();
if (top != null){
top().appendChild(newNode);
}
return newNode;
}
代码示例来源:origin: stanfordnlp/CoreNLP
CorefChain.CorefMention mention,
boolean representative) {
Element mentionElem = new Element("mention", curNS);
if (representative) {
mentionElem.addAttribute(new Attribute("representative", "true"));
代码示例来源:origin: wiztools/rest-client
static Element getNtlmAuthElement(NtlmAuth auth) {
Element e = new Element("ntlm");
if(StringUtil.isNotEmpty(auth.getDomain())) {
Element eDomain = new Element("domain");
eDomain.appendChild(auth.getDomain());
e.appendChild(eDomain);
}
if(StringUtil.isNotEmpty(auth.getWorkstation())) {
Element eWorkstation = new Element("workstation");
eWorkstation.appendChild(auth.getWorkstation());
e.appendChild(eWorkstation);
}
populateUsernamePasswordElement(e, auth);
return e;
}
代码示例来源:origin: stanfordnlp/CoreNLP
private static Element toXML(EntityMention entity, String curNS) {
Element top = new Element("entity", curNS);
top.addAttribute(new Attribute("id", entity.getObjectId()));
Element type = new Element("type", curNS);
type.appendChild(entity.getType());
top.appendChild(entity.getType());
if (entity.getNormalizedName() != null){
Element nm = new Element("normalized", curNS);
nm.appendChild(entity.getNormalizedName());
top.appendChild(nm);
}
if (entity.getSubType() != null){
Element subtype = new Element("subtype", curNS);
subtype.appendChild(entity.getSubType());
top.appendChild(subtype);
}
Element span = new Element("span", curNS);
span.addAttribute(new Attribute("start", Integer.toString(entity.getHeadTokenStart())));
span.addAttribute(new Attribute("end", Integer.toString(entity.getHeadTokenEnd())));
top.appendChild(span);
top.appendChild(makeProbabilitiesElement(entity, curNS));
return top;
}
代码示例来源:origin: stanfordnlp/CoreNLP
private static Element toXML(RelationMention relation, String curNS) {
Element top = new Element("relation", curNS);
top.addAttribute(new Attribute("id", relation.getObjectId()));
Element type = new Element("type", curNS);
type.appendChild(relation.getType());
top.appendChild(relation.getType());
if (relation.getSubType() != null){
Element subtype = new Element("subtype", curNS);
subtype.appendChild(relation.getSubType());
top.appendChild(relation.getSubType());
}
List<EntityMention> mentions = relation.getEntityMentionArgs();
Element args = new Element("arguments", curNS);
for (EntityMention e : mentions) {
args.appendChild(toXML(e, curNS));
}
top.appendChild(args);
top.appendChild(makeProbabilitiesElement(relation, curNS));
return top;
}
代码示例来源:origin: stanfordnlp/CoreNLP
private static Element toXML(RelationTriple triple, String curNS) {
Element top = new Element("triple", curNS);
top.addAttribute(new Attribute("confidence", triple.confidenceGloss()));
Element subject = new Element("subject", curNS);
subject.addAttribute(new Attribute("begin", Integer.toString(triple.subjectTokenSpan().first)));
subject.addAttribute(new Attribute("end", Integer.toString(triple.subjectTokenSpan().second)));
Element text = new Element("text", curNS);
text.appendChild(triple.subjectGloss());
Element lemma = new Element("lemma", curNS);
lemma.appendChild(triple.subjectLemmaGloss());
subject.appendChild(text);
Element relation = new Element("relation", curNS);
relation.addAttribute(new Attribute("begin", Integer.toString(triple.relationTokenSpan().first)));
relation.addAttribute(new Attribute("end", Integer.toString(triple.relationTokenSpan().second)));
text = new Element("text", curNS);
text.appendChild(triple.relationGloss());
lemma = new Element("lemma", curNS);
lemma.appendChild(triple.relationLemmaGloss());
relation.appendChild(text);
Element object = new Element("object", curNS);
object.addAttribute(new Attribute("begin", Integer.toString(triple.objectTokenSpan().first)));
object.addAttribute(new Attribute("end", Integer.toString(triple.objectTokenSpan().second)));
text = new Element("text", curNS);
text.appendChild(triple.objectGloss());
lemma = new Element("lemma", curNS);
lemma.appendChild(triple.objectLemmaGloss());
object.appendChild(text);
代码示例来源:origin: wiztools/rest-client
static void populateUsernamePasswordElement(Element eParent, UsernamePasswordAuth auth) {
if(StringUtil.isNotEmpty(auth.getUsername())) {
Element eUsername = new Element("username");
eUsername.appendChild(auth.getUsername());
eParent.appendChild(eUsername);
}
if(auth.getPassword() != null && auth.getPassword().length > 0) {
Element ePassword = new Element("password");
ePassword.appendChild(Util.base64encode(new String(auth.getPassword())));
eParent.appendChild(ePassword);
}
}
代码示例来源:origin: wiztools/rest-client
static void populateBasicDigestElement(Element eParent, BasicDigestAuth auth) {
if(StringUtil.isNotEmpty(auth.getHost())) {
Element eHost = new Element("host");
eHost.appendChild(auth.getHost());
eParent.appendChild(eHost);
}
if(StringUtil.isNotEmpty(auth.getRealm())) {
Element eRealm = new Element("realm");
eRealm.appendChild(auth.getRealm());
eParent.appendChild(eRealm);
}
if(auth.isPreemptive()) {
Element ePreemptive = new Element("preemptive");
eParent.appendChild(ePreemptive);
}
populateUsernamePasswordElement(eParent, auth);
}
代码示例来源:origin: wiztools/rest-client
public static void writeRequestCollectionXML(final List<Request> requests, final File f)
throws IOException, XMLException {
XmlPersistenceWrite xUtl = new XmlPersistenceWrite();
Element eRoot = new Element("request-collection");
eRoot.addAttribute(new Attribute("version", Versions.CURRENT));
for(Request req: requests) {
Element e = xUtl.getRequestElement(req);
eRoot.appendChild(e);
}
Document doc = new Document(eRoot);
xUtl.writeXML(doc, f);
}
代码示例来源:origin: stanfordnlp/CoreNLP
private static Element buildDependencyTreeInfo(String dependencyType, SemanticGraph graph, List<CoreLabel> tokens, String curNS) {
if(graph != null) {
Element depInfo = new Element("dependencies", curNS);
depInfo.addAttribute(new Attribute("type", dependencyType));
代码示例来源:origin: wiztools/rest-client
static Element getAuthElement(Auth auth) {
Element eAuth = new Element("auth");
if(auth instanceof BasicAuth) {
eAuth.appendChild(getBasicAuthElement((BasicAuth)auth));
}
else if(auth instanceof DigestAuth) {
eAuth.appendChild(getDigestAuthElement((DigestAuth)auth));
}
else if(auth instanceof NtlmAuth) {
eAuth.appendChild(getNtlmAuthElement((NtlmAuth)auth));
}
else if(auth instanceof OAuth2BearerAuth) {
eAuth.appendChild(getOAuth2BearerElement((OAuth2BearerAuth)auth));
}
return eAuth;
}
代码示例来源:origin: stanfordnlp/CoreNLP
Element timexElem = new Element("Timex", curNS);
timexElem.addAttribute(new Attribute("tid", timex.tid()));
timexElem.addAttribute(new Attribute("type", timex.timexType()));
Element cur = new Element("TrueCase", curNS);
cur.appendChild(token.get(CoreAnnotations.TrueCaseAnnotation.class));
wordInfo.appendChild(cur);
Element cur = new Element("TrueCaseText", curNS);
cur.appendChild(token.get(CoreAnnotations.TrueCaseTextAnnotation.class));
wordInfo.appendChild(cur);
Element cur = new Element("sentiment", curNS);
cur.appendChild(token.get(SentimentCoreAnnotations.SentimentClass.class));
wordInfo.appendChild(cur);
Element cur = new Element("entitylink", curNS);
cur.appendChild(token.get(CoreAnnotations.WikipediaEntityAnnotation.class));
wordInfo.appendChild(cur);
内容来源于网络,如有侵权,请联系作者删除!