use of org.apache.commons.lang3.StringUtils.EMPTY in project pyramid by cheng-li.
the class ESIndex method getTermStats.
/**
* df is from one shard!!!
* @param id
* @return term statistics from one doc
* @throws IOException
*/
public Set<TermStat> getTermStats(String field, String id) throws IOException {
StopWatch stopWatch = null;
if (logger.isDebugEnabled()) {
stopWatch = new StopWatch();
stopWatch.start();
}
TermVectorResponse response = client.prepareTermVector(indexName, documentType, id).setOffsets(false).setPositions(false).setFieldStatistics(false).setTermStatistics(true).setSelectedFields(field).execute().actionGet();
Terms terms = response.getFields().terms(field);
Set<TermStat> set = new HashSet<>();
// if the field is empty, terms==null
if (terms == null) {
return set;
}
TermsEnum iterator = terms.iterator(null);
for (int i = 0; i < terms.size(); i++) {
String term = iterator.next().utf8ToString();
int tf = iterator.docsAndPositions(null, null).freq();
int df = iterator.docFreq();
DefaultSimilarity defaultSimilarity = new DefaultSimilarity();
/**
* from lucene
*/
/**
* tf is just tf, not square root of tf as in lucene
*/
/** Implemented as <code>log(numDocs/(docFreq+1)) + 1</code>. */
float tfidf = tf * defaultSimilarity.idf(df, this.numDocs);
TermStat termStat = new TermStat(term);
termStat.setTf(tf).setDf(df).setTfidf(tfidf);
set.add(termStat);
}
if (logger.isDebugEnabled()) {
logger.debug("time spent on getNgramInfos for " + id + " = " + stopWatch);
}
return set;
}
use of org.apache.commons.lang3.StringUtils.EMPTY in project API by ca-cwds.
the class ScreeningToReferralService method processReferralAddress.
private gov.ca.cwds.rest.api.domain.Address processReferralAddress(ScreeningToReferral scr, Set<ErrorMessage> messages) throws ServiceException {
gov.ca.cwds.rest.api.domain.Address address = scr.getAddress();
if (address == null || address.getZip() == null || address.getStreetAddress() == null || address.getType() == null) {
String message = " Screening address is null or empty";
ServiceException se = new ServiceException(message);
logError(message, se, messages);
return address;
}
try {
Address domainAddress = Address.createWithDefaults(address, DEFAULT_STATE_CODE);
buildErrors(messages, validator.validate(domainAddress));
PostedAddress postedAddress = (PostedAddress) this.addressService.create(domainAddress);
address.setLegacyId(postedAddress.getExistingAddressId());
address.setLegacySourceTable("ADDRS_T");
} catch (Exception e) {
logError(e.getMessage(), e, messages);
}
return address;
}
use of org.apache.commons.lang3.StringUtils.EMPTY in project gatk-protected by broadinstitute.
the class EvaluateCopyNumberTriStateCalls method buildAndAnnotateTruthOverlappingGenotype.
private Genotype buildAndAnnotateTruthOverlappingGenotype(final String sample, final VariantContext truth, final List<VariantContext> calls, final TargetCollection<Target> targets) {
final Genotype truthGenotype = truth.getGenotype(sample);
// if there is no truth genotype for that sample, we output the "empty" genotype.
if (truthGenotype == null) {
return GenotypeBuilder.create(sample, Collections.emptyList());
}
final int truthCopyNumber = GATKProtectedVariantContextUtils.getAttributeAsInt(truthGenotype, GS_COPY_NUMBER_FORMAT_KEY, truthNeutralCopyNumber);
final CopyNumberTriStateAllele truthAllele = copyNumberToTrueAllele(truthCopyNumber);
final List<Pair<VariantContext, Genotype>> allCalls = calls.stream().map(vc -> new ImmutablePair<>(vc, vc.getGenotype(sample))).filter(pair -> pair.getRight() != null).filter(pair -> GATKProtectedVariantContextUtils.getAttributeAsString(pair.getRight(), XHMMSegmentGenotyper.DISCOVERY_KEY, XHMMSegmentGenotyper.DISCOVERY_FALSE).equals(XHMMSegmentGenotyper.DISCOVERY_TRUE)).collect(Collectors.toList());
final List<Pair<VariantContext, Genotype>> qualifiedCalls = composeQualifyingCallsList(targets, allCalls);
return buildAndAnnotateTruthOverlappingGenotype(sample, targets, truthGenotype, truthCopyNumber, truthAllele, qualifiedCalls);
}
use of org.apache.commons.lang3.StringUtils.EMPTY in project gatk by broadinstitute.
the class EvaluateCopyNumberTriStateCalls method buildAndAnnotateTruthOverlappingGenotype.
private Genotype buildAndAnnotateTruthOverlappingGenotype(final String sample, final VariantContext truth, final List<VariantContext> calls, final TargetCollection<Target> targets) {
final Genotype truthGenotype = truth.getGenotype(sample);
// if there is no truth genotype for that sample, we output the "empty" genotype.
if (truthGenotype == null) {
return GenotypeBuilder.create(sample, Collections.emptyList());
}
final int truthCopyNumber = GATKProtectedVariantContextUtils.getAttributeAsInt(truthGenotype, GS_COPY_NUMBER_FORMAT_KEY, truthNeutralCopyNumber);
final CopyNumberTriStateAllele truthAllele = copyNumberToTrueAllele(truthCopyNumber);
final List<Pair<VariantContext, Genotype>> allCalls = calls.stream().map(vc -> new ImmutablePair<>(vc, vc.getGenotype(sample))).filter(pair -> pair.getRight() != null).filter(pair -> GATKProtectedVariantContextUtils.getAttributeAsString(pair.getRight(), XHMMSegmentGenotyper.DISCOVERY_KEY, XHMMSegmentGenotyper.DISCOVERY_FALSE).equals(XHMMSegmentGenotyper.DISCOVERY_TRUE)).collect(Collectors.toList());
final List<Pair<VariantContext, Genotype>> qualifiedCalls = composeQualifyingCallsList(targets, allCalls);
return buildAndAnnotateTruthOverlappingGenotype(sample, targets, truthGenotype, truthCopyNumber, truthAllele, qualifiedCalls);
}
use of org.apache.commons.lang3.StringUtils.EMPTY in project bitsquare by bitsquare.
the class WithdrawalView method setAddressColumnCellFactory.
///////////////////////////////////////////////////////////////////////////////////////////
// ColumnCellFactories
///////////////////////////////////////////////////////////////////////////////////////////
private void setAddressColumnCellFactory() {
addressColumn.setCellValueFactory((addressListItem) -> new ReadOnlyObjectWrapper<>(addressListItem.getValue()));
addressColumn.setCellFactory(new Callback<TableColumn<WithdrawalListItem, WithdrawalListItem>, TableCell<WithdrawalListItem, WithdrawalListItem>>() {
@Override
public TableCell<WithdrawalListItem, WithdrawalListItem> call(TableColumn<WithdrawalListItem, WithdrawalListItem> column) {
return new TableCell<WithdrawalListItem, WithdrawalListItem>() {
private HyperlinkWithIcon hyperlinkWithIcon;
@Override
public void updateItem(final WithdrawalListItem item, boolean empty) {
super.updateItem(item, empty);
if (item != null && !empty) {
String address = item.getAddressString();
hyperlinkWithIcon = new HyperlinkWithIcon(address, AwesomeIcon.EXTERNAL_LINK);
hyperlinkWithIcon.setOnAction(event -> openBlockExplorer(item));
hyperlinkWithIcon.setTooltip(new Tooltip("Open external blockchain explorer for " + "address: " + address));
setGraphic(hyperlinkWithIcon);
} else {
setGraphic(null);
if (hyperlinkWithIcon != null)
hyperlinkWithIcon.setOnAction(null);
}
}
};
}
});
}
Aggregations