当前位置: 首页>>代码示例>>Java>>正文


Java ParsedName类代码示例

本文整理汇总了Java中org.gbif.api.model.checklistbank.ParsedName的典型用法代码示例。如果您正苦于以下问题:Java ParsedName类的具体用法?Java ParsedName怎么用?Java ParsedName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ParsedName类属于org.gbif.api.model.checklistbank包,在下文中一共展示了ParsedName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseToCanonical

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
@Override
// parses the name without authorship and returns the ParsedName.canonicalName() string
public String parseToCanonical(String scientificName, @Nullable Rank rank) {
  if (Strings.isNullOrEmpty(scientificName)) {
    return null;
  }
  try {
    ParsedName pn = parse(scientificName, rank);
    if (pn != null) {
      return pn.canonicalName();
    }
  } catch (UnparsableException e) {
    logUnparsable(e);
  }
  return null;
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:17,代码来源:NameParserGbifV1.java

示例2: convertNameType

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
@Test
public void convertNameType() throws Exception {
  org.gbif.nameparser.api.ParsedName pn = new org.gbif.nameparser.api.ParsedName();
  for (org.gbif.nameparser.api.NameType t : org.gbif.nameparser.api.NameType.values()) {
    pn.setType(t);
    assertNotNull(NameParserGbifV1.gbifNameType(pn));
  }
  pn.setCandidatus(true);
  assertEquals(NameType.CANDIDATUS, NameParserGbifV1.gbifNameType(pn));

  pn.setCandidatus(false);
  pn.setCultivarEpithet("Bella");
  assertEquals(NameType.CULTIVAR, NameParserGbifV1.gbifNameType(pn));

  pn.setDoubtful(true);
  assertEquals(NameType.DOUBTFUL, NameParserGbifV1.gbifNameType(pn));
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:18,代码来源:NameParserGbifV1Test.java

示例3: parseQuietly

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
@Test
public void parseQuietly() throws Exception {
  ParsedName pn = parser.parseQuietly("Navicula var. fasciata", Rank.VARIETY);
  assertNull(pn.getSpecificEpithet());
  assertEquals(NameType.INFORMAL, pn.getType());

  assertEquals("Abies alba", parser.parseQuietly("Abies alba Mill.").canonicalName());
  pn = parser.parseQuietly("Abies alba x Pinus graecus L.");
  assertEquals("Abies alba x Pinus graecus L.", pn.getScientificName());
  assertEquals(NameType.HYBRID, pn.getType());
  assertNull(pn.getGenusOrAbove());

  assertFalse(parser.parseQuietly("Protoscenium simplex  (Cleve, 1899), Jørgensen, 1905 ", Rank.SPECIES).isParsedPartially());
  assertFalse(parser.parseQuietly("Plagiacanthidae", Rank.SPECIES).isParsedPartially());

  pn = parser.parseQuietly("Plagiacanthidae WhatTheHeck @%&/ (please dont parse me[ he?5789])", Rank.SPECIES);
  assertTrue(pn.isParsed());
  assertTrue(pn.isParsedPartially());
  assertEquals("Plagiacanthidae", pn.getGenusOrAbove());
}
 
开发者ID:gbif,项目名称:name-parser,代码行数:21,代码来源:NameParserGbifV1Test.java

示例4: queryHigher

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
private List<NameUsageMatch> queryHigher(ParsedName pn, String canonicalName, Rank rank, LinneanClassification lc, boolean verbose) {
  // do a lucene matching
  List<NameUsageMatch> matches = nubIndex.matchByName(canonicalName, false, 50);
  for (NameUsageMatch m : matches) {
    // 0 - +100
    final int nameSimilarity = nameSimilarity(canonicalName, m);
    // -50 - +50
    final int classificationSimilarity = classificationSimilarity(lc, m);
    // -10 - +5
    final int rankSimilarity = rankSimilarity(rank, m.getRank()) * 2;
    // -5 - +1
    final int statusScore = STATUS_SCORE.get(m.getStatus());

    // preliminary total score, -5 - 20 distance to next best match coming below!
    m.setConfidence(nameSimilarity + classificationSimilarity + rankSimilarity + statusScore);

    if (verbose) {
      addNote(m, "Similarity: name=" + nameSimilarity);
      addNote(m, "classification=" + classificationSimilarity);
      addNote(m, "rank=" + rankSimilarity);
      addNote(m, "status=" + statusScore);
    }
  }

  return matches;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:27,代码来源:NubMatchingServiceImpl.java

示例5: authorSimilarity

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
private int authorSimilarity(@Nullable ParsedName pn, NameUsageMatch m) {
  int similarity = 0;
  if (pn != null) {
    try {
      ParsedName mpn = parser.parse(m.getScientificName(), m.getRank());
      // authorship comparison was requested!
      Equality recomb = authComp.compare(pn.getAuthorship(), pn.getYear(), mpn.getAuthorship(), mpn.getYear());
      Equality bracket = authComp.compare(pn.getBracketAuthorship(), pn.getBracketYear(), mpn.getBracketAuthorship(), mpn.getBracketYear());

      similarity = equality2Similarity(recomb, 3);
      similarity = similarity + equality2Similarity(bracket, 1);

    } catch (UnparsableException e) {
      if (e.type.isParsable()) {
        LOG.warn("Failed to parse name: {}", m.getScientificName());
      }
    }
  }

  return similarity;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:22,代码来源:NubMatchingServiceImpl.java

示例6: parse

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
private List<ParsedName> parse(Iterator<String> iter) {
  int counter = 0;
  int unparsable = 0;
  List<ParsedName> pnames = Lists.newArrayList();

  while (iter.hasNext()) {
    final String name = iter.next();
    ParsedName pn = parser.parseQuietly(name);
    pnames.add(pn);
    counter++;
    if (!pn.getType().isParsable()) {
      unparsable++;
    }
  }

  LOG.debug("Parsed {} names out of which {} are unparsable", counter, unparsable);
  return pnames;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:19,代码来源:NameParserResource.java

示例7: matchesNub

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
private boolean matchesNub(ParsedName pn, Rank rank, Kingdom uKingdom, NubUsage match, @Nullable NubUsage currNubParent, boolean ignoreAuthor) {
  if (rank != match.rank) {
    return false;
  }
  // no homonyms above genus level
  if (rank.isSuprageneric()) {
    return true;
  }
  Equality author = ignoreAuthor ? Equality.UNKNOWN : authComp.compare(pn, match.parsedName);
  Equality kingdom = compareKingdom(uKingdom, match.kingdom);
  switch (author) {
    case DIFFERENT:
      return false;
    case EQUAL:
      return true;
    case UNKNOWN:
      return kingdom != Equality.DIFFERENT && (
          rank.isSpeciesOrBelow() || compareClassification(currNubParent, match) != Equality.DIFFERENT
      );
  }
  return false;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:23,代码来源:NubDb.java

示例8: createBasionymPlaceholder

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
private NubUsage createBasionymPlaceholder(NubUsage family, BasionymGroup group) {
  NubUsage basionym = new NubUsage();
  basionym.datasetKey = null;
  basionym.origin = Origin.BASIONYM_PLACEHOLDER;
  basionym.rank = Rank.UNRANKED;
  basionym.status = TaxonomicStatus.DOUBTFUL;
  basionym.parsedName = new ParsedName();
  basionym.parsedName.setGenusOrAbove("?");
  basionym.parsedName.setSpecificEpithet(group.getEpithet());
  basionym.parsedName.setAuthorship(group.getAuthorship());
  basionym.parsedName.setYear(group.getYear());
  basionym.parsedName.setType(NameType.PLACEHOLDER);
  basionym.parsedName.setScientificName(basionym.parsedName.fullName());
  LOG.debug("creating basionym placeholder {} in family {}", basionym.parsedName.canonicalNameComplete(), family.parsedName.canonicalName());
  return db.addUsage(family, basionym);
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:17,代码来源:NubBuilder.java

示例9: create

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
protected NameUsageNode create(NameUsage u, boolean isRoot) {
  Node n = dao.createTaxon();
  if (u.getTaxonomicStatus() != null && u.getTaxonomicStatus().isSynonym()) {
    n.addLabel(Labels.SYNONYM);
  }
  if (isRoot) {
    n.addLabel(Labels.ROOT);
  }

  // parse name and store it
  ParsedName pn = PARSER.parseQuietly(u.getScientificName(), u.getRank());
  dao.store(n.getId(), pn);

  // update canonical and store usage
  //u.setCanonicalName(pn.canonicalNameWithMarker());
  NameUsageNode nn = new NameUsageNode(n, u, true);
  dao.store(nn, true);

  return nn;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:21,代码来源:ImportDb.java

示例10: UsageDao

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
/**
 * @param kvp
 * @param neoDir
 * @param neoFactory
 * @param registry
 */
private UsageDao(DB kvp, File neoDir, @Nullable File kvpStore, GraphDatabaseBuilder neoFactory, @Nullable MetricRegistry registry) {
  try {
    this.neoFactory = neoFactory;
    this.neoDir = neoDir;
    this.kvpStore = kvpStore;
    this.kvp = kvp;
    this.registry = registry;

    names = createKvpMap("names", ParsedName.class, 128);
    facts = createKvpMap("facts", UsageFacts.class, 128);
    verbatim = createKvpMap("verbatim", VerbatimNameUsage.class, 512);
    usages = createKvpMap("usages", NameUsage.class, 256);
    extensions = createKvpMap("extensions", UsageExtensions.class, 512);
    srcUsages = createKvpMap("srcUsages", SrcUsage.class, 256);
    nubUsages = createKvpMap("nubUsages", NubUsage.class, 256);

    openNeo();
  } catch (Exception e) {
    LOG.error("Failed to initialize a new DAO", e);
    close();
    throw e;
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:30,代码来源:UsageDao.java

示例11: testEmptyModels

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
@Test
public void testEmptyModels() throws Exception {
    assertSerde(new NameUsage());
    assertSerde(new VerbatimNameUsage());
    assertSerde(new NameUsageMetrics());
    assertSerde(new UsageExtensions());
    assertSerde(new ParsedName());
    assertSerde(new Description());
    assertSerde(new Distribution());
    assertSerde(new Identifier());
    assertSerde(new NameUsageMediaObject());
    assertSerde(new Reference());
    assertSerde(new SpeciesProfile());
    assertSerde(new NameUsage());
    assertSerde(new TypeSpecimen());
    assertSerde(new VernacularName());
    assertSerde(new DatasetMetrics());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:19,代码来源:CliKryoFactoryTest.java

示例12: testCountTaxa

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
@Test
public void testCountTaxa() throws Exception {
  UsageDao dao = UsageDao.temporaryDao(10);
  NubDb nub = NubDb.create(dao, AuthorComparator.createWithoutAuthormap());
  try (Transaction tx = dao.beginTx()) {

    assertEquals(0l, nub.countTaxa());

    NubUsage u = new NubUsage();
    u.parsedName = new ParsedName();
    u.origin = Origin.SOURCE;
    u.rank = Rank.SPECIES;
    nub.addRoot(u);
    assertEquals(1l, nub.countTaxa());

    // we add the same nub usage which already has a neo node, nothing changes
    nub.addRoot(u);
    assertEquals(1l, nub.countTaxa());

    u.node = null;
    nub.addRoot(u);
    assertEquals(2l, nub.countTaxa());
    tx.success();
  }

}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:27,代码来源:NubDbTest.java

示例13: nubusage

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
public static NubUsage nubusage(int key) {
  NubUsage u = new NubUsage();
  u.usageKey = key;
  u.datasetKey = UUID.randomUUID();
  u.kingdom = Kingdom.byNubUsageId(RND.nextInt(8));
  u.origin = Origin.SOURCE;
  u.addRemark(StringUtils.randomSpecies());
  u.parsedName = new ParsedName();
  u.parsedName.setGenusOrAbove(StringUtils.randomGenus());
  u.parsedName.setSpecificEpithet(StringUtils.randomEpithet());
  if (key % 5 == 0) {
    u.rank = Rank.SUBSPECIES;
    u.parsedName.setInfraSpecificEpithet(StringUtils.randomEpithet());
  } else {
    u.rank = Rank.SPECIES;
  }
  u.parsedName.setAuthorship(StringUtils.randomAuthor());
  u.parsedName.setYear(StringUtils.randomSpeciesYear());
  u.parsedName.setScientificName(u.parsedName.fullName());
  u.status = TaxonomicStatus.ACCEPTED;
  return u;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:23,代码来源:UsageDaoTest.java

示例14: scientificName

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
/**
 * @param pn
 * @param code to which rules to adhere to
 * @return
 */
public static String scientificName(ParsedName pn, NomenclaturalCode code) {
  if (!pn.isParsed() || NomenclaturalCode.VIRUS == code) {
    return pn.getScientificName();
  }

  // remove authorship if indet name
  if (pn.isIndetermined()) {
    return pn.buildName(true, true, false, false, true, false, true, false, true, false, false, false, true, true);
  }

  String sciname;
  if (code == NomenclaturalCode.ZOOLOGICAL && pn.getInfraSpecificEpithet() != null && Rank.SUBSPECIES == pn.getRank()) {
    Rank r = pn.getRank();
    pn.setRank(null);
    sciname = pn.buildName(true, false, true, false, true, false, true, false, true, false, false, false, true, true);
    pn.setRank(r);

  } else {
    sciname = pn.canonicalNameComplete();
  }

  return sciname;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:29,代码来源:NameFormatter.java

示例15: buildScientificName

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
/**
 * Assembles the most complete scientific name based on full and individual name parts.
 * @param scientificName the full scientific name
 * @param genericName see GbifTerm.genericName
 * @param genus see DwcTerm.genus
 * @param specificEpithet see DwcTerm.specificEpithet
 * @param infraspecificEpithet see DwcTerm.infraspecificEpithet
 */
public static String buildScientificName(String scientificName, String authorship, String genericName, String genus,
                                         String specificEpithet, String infraspecificEpithet) {
  String sciname = ClassificationUtils.clean(scientificName);
  if (sciname == null) {
    // handle case when the scientific name is null and only given as atomized fields: genus & speciesEpitheton
    ParsedName pn = new ParsedName();
    if (!StringUtils.isBlank(genericName)) {
      pn.setGenusOrAbove(genericName);
    } else {
      pn.setGenusOrAbove(genus);
    }
    pn.setSpecificEpithet(specificEpithet);
    pn.setInfraSpecificEpithet(infraspecificEpithet);
    pn.setAuthorship(authorship);
    sciname = pn.canonicalNameComplete();

  } else if (!Strings.isNullOrEmpty(authorship) && !sciname.toLowerCase().contains(authorship.toLowerCase())) {
    sciname = sciname + " " + authorship;
  }

  return sciname;
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:31,代码来源:TaxonomyInterpreter.java


注:本文中的org.gbif.api.model.checklistbank.ParsedName类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。