本文整理汇总了Java中org.apache.commons.lang3.tuple.Triple类的典型用法代码示例。如果您正苦于以下问题:Java Triple类的具体用法?Java Triple怎么用?Java Triple使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Triple类属于org.apache.commons.lang3.tuple包,在下文中一共展示了Triple类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listAllJobs
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
public ResultBundle<Map<String, Triple<SpiderInfo, JobKey, Trigger>>> listAllJobs() {
Map<String, Triple<SpiderInfo, JobKey, Trigger>> result = new HashMap<>();
for(JobKey key:manager.listAll(QUARTZ_JOB_GROUP_NAME)) {
Pair<JobDetail, Trigger> pair = manager.findInfo(key);
SpiderInfo info = (SpiderInfo)pair.getLeft().getJobDataMap().get("spiderInfo");
result.put(info.getId(), Triple.of(info, key, pair.getRight()));
}
return builder.bundle(null, () -> result);
}
示例2: getAnnotatedSnippetS3
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
private JSONArray getAnnotatedSnippetS3(String query, WikipediaInterface wikiApi) throws JSONException, IOException {
JSONArray res = new JSONArray();
if (this.annotatedSnippetsAndBoldsS3.containsKey(query))
for (Triple<String, HashSet<Annotation>, HashSet<Mention>> p : this.annotatedSnippetsAndBoldsS3.get(query)) {
JSONObject pairJs = new JSONObject();
res.put(pairJs);
pairJs.put("snippet", p.getLeft());
JSONArray annotationsJs = new JSONArray();
pairJs.put("parts", annotationsJs);
int lastIdx = 0;
for (Annotation a : SmaphUtils.sorted(p.getMiddle())) {
annotationsJs.put(getTextPartJson(p.getLeft(), lastIdx, a.getPosition(), p.getRight()));
JSONObject annotationJs = getTextPartJson(p.getLeft(), a.getPosition(), a.getPosition() + a.getLength(),
p.getRight());
annotationsJs.put(annotationJs);
annotationJs.put("title", wikiApi.getTitlebyId(a.getConcept()));
annotationJs.put("wid", a.getConcept());
annotationJs.put("url", widToUrl(a.getConcept(), wikiApi));
lastIdx = a.getPosition() + a.getLength();
}
annotationsJs.put(getTextPartJson(p.getLeft(), lastIdx, p.getLeft().length(), p.getRight()));
}
return res;
}
示例3: getEntityFeaturesJson
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
private JSONArray getEntityFeaturesJson(
HashMap<String, List<Triple<Integer, HashMap<String, Double>, Boolean>>> source,
String query, WikipediaInterface wikiApi) throws JSONException,
IOException {
JSONArray res = new JSONArray();
if (source.containsKey(query))
for (Triple<Integer, HashMap<String, Double>, Boolean> p : source
.get(query)) {
JSONObject pairJs = new JSONObject();
res.put(pairJs);
pairJs.put("wid", p.getLeft());
pairJs.put("title", wikiApi.getTitlebyId(p.getLeft()));
pairJs.put("url", widToUrl(p.getLeft(), wikiApi));
JSONObject features = new JSONObject();
pairJs.put("features", features);
for (String ftrName : SmaphUtils.sorted(p.getMiddle().keySet()))
features.put(ftrName, p.getMiddle().get(ftrName));
pairJs.put("accepted", p.getRight());
}
return res;
}
示例4: getSourceSearchResultJson
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
private JSONArray getSourceSearchResultJson(
HashMap<String, List<Triple<Integer, String, Integer>>> source,
String query, WikipediaInterface wikiApi) throws JSONException, IOException {
JSONArray res = new JSONArray();
if (source.containsKey(query))
for (Triple<Integer, String, Integer> t : source.get(query)) {
JSONObject triple = new JSONObject();
res.put(triple);
triple.put("rank", t.getLeft());
triple.put("wid", t.getRight());
triple.put("title",
t.getRight() >= 0 ? wikiApi.getTitlebyId(t.getRight())
: "---not a wikipedia page---");
triple.put("url", t.getMiddle());
}
return res;
}
示例5: getMinMaxAvg
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
public static Triple<Double, Double, Double> getMinMaxAvg(List<Double> values) {
if (values.isEmpty())
return new ImmutableTriple<Double, Double, Double>(0.0, 0.0, 0.0);
double minVal = Double.POSITIVE_INFINITY;
double maxVal = Double.NEGATIVE_INFINITY;
double avgVal = 0.0;
for (double v : values) {
minVal = Math.min(v, minVal);
maxVal = Math.max(v, maxVal);
avgVal += v / values.size();
}
return new ImmutableTriple<Double, Double, Double>(minVal, maxVal,
avgVal);
}
示例6: getBoldsEDCapitalizedWordcount
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
private static Triple<Double, Double, Double> getBoldsEDCapitalizedWordcount(String query, int rank, List<Pair<String, Integer>> websearchBolds){
double minEdDist = 1.0;
double capitalized = 0;
double avgNumWords = 0;
int boldsCount = 0;
for (Pair<String, Integer> p : websearchBolds)
if (p.second == rank) {
boldsCount++;
minEdDist = Math.min(minEdDist,
SmaphUtils.getMinEditDist(query, p.first));
if (Character.isUpperCase(p.first.charAt(0)))
capitalized++;
avgNumWords += p.first.split("\\W+").length;
}
if (boldsCount != 0)
avgNumWords /= boldsCount;
return new ImmutableTriple<>(minEdDist, capitalized, avgNumWords);
}
示例7: getAdvancedARToFtrsAndPresence
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
private List<Triple<Annotation, AnnotationFeaturePack, Boolean>> getAdvancedARToFtrsAndPresence(
String query, QueryInformation qi,
HashSet<Annotation> goldStandardAnn,
MatchRelation<Annotation> annotationMatch) {
List<Triple<Annotation, AnnotationFeaturePack, Boolean>> annAndFtrsAndPresence = new Vector<>();
for (Annotation a : IndividualLinkback.getAnnotations(query,
qi.allCandidates(), anchorMaxED, e2a, wikiApi)) {
boolean inGold = false;
for (Annotation goldAnn : goldStandardAnn)
if (annotationMatch.match(goldAnn, a)) {
inGold = true;
break;
}
//if (e2a.containsId(a.getConcept())) {
AnnotationFeaturePack features = new AnnotationFeaturePack(a, query, qi, wikiApi, wikiToFreeb, e2a);
annAndFtrsAndPresence.add(new ImmutableTriple<Annotation, AnnotationFeaturePack, Boolean>(a, features, inGold));
//} else
// LOG.warn("No anchors found for id={}", a.getConcept());
}
return annAndFtrsAndPresence;
}
示例8: getLBBindingToFtrsAndF1
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
private List<Triple<HashSet<Annotation>, BindingFeaturePack, Double>> getLBBindingToFtrsAndF1(String query,
QueryInformation qi, HashSet<Annotation> goldStandardAnn, MatchRelation<Annotation> match,
Set<Tag> acceptedEntities, SmaphDebugger debugger) {
Collection<Pair<HashSet<Annotation>, BindingFeaturePack>> bindingAndFeaturePacks = CollectiveLinkBack
.getBindingFeaturePacks(query, acceptedEntities, qi, bg, wikiApi, wikiToFreeb, e2a, debugger);
List<Triple<HashSet<Annotation>, BindingFeaturePack, Double>> res = new Vector<>();
for (Pair<HashSet<Annotation>, BindingFeaturePack> bindingAndFeaturePack : bindingAndFeaturePacks) {
HashSet<Annotation> binding = bindingAndFeaturePack.first;
BindingFeaturePack bindingFeatures = bindingAndFeaturePack.second;
Metrics<Annotation> m = new Metrics<>();
float f1 = m.getSingleF1(goldStandardAnn, binding, match);
res.add(new ImmutableTriple<HashSet<Annotation>, BindingFeaturePack, Double>(
binding, bindingFeatures, (double) f1));
}
return res;
}
示例9: getLBUpperBound2
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
public Pair<HashSet<ScoredAnnotation>, Integer> getLBUpperBound2(String query,
HashSet<Annotation> goldStandardAnn, BindingGenerator bg, SmaphDebugger debugger)
throws Exception {
QueryInformation qi = getQueryInformation(query, debugger);
List<Triple<HashSet<Annotation>, BindingFeaturePack, Double>> bindingToFtrsAndF1 = getLBBindingToFtrsAndF1(
query, qi, goldStandardAnn, new StrongAnnotationMatch(
wikiApi), qi.allCandidates(), debugger);
HashSet<Annotation> bestBinding = null;
double bestF1 = Double.NEGATIVE_INFINITY;
for (Triple<HashSet<Annotation>, BindingFeaturePack, Double> bindingAndFtrsAndF1 : bindingToFtrsAndF1) {
double f1 = bindingAndFtrsAndF1.getRight();
if (f1 > bestF1) {
bestBinding = bindingAndFtrsAndF1.getLeft();
bestF1 = f1;
}
}
HashSet<ScoredAnnotation> bestBindingScored = new HashSet<>();
for (Annotation a: bestBinding)
bestBindingScored.add(new ScoredAnnotation(a.getPosition(), a.getLength(), a.getConcept(), 1.0f));
return new Pair<HashSet<ScoredAnnotation>, Integer>(bestBindingScored,
bindingToFtrsAndF1.size());
}
示例10: getUpperBoundMentions
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
public HashSet<ScoredAnnotation> getUpperBoundMentions(String query,
HashSet<Annotation> goldStandardAnn, BindingGenerator bg, SmaphDebugger debugger)
throws Exception {
QueryInformation qi = getQueryInformation(query, debugger);
List<Triple<HashSet<Annotation>, BindingFeaturePack, Double>> bindingToFtrsAndF1 = getLBBindingToFtrsAndF1(
query, qi, goldStandardAnn,
new StrongMentionAnnotationMatch(), qi.allCandidates(), debugger);
HashSet<Annotation> bestBinding = null;
double bestF1 = Double.NEGATIVE_INFINITY;
for (Triple<HashSet<Annotation>, BindingFeaturePack, Double> bindingAndFtrsAndF1 : bindingToFtrsAndF1) {
double f1 = bindingAndFtrsAndF1.getRight();
if (f1 > bestF1) {
bestBinding = bindingAndFtrsAndF1.getLeft();
bestF1 = f1;
}
}
if (bestBinding == null) return null;
HashSet<ScoredAnnotation> bestBindingScored= new HashSet<>();
for (Annotation a : bestBinding)
bestBindingScored.add(new ScoredAnnotation(a.getPosition(), a.getLength(), a.getConcept(), 1.0f));
return bestBindingScored;
}
示例11: onPendingTransactionUpdate
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
private void onPendingTransactionUpdate(TransactionReceipt txReceipt, EthereumListener.PendingTransactionState state, Block block) {
byte[] txHash = txReceipt.getTransaction().getHash();
Pair<Long, TransactionResultDTO> removed = remoteTxs.remove(txHash);
if (state == EthereumListener.PendingTransactionState.DROPPED) {
if (localTxs.remove(txHash) != null) {
System.out.println("Dropped due to timeout (matchned: " + (removed != null) + "): " + Hex.toHexString(txHash));
} else {
if (remoteTxs.containsKey(txHash)) {
System.err.println("Dropped but matching: " + Hex.toHexString(txHash) + ": \n" + txReceipt);
}
}
} else if (state == EthereumListener.PendingTransactionState.NEW_PENDING) {
System.out.println("Local: " + Hex.toHexString(txHash));
if (removed == null) {
localTxs.put(txHash, Triple.of(System.currentTimeMillis(), txReceipt, state));
} else {
System.out.println("Tx matched: " + Hex.toHexString(txHash));
}
}
checkUnmatched();
}
示例12: testBlockOnlyIncluded
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
@Test
public void testBlockOnlyIncluded() throws InterruptedException {
StandaloneBlockchain bc = new StandaloneBlockchain();
PendingListener l = new PendingListener();
bc.addEthereumListener(l);
Triple<TransactionReceipt, EthereumListener.PendingTransactionState, Block> txUpd = null;
PendingStateImpl pendingState = (PendingStateImpl) bc.getBlockchain().getPendingState();
ECKey alice = new ECKey();
ECKey bob = new ECKey();
bc.sendEther(bob.getAddress(), convert(100, ETHER));
Block b1 = bc.createBlock();
Transaction tx1 = bc.createTransaction(bob, 0, alice.getAddress(), BigInteger.valueOf(1000000), new byte[0]);
bc.submitTransaction(tx1);
Block b2 = bc.createBlock();
Block b2_ = bc.createForkBlock(b1);
Assert.assertTrue(l.getQueueFor(tx1).isEmpty());
Block b3_ = bc.createForkBlock(b2_);
txUpd = l.pollTxUpdate(tx1);
Assert.assertEquals(txUpd.getMiddle(), EthereumListener.PendingTransactionState.PENDING);
}
示例13: getTxEth
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
public List<Triple<Date,Long,Long>> getTxEth(String address) throws IOException {
String s = "https://"+url+"/api" +
"?module=account" +
"&action=txlist" +
"&address=" + address +
"&tag=latest" +
"&apikey="+apiKey;
HttpHeaders headers = new HttpHeaders();
headers.set("User-Agent", options.getUserAgent());
ResponseEntity<String> res = restTemplate.exchange(s, HttpMethod.GET, new HttpEntity<>(null, headers), String.class);
ObjectMapper objectMapper = new ObjectMapper();
TxReturnValue retVal = objectMapper.readValue(res.getBody(), TxReturnValue.class);
List<Triple<Date,Long,Long>> ret = new ArrayList<>();
for(TxReturnValue.Result result:retVal.result) {
long time = Long.parseLong(result.timeStamp) * 1000;
long value = Long.parseLong(result.value);
long blocknr = Long.parseLong(result.blockNumber);
ret.add(Triple.of(new Date(time), value, blocknr));
}
return ret;
}
示例14: getTxBtc
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
public List<Triple<Date, Long, Long>> getTxBtc(String address) throws ParseException, IOException {
String s = "https://" + url + "/api/v1/address/txs/" + address + "?amount_format=string";
HttpHeaders headers = new HttpHeaders();
headers.set("User-Agent", options.getUserAgent());
ResponseEntity<String> res = restTemplate.exchange(s, HttpMethod.GET, new HttpEntity<>(null, headers), String.class);
ObjectMapper objectMapper = new ObjectMapper();
TxReturnValue retVal = objectMapper.readValue(res.getBody(), TxReturnValue.class);
List<Triple<Date, Long, Long>> ret = new ArrayList<>();
if (retVal.data.nbTxs != retVal.data.nbTxsDisplayed) {
LOG.error("someone payed with over 200 tx, handle manually {}", address);
}
DateFormat m_ISO8601Local = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
for (TxReturnValue.Data.Tx result : retVal.data.txs) {
Date time = m_ISO8601Local.parse(result.timeUtc);
BigDecimal amount = new BigDecimal(result.amount).multiply(new BigDecimal(100_000_000));
ret.add(Triple.of(time, amount.longValue(), getBlockNr(result.tx)));
}
return ret;
}
示例15: processApplication
import org.apache.commons.lang3.tuple.Triple; //导入依赖的package包/类
private void processApplication(Map<String, Application> appCache,
Map.Entry<String, Pair<Set<GrpcHost>, Set<GrpcHost>>> entry) {
Triple<String, String, String> appNameServiceVersion = getAppNameServiceVersion(entry.getKey());
Pair<Set<GrpcHost>, Set<GrpcHost>> providerConsumer = entry.getValue();
String appName = appNameServiceVersion.getLeft();
String serviceName = appNameServiceVersion.getMiddle();
String version = appNameServiceVersion.getRight();
Application application = new Application(appName);
GrpcService service = new GrpcService(appName, version, serviceName);
if (providerConsumer.getLeft() != null) {
service.addProviderHosts(providerConsumer.getLeft());
}
if (providerConsumer.getRight() != null) {
service.addConsumerHosts(providerConsumer.getRight());
}
application.addService(service);
if (appCache.get(application.getAppName()) == null) {
appCache.put(application.getAppName(), application);
} else {
appCache.get(application.getAppName()).addServices(application.getServices());
}
}