Package org.apache.stanbol.entityhub.servicesapi.model

Examples of org.apache.stanbol.entityhub.servicesapi.model.Reference


     */
    @Test
    public void testRemovalOfTypeRepresentationStatement() throws YardException {
        Yard yard = getYard();
        ValueFactory vf = yard.getValueFactory();
        Reference representationType = vf.createReference(RdfResourceEnum.Representation.getUri());
        Representation test = create();
        //the rdf:type Representation MUST NOT be within the Representation
        Assert.assertFalse(test.get(RDF.type.getUnicodeString()).hasNext());
        //now add the statement and see if an IllegalStateException is thrown
        /*
 
View Full Code Here


        for(Iterator<String> fields = rep.getFieldNames();fields.hasNext();){
            String field = fields.next();
            Iterator<Reference> values = rep.getReferences(field);
//            assertTrue(values.hasNext());
            while(values.hasNext()){
                Reference ref = values.next();
                assertNotNull(ref);
            }
        }
    }
View Full Code Here

                log.info(pos+" features processed ("+mean+"ms/feature)");
            }
        }
    }
    private Reference getDocRef(String refString){
        Reference ref = indexDocRefs.get(refString);
        if(ref == null){
            ref = yard.getValueFactory().createReference(refString);
            indexDocRefs.put(refString, ref);
        }
        return ref;
View Full Code Here

        Representation result = suggestion.getResult();
        Iterator<Reference> redirects = result.getReferences(config.getRedirectField());
        switch (config.getRedirectProcessingMode()) {
            case ADD_VALUES:
                while(redirects.hasNext()){
                    Reference redirect = redirects.next();
                    if(redirect != null){
                        Representation redirectedEntity = entitySearcher.get(redirect.getReference(),
                            config.getSelectedFields());
                        if(redirectedEntity != null){
                            for(Iterator<String> fields = redirectedEntity.getFieldNames();fields.hasNext();){
                                String field = fields.next();
                                result.add(field, redirectedEntity.get(field));
                            }
                        }
                        //set that the redirects where searched for this result
                        suggestion.setRedirectProcessed(true);
                    }
                }
            case FOLLOW:
                while(redirects.hasNext()){
                    Reference redirect = redirects.next();
                    if(redirect != null){
                        Representation redirectedEntity = entitySearcher.get(redirect.getReference(),
                            config.getSelectedFields());
                        if(redirectedEntity != null){
                            //copy the original result score
                            redirectedEntity.set(RdfResourceEnum.resultScore.getUri(),
                                result.get(RdfResourceEnum.resultScore.getUri()));
View Full Code Here

                            Set<UriRef> textAnnotationTypes = new HashSet<UriRef>();
                            for(Representation rep : suggestions){
                                Iterator<Reference> types = rep.getReferences(NamespaceEnum.rdf+"type");
                                log.info(" > Entity {}"+rep.getId());
                                while(types.hasNext()){
                                    Reference type = types.next();
                                    log.info("  - type {}",type.toString());
                                    UriRef textAnnotationType = DEFAULT_ENTITY_TYPE_MAPPINGS.get(type.getReference());
                                    if(textAnnotationType != null){
                                        textAnnotationTypes.add(textAnnotationType);
                                    }
                                }
                            }
View Full Code Here

    private Representation processRedirects(ReferencedSite site, Representation rep, Collection<String> fields) {
        Iterator<Reference> redirects = rep.getReferences(NamespaceEnum.rdfs+"seeAlso");
        switch (redirectState == null ? RedirectProcessingState.IGNORE : redirectState) {
            case ADD_VALUES:
                while(redirects.hasNext()){
                    Reference redirect = redirects.next();
                    if(redirect != null){
                        try {
                            Entity redirectedEntity = site != null ?
                                    site.getEntity(redirect.getReference()) :
                                        entityhub.getEntity(redirect.getReference());
                            if(redirectedEntity != null){
                                for(String field: fields){
                                    rep.add(field, redirectedEntity.getRepresentation().get(field));
                                }
                            }
                        } catch (EntityhubException e) {
                            log.info(String.format("Unable to follow redirect to '%s' for Entity '%s'",
                                redirect.getReference(),rep.getId()),e);
                        }
                    }
                }
                return rep;
            case FOLLOW:
                while(redirects.hasNext()){
                    Reference redirect = redirects.next();
                    if(redirect != null){
                        try {
                            Entity redirectedEntity = site != null ?
                                    site.getEntity(redirect.getReference()) :
                                        entityhub.getEntity(redirect.getReference());
                            if(redirectedEntity != null){
                                return redirectedEntity.getRepresentation();
                            }
                        } catch (EntityhubException e) {
                            log.info(String.format("Unable to follow redirect to '%s' for Entity '%s'",
                                redirect.getReference(),rep.getId()),e);
                        }
                    }
                }
                return rep; //no redirect found
            default:
View Full Code Here

        for(Iterator<String> fields = rep.getFieldNames();fields.hasNext();){
            String field = fields.next();
            Iterator<Reference> values = rep.getReferences(field);
//            assertTrue(values.hasNext());
            while(values.hasNext()){
                Reference ref = values.next();
                assertNotNull(ref);
            }
        }
    }
View Full Code Here

        Representation result = suggestion.getResult();
        Iterator<Reference> redirects = result.getReferences(config.getRedirectField());
        switch (config.getRedirectProcessingMode()) {
            case ADD_VALUES:
                while(redirects.hasNext()){
                    Reference redirect = redirects.next();
                    if(redirect != null){
                        Representation redirectedEntity = entitySearcher.get(redirect.getReference(),
                            config.getSelectedFields());
                        if(redirectedEntity != null){
                            for(Iterator<String> fields = redirectedEntity.getFieldNames();fields.hasNext();){
                                String field = fields.next();
                                result.add(field, redirectedEntity.get(field));
                            }
                        }
                        //set that the redirects where searched for this result
                        suggestion.setRedirectProcessed(true);
                    }
                }
            case FOLLOW:
                while(redirects.hasNext()){
                    Reference redirect = redirects.next();
                    if(redirect != null){
                        Representation redirectedEntity = entitySearcher.get(redirect.getReference(),
                            config.getSelectedFields());
                        if(redirectedEntity != null){
                            //copy the original result score
                            redirectedEntity.set(RdfResourceEnum.resultScore.getUri(),
                                result.get(RdfResourceEnum.resultScore.getUri()));
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.servicesapi.model.Reference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.