• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ParsedName类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testCompareSanctioning

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
/**
 * Ignore the sanctioning author
 */
@Test
public void testCompareSanctioning() throws Exception {
  ParsedName p1 = new ParsedName();
  ParsedName p2 = new ParsedName();

  p1.setAuthorship("Fr. : Fr.");
  p2.setAuthorship("Fr.");

  assertEquals(Equality.EQUAL, comp.compare(p1, p2));

  p2.setAuthorship("Fr. : Pers.");
  assertEquals(Equality.EQUAL, comp.compare(p1, p2));

  p1.setBracketAuthorship("Mill.");
  p2.setBracketAuthorship("Mill. : Pers.");
  assertEquals(Equality.EQUAL, comp.compare(p1, p2));
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:21,代码来源:AuthorComparatorTest.java


示例17: testCompareUnparsedAuthor

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
@Test
public void testCompareUnparsedAuthor() throws Exception {
  ParsedName p1 = new ParsedName();
  p1.setScientificName("Platanus x hispanica Mill. ex Münch., 1770");
  p1.setGenusOrAbove("Platanus");
  p1.setSpecificEpithet("hispanica");
  p1.setNotho(NamePart.SPECIFIC);
  p1.setParsed(false);

  ParsedName p2 = new ParsedName();
  p2.setScientificName("Platanus hispanica Mill. ex Münch.");
  p2.setGenusOrAbove("Platanus");
  p2.setSpecificEpithet("hispanica");
  p2.setNotho(NamePart.SPECIFIC);
  p2.setAuthorship("Mill. ex Münch.");
  p2.setParsed(true);

  assertEquals(Equality.EQUAL, comp.compare(p1, p2));
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:20,代码来源:AuthorComparatorTest.java


示例18: testUnparsedAuthors

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
@Test
public void testUnparsedAuthors() throws Exception {
  ParsedName p3 = new ParsedName();
  p3.setParsed(false);
  p3.setScientificName("Blattaria Voet, ?, 1806");
  p3.setGenusOrAbove("Blattaria");

  ParsedName p4 = new ParsedName();
  p4.setScientificName("Blattaria Weyenbergh, 1874");
  p4.setAuthorship("Weyenbergh");
  p4.setYear("1874");

  assertEquals(Equality.DIFFERENT, comp.compare(p3, p4));

  p4.setYear("1806");
  assertEquals(Equality.EQUAL, comp.compare(p3, p4));
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:18,代码来源:AuthorComparatorTest.java


示例19: testGroupPlantBasionyms3

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
@Test
public void testGroupPlantBasionyms3() throws Exception {
  List<ParsedName> names = names(
      "Negundo aceroides subsp. violaceus (G.Kirchn.) W.A.Weber",
      "Negundo aceroides subsp. violaceus (Kirchner) W.A. Weber",

      "Negundo aceroides subsp. violaceum (Booth ex G.Kirchn.) Holub",
      "Negundo aceroides subsp. violaceum (Booth ex Kirchner) Holub",

      "Negundo aceroides var. violaceum G.Kirchn. in Petzold & G.Kirchn.",
      "Acer violaceum (Kirchner) Simonkai",
      "Acer negundo var. violaceum (G. Kirchn.) H. Jaeger"
  );

  Collection<BasionymGroup<ParsedName>> groups = sorter.groupBasionyms(names);
  assertEquals(1, groups.size());
  BasionymGroup<ParsedName> g = groups.iterator().next();
  assertFalse(g.getRecombinations().isEmpty());
  assertEquals(6, g.getRecombinations().size());
  assertNotNull(g.getBasionym());
  assertEquals("G.Kirchn.", g.getBasionym().authorshipComplete());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:23,代码来源:BasionymSorterTest.java


示例20: applyMatch

import org.gbif.api.model.checklistbank.ParsedName; //导入依赖的package包/类
private static void applyMatch(Occurrence occ, NameUsageMatch match, Collection<OccurrenceIssue> issues) {
  occ.setTaxonKey(match.getUsageKey());
  occ.setScientificName(match.getScientificName());
  occ.setTaxonRank(match.getRank());

  // copy issues
  occ.getIssues().addAll(issues);

  // parse name into pieces - we dont get them from the nub lookup
  try {
    ParsedName pn = PARSER.parse(match.getScientificName(), match.getRank());
    occ.setGenericName(pn.getGenusOrAbove());
    occ.setSpecificEpithet(pn.getSpecificEpithet());
    occ.setInfraspecificEpithet(pn.getInfraSpecificEpithet());
  } catch (UnparsableException e) {
    if (e.type.isParsable()) {
      LOG.warn("Fail to parse backbone {} name for occurrence {}: {}", e.type, occ.getKey(), e.name);
    }
  }

  for (Rank r : Rank.DWC_RANKS) {
    org.gbif.api.util.ClassificationUtils.setHigherRank(occ, r, match.getHigherRank(r));
    org.gbif.api.util.ClassificationUtils.setHigherRankKey(occ, r, match.getHigherRankKey(r));
  }
  LOG.debug("Occurrence {} matched to nub {} [{}]", occ.getKey(), occ.getScientificName(), occ.getTaxonKey());
}
 
开发者ID:gbif,项目名称:occurrence,代码行数:27,代码来源:TaxonomyInterpreter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CaseStatement类代码示例发布时间:2022-05-22
下一篇:
Java GetApplicationAttemptReportResponseProtoOrBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap