@Override protected boolean enhanceMetadata(BxDocument document, YElement metadata) { String text = ""; for (BxPage page : filterPages(document)) { for (BxZone zone : filterZones(page)) { String[] lines = zone.toText().split("\n"); for (String line : lines) { if (line.toLowerCase().startsWith("keywords") || line.toLowerCase().startsWith("key words")) { break; } text += "\n" + line; } } } text = text.trim(); if (!text.isEmpty()) { Matcher matcher = PREFIX.matcher(text); if (matcher.find()) { text = text.substring(matcher.end()).trim(); } metadata.addDescription(new YDescription().setType(YConstants.DS_ABSTRACT).setText(text)); return true; } return false; }
private List<String> trySoncaKeywords(YElement element, String finalText) { try { YDescription description = new YDescription(YLanguage.Polish, finalText); element.addDescription(description); YElement enrich = soncaMetadataEnricher.enrich(Lists.newArrayList(element)); List<YTagList> tagLists = enrich.getTagLists("sonca.keywords"); YTagList polishTagList = null; for (YTagList yTagList : tagLists) { if (yTagList.getLanguage() == YLanguage.Polish) { polishTagList = yTagList; } } if (polishTagList != null) { return polishTagList.getValues(); } else { return new ArrayList<String>(); } } catch (Exception e) { e.printStackTrace(); return new ArrayList<String>(); } }
public void convertDescription(BibEntry source, YElement yElement) { //note String note = source.getFirstFieldValue(BibEntry.FIELD_NOTE); if (note != null) { yElement.addDescription(new YDescription().setType(YConstants.DS_NOTE).setText(note)); } //abstract String abstractField = source.getFirstFieldValue(BibEntry.FIELD_ABSTRACT); if (abstractField != null) { yElement.addDescription(new YDescription().setType(YConstants.DS_ABSTRACT).setText(abstractField)); } }
continue; element.addDescription(description);
private YElement prepareYElement(String id, Properties prop) { YElement yElement = new YElement(); yElement.setId(id); if (!prop.getProperty("title").isEmpty()) { yElement.addName(new YName(prepareProperty("title", prop))); } yElement.addDescription(new YDescription(YLanguage.Undetermined, prepareProperty("description", prop), DescriptionTypes.DS_SUMMARY)); if (!prop.getProperty("key-words").isEmpty()) { List<String> tags = new ArrayList<String>(Arrays.asList(prepareProperty("key-words", prop).split(","))); yElement.addTagList(new YTagList().setType(TagTypes.TG_KEYWORD).setValues(tags)); } if (!prop.getProperty("supplier").isEmpty()) { yElement.addAttribute("copyright-holder", prepareProperty("supplier", prop)); } if (!prop.getProperty("duration").isEmpty()) { yElement.addAttribute("duration", prepareProperty("duration", prop)); } yElement.addLanguage(YLanguage.Undetermined); return yElement; }
private void updateArticleDescription(ZentralBlattRecord src, YElement yelement) { if (src.hasField("ab")) { String abText = src.getField("ab").trim(); if (isValidDescription(abText)) { YDescription desc = new YDescription(); desc.setType(isSummary(abText) ? YConstants.DS_SUMMARY : YConstants.DS_ABSTRACT); desc.setText(filterAbstractPrefixes(abText)); yelement.addDescription(desc); } } }
parent).addDescription(y.description(getYLang(aabstract), textOfElement(aabstract), DescriptionTypes.DS_ABSTRACT)).addLanguage(getYLang(ameta));
private boolean addMetadataIfNeeded(HarvestingResult harvestingResult, YElement element) { boolean metadataModified = false; if (shouldAbstractBeAdded(harvestingResult, element)) { Node htmlNode = new Node(BaseYModelUtils.XHTML_NAMESPACE, BaseYModelUtils.HTML_TAG); htmlNode.addPart(new Leaf(StringUtils.trim(harvestingResult.getDesciption()))); YRichText richText = new YRichText(Arrays.asList(htmlNode)); YDescription newAbstract = new YDescription(YLanguage.Undetermined, richText, DescriptionTypes.DS_ABSTRACT); element.addDescription(newAbstract); metadataModified = true; } if (shouldImpactFactorBeAdded(harvestingResult, element)) { element.addAttribute(new YAttribute(YModelUtils.IMPACT_FACTOR, harvestingResult.getImpactFactor().toEngineeringString())); metadataModified = true; } if (shouldFrequencyBeAdded(harvestingResult, element)) { element.addAttribute(new YAttribute(YModelUtils.FREQUENCY, harvestingResult.getFrequency())); metadataModified = true; } List<YCategoryRef> refs = element.getCategoryRefs(); if (shouldCategoryRefsBeAdded(harvestingResult, refs)) { refs.addAll(harvestingResult.getCategories()); metadataModified = true; } if (shouldTitlesBeAdded(harvestingResult, element)) { metadataModified |= addTitleHistory(harvestingResult.getOtherTitles(), element); } return metadataModified; }
parent).addDescription(y.description(getYLang(aabstract), textOfElement(aabstract), DS_ABSTRACT)).addLanguage(getYLang(ameta));
for (LocalizedData<String> description : resource.getDescriptions()) { if (StringUtils.isNotEmpty(description.getData())) { yElement.addDescription(new YDescription(description.getLanguage().getyLanguage(), extractor.extractFrom(description.getData())));
article.addDescription(y.description(JDOMHelper.getYLang(aabstract), JDOMHelper.textOfElement(aabstract), DS_ABSTRACT)); article.addDescription(y.description(JDOMHelper.getYLang(tr), JDOMHelper.textOfElement(tr), "trans-abstract"));
private void prepareYElementFromApi(Video video, YElement yElement) throws ParseException { yElement.addName(new YName(video.getSnippet().getTitle())); yElement.addDescription(new YDescription(YLanguage.Undetermined, video.getSnippet().getDescription() , DescriptionTypes.DS_SUMMARY)); prepareDate(video, yElement); String license = video.getStatus().getLicense(); if(null != license && license.contains("creativeCommon")) { yElement.addTagList(new YTagList().setType(YModelUtils.LICENSE).addValue("cc0")); } prepareContent(video, yElement); List<String> tags = video.getSnippet().getTags(); if (CollectionUtils.isNotEmpty(tags)) { yElement.addTagList(new YTagList().setType(TagTypes.TG_KEYWORD).setValues(tags)); } YCurrent currentLevel = new YCurrent().setLevel(VideoConstants.VIDEO_CURRENT_LEVEL); yElement.addStructure(new YStructure() .setHierarchy(HierarchyWithLevelIds.EXT_HIERARCHY_PUBLICATION) .setCurrent(currentLevel)); prepareAttributes(video, yElement); }
private YElement initArticleinBookElement(org.jdom.Element ameta, YElement parent, NlmIdGenerator idGenerator) { org.jdom.Element atitles = JDOMHelper.optDescendant(ameta, "title-group"); org.jdom.Element atitle = JDOMHelper.optDescendant(atitles, "article-title"); org.jdom.Element aabstract = JDOMHelper.getChild(ameta, "abstract"); Element articleId = JDOMHelper.getChildWithGivenAttributeValue(ameta, "article-id", "pub-id-type", "eudml-id"); String eudmlId=articleId==null?null:articleId.getValue(); String id=idGenerator.getBookArticleId(eudmlId); YElement article = factory.element(NlmToYConstants.EXT_HIERARCHY_MBOOK_ARTICLE, NlmToYConstants.EXT_LEVEL_MBOOK_ARTICLE_ARTICLE, y.canonicalName(JDOMHelper.getYLang(atitle), JDOMHelper.textOfElement(atitle)), parent, id) .addDescription(y.description(JDOMHelper.getYLang(aabstract), JDOMHelper.textOfElement(aabstract), DescriptionTypes.DS_ABSTRACT)) .addLanguage(JDOMHelper.getYLang(ameta)); List<org.jdom.Element> trs = JDOMHelper.optChildren(atitles, "trans-title-group"); for (org.jdom.Element tr : trs) { article.addName(y.name(JDOMHelper.getYLang(tr), JDOMHelper.textOfElement(JDOMHelper.getChild(tr, "trans-title")), NameTypes.NM_ALTERNATIVE)); } return article; }
book.addDescription(y.description(JDOMHelper.getYLang(babstract), JDOMHelper.textOfElement(babstract), DescriptionTypes.DS_ABSTRACT)).addLanguage(JDOMHelper.getYLang(bmeta)); book.addDescription(y.description(JDOMHelper.getYLang(tr), JDOMHelper.textOfElement(tr), "trans-abstract"));
if(abstrakt!=null){ if(abstrakt.getAbstractText()!=null){ article.addDescription(new YDescription(YLanguage.English,xmc.getArticle().getAbstract().getAbstractText(),DescriptionTypes.DS_ABSTRACT)); if(otherAbstrakt!=null){ if(otherAbstrakt.getAbstractText()!=null){ article.addDescription(new YDescription(YLanguage.Undetermined,otherAbstrakt.getAbstractText(),DescriptionTypes.DS_ABSTRACT)); if(generalNotes!=null){ for(String note:generalNotes){ article.addDescription(new YDescription(YLanguage.Undetermined,note, DescriptionTypes.DS_NOTE));