/** * TODO, so far: ignore * @param ya * @param paos_ref * @param refno * @return */ private boolean parseReferenceType(YAttribute ya, LinkedList<PredicateAndObject> paos_ref, int refno) { if(YConstants.AT_REFERENCE_PARSED_TYPE.equals(ya.getKey())){/*2*/ return true; }else return false; }
private static boolean attributeHasOneOfKeys(YAttribute attribute, String... keys) { final String key = attribute.getKey(); for (String matchKey : keys) { if (matchKey.equals(key)) { return true; } } return false; }
/** * TODO, so far: ignore * @param ya * @param paos_ref * @param refno * @return */ private boolean parseReferenceType(YAttribute ya, LinkedList<PredicateAndObject> paos_ref, int refno) { if(YConstants.AT_REFERENCE_PARSED_TYPE.equals(ya.getKey())){/*2*/ return true; }else return false; }
/** * accomplished * @param ya * @param paos_ref * @param refno * @return */ private boolean parseReferenceName(YAttribute ya, LinkedList<PredicateAndObject> paos_ref, int refno) { if(YConstants.AT_ENHANCED_FROM_ZBL_NAME.equals(ya.getKey())){/*8*/ for(YAttribute inner : ya.getAttributes()){ if(YConstants.AT_ENHANCED_FROM_ZBL_TYPE.equals(inner.getKey())){/*8.1*/ }else if(YConstants.AT_ENHANCED_FROM_ZBL_LANGUAGE.equals(inner.getKey())){/*8.2*/ }else if(YConstants.AT_ENHANCED_FROM_ZBL_VALUE.equals(inner.getKey())){/*8.3*/ paos_ref.add(new PredicateAndObject(RelConstants.RL_TITLE, inner.getValue())); } } return true; }else return false; }
/** * accomplished * @param ya * @param paos_ref * @param refno * @return */ private boolean parseReferenceName(YAttribute ya, LinkedList<PredicateAndObject> paos_ref, int refno) { if(YConstants.AT_ENHANCED_FROM_ZBL_NAME.equals(ya.getKey())){/*8*/ for(YAttribute inner : ya.getAttributes()){ if(YConstants.AT_ENHANCED_FROM_ZBL_TYPE.equals(inner.getKey())){/*8.1*/ }else if(YConstants.AT_ENHANCED_FROM_ZBL_LANGUAGE.equals(inner.getKey())){/*8.2*/ }else if(YConstants.AT_ENHANCED_FROM_ZBL_VALUE.equals(inner.getKey())){/*8.3*/ paos_ref.add(new PredicateAndObject(RelConstants.RL_TITLE, inner.getValue())); } } return true; }else return false; }
private List<YAttribute> removeDocumentTypeAttribute() { List<YAttribute> yAttributes = new ArrayList<>(); for (YAttribute yAttr : safe(article.getAttributes())) { if(!yAttr.getKey().equals(CS.DOCUMENT_TYPE)) { yAttributes.add(yAttr); } } return yAttributes; }
/** * transplantation form RelationStatementBuilder * @param ya * @param paos_ref * @param refno * @return */ private boolean parseReferenceText(YAttribute ya, LinkedList<PredicateAndObject> paos_ref, int refno) { if(YConstants.AT_REFERENCE_TEXT.equals(ya.getKey())){/*3*/ parseReferenceText(ya.getValue(), paos_ref, refno); return true; }else return false; }
/** * accomplished * @param ya * @param paos_ref * @param refno * @param refid * @return */ private boolean parseReferenceId(YAttribute ya, LinkedList<PredicateAndObject> paos_ref, int refno) { if(YConstants.AT_REFERENCE_PARSED_ID_MR.equals(ya.getKey())){/*1.1*/ paos_ref.add(new PredicateAndObject(RelConstants.RL_IS_DOCUMENT, RelConstants.NS_MR_DOCUMENT+ ya.getValue())); return true; }else if(YConstants.AT_REFERENCE_PARSED_ID_ZBL.equals(ya.getKey())){/*1.2*/ paos_ref.add(new PredicateAndObject(RelConstants.RL_IS_DOCUMENT, RelConstants.NS_ZBL_DOCUMENT+ ya.getValue())); return true; }else if(YConstants.AT_REFERENCE_PARSED_ID_ISBN.equals(ya.getKey())){ paos_ref.add(new PredicateAndObject(RelConstants.RL_HAS_ISBN, RelConstants.NS_ISBN+ ya.getValue())); return true; }else return false; }
/** * transplantation form RelationStatementBuilder * @param ya * @param paos_ref * @param refno * @param sb * @return * @throws YaddaException */ private boolean parseReferenceText(YAttribute ya, LinkedList<PredicateAndObject> paos_ref, int refno, StringBuffer sb) throws YaddaException { if(YConstants.AT_REFERENCE_TEXT.equals(ya.getKey())){/*3*/ sb.append(ya.getValue().toString()); paos_ref.add(new PredicateAndObject(RelConstants.RL_TEXT, ya.getValue().toString())); //further parsing of reference-parsed-text is done in parseReferences() method, //hence parsing here is not allowed return true; }else return false; }
@Override public DBObject convert(Collection<YAttribute> source) { DBObject dbObject = new BasicDBObject(); for(YAttribute attribute : source){ Object attributeValue = getAttributeValue(attribute); Object object = dbObject.get(attribute.getKey()); attributeValue = processValue(attributeValue, object); String key = converter.potentiallyEscapeMapKey(attribute.getKey()); dbObject.put(key, attributeValue); } return dbObject; }
private void proceedReferenceAuthorZblFingerPrint(YAttribute ya, LinkedList<PredicateAndObject> pao) { for(YAttribute inner : ya.getAttributes()){ if(YConstants.AT_ZBL_AUTHOR_FINGERPRINT.equals(inner.getKey()) && !"-".equals(inner.getValue())){/*5.1*/ String zblfingerprint=inner.getValue(); pao.add(new PredicateAndObject(RelConstants.RL_IS_PERSON, RelConstants.NS_ZBL_PERSON + zblfingerprint)); } } }
/** * accomplished * @param ya * @param paos_ref * @param refno * @param refid * @return */ private boolean parseReferenceId(YAttribute ya, LinkedList<PredicateAndObject> paos_ref, int refno) { if(YConstants.AT_REFERENCE_PARSED_ID_MR.equals(ya.getKey())){/*1.1*/ paos_ref.add(new PredicateAndObject(RelConstants.RL_IS_DOCUMENT, RelConstants.NS_MR_DOCUMENT+ ya.getValue())); return true; }else if(YConstants.AT_REFERENCE_PARSED_ID_ZBL.equals(ya.getKey())){/*1.2*/ paos_ref.add(new PredicateAndObject(RelConstants.RL_IS_DOCUMENT, RelConstants.NS_ZBL_DOCUMENT+ ya.getValue())); return true; }else if(YConstants.AT_REFERENCE_PARSED_ID_ISBN.equals(ya.getKey())){ paos_ref.add(new PredicateAndObject(RelConstants.RL_HAS_ISBN, RelConstants.NS_ISBN+ ya.getValue())); return true; }else return false; }
protected List<ViewContact> resolveContacts(final YInstitution personality) { final List<ViewContact> contacts = new LinkedList<ViewContact>(); final List<String> contactKeys = new ArrayList<String>(); contactKeys.add(YConstants.AT_CONTACT); contactKeys.add(YConstants.AT_CONTACT_LOCATION); contactKeys.add(YConstants.AT_CONTACT_URL); contactKeys.add(YConstants.AT_CONTACT_EMAIL); contactKeys.add(YConstants.AT_CONTACT_PHONE); contactKeys.add(YConstants.AT_CONTACT_FAX); for (final String contactKey : contactKeys) { final List<YAttribute> ycontacts = personality.getAttributes(contactKey); if (ycontacts != null) { for (final YAttribute contact : ycontacts) { final ViewContact viewContact = new ViewContact(contact.getKey(), detailsFilter.filter( contact.getValue(), InputType.PLAIN_TEXT)); contacts.add(viewContact); } } } return contacts; }
@Override void compare(YElement expected, YElement actual, EvalResult result) { List<YAttribute> expAttributes = expected.getAttributes(); Map<String, List<String>> actAttMap = new HashMap<String, List<String>>(); for (YAttribute yatt : actual.getAttributes()) { String key = yatt.getKey(); if (actAttMap.get(key) == null) { actAttMap.put(key, new ArrayList<String>()); } actAttMap.get(key).add(yatt.getValue()); } for (YAttribute yatt : expAttributes) { String key = yatt.getKey(); if (actAttMap.containsKey(key)) { if (actAttMap.get(key).contains(yatt.getValue())) { result.append(key, ResultStatus.RECOGNIZED, 1); } else { result.append(key, ResultStatus.FAILED, 1); } //actAttMap.remove(key); } else { result.append(key, ResultStatus.FAILED, 1); } } for (String key : actAttMap.keySet()) { result.append(key, ResultStatus.REDUNDANT, 1); } } },
private static YAttribute extractOneReferenceTextAttributeScNode(YAttribute ya) { if(! ll.contains(ya.getKey())) return ya; for(Part p:ya.getRichValue().toParts()){ if(p instanceof Node){ if("sc".equals(((Node)p).getTag())) return new YAttribute(ya.getKey(),new YRichText(((Node)p).getParts().get(0).toString())); }else if(p instanceof Leaf) return new YAttribute(ya.getKey(),new YRichText(((Leaf)p).toPlainText())); } return ya; }
private static YAttribute extractOneReferenceTextAttributeScNode(YAttribute ya) { if(! ll.contains(ya.getKey())) return ya; for(Part p:ya.getRichValue().toParts()){ if(p instanceof Node){ if("sc".equals(((Node)p).getTag())) return new YAttribute(ya.getKey(),new YRichText(((Node)p).getParts().get(0).toString())); }else if(p instanceof Leaf) // if(p.toPlainText()!=null && !p.toPlainText().matches("[\\s]+")) return new YAttribute(ya.getKey(),new YRichText(((Leaf)p).toPlainText())); } return ya; } }
protected List<ViewContact> resolveContributorContacts(final YContributor contributor, final IFilteringContext filteringContext) { final List<ViewContact> contacts = new LinkedList<ViewContact>(); for (final YAttribute contact : contributor.getAttributes()) { if (contact.getKey().equals(YConstants.AT_AC_CONTACT_EMAIL)) { final ViewContact viewContact = new ViewContact(YConstants.AT_CONTACT_EMAIL, filterEmail(contact.getValue(), filteringContext)); contacts.add(viewContact); } else if (contact.getKey().equals(YConstants.AT_INSTITUTION)) { for (final YAttribute contact2 : contact.getAttributes()) { if (contact2.getKey().equals(YConstants.AT_INSTITUTION_MAIL)) { final ViewContact viewContact = new ViewContact(YConstants.AT_CONTACT_EMAIL, filterEmail(contact2.getValue(), filteringContext)); contacts.add(viewContact); } else if (contact2.getKey().equals(YConstants.AT_INSTITUTION_WWW)) { final ViewContact viewContact = new ViewContact(YConstants.AT_CONTACT_URL, detailsFilter.filter(contact2.getValue(), InputType.RICH_TEXT, filteringContext)); contacts.add(viewContact); } else if (contact2.getKey().equals(YConstants.AT_INSTITUTION_PHONE)) { final ViewContact viewContact = new ViewContact(YConstants.AT_CONTACT_PHONE, detailsFilter.filter(contact2.getValue(), InputType.RICH_TEXT, filteringContext)); contacts.add(viewContact); } } } } return contacts; }
private static YElement putRelationReferenceToLeafsIntoNodes(YElement yelement) { for(YRelation yr : yelement.getRelations()){ for(YAttribute ya : yr.getAttributes()){ if(! ll.contains(ya.getKey()))continue; removeGivenTag("sc", ya.getRichValue().toParts()); ya.setValue(new YRichText(extractLeafs(removeNodeWithGivenTag("ext-link", ya.getRichValue().toParts())))); } } return yelement; }
private static YElement putRelationReferenceToLeafsIntoNodes(YElement yelement) { for(YRelation yr : yelement.getRelations()){ // LinkedList<YAttribute> lya = new LinkedList<YAttribute>(); for(YAttribute ya : yr.getAttributes()){ if(! ll.contains(ya.getKey()))continue; removeGivenTag("sc", ya.getRichValue().toParts()); ya.setValue(new YRichText(extractLeafs(removeNodeWithGivenTag("ext-link", ya.getRichValue().toParts())))); // lya.add(ya); } // if(lya.size()>0)yr.setAttributes(lya); } return yelement; }