Package org.apache.stanbol.entityhub.servicesapi.site

Examples of org.apache.stanbol.entityhub.servicesapi.site.Site


     */
    protected Entity importEntity(Entity remoteEntity) throws YardException{
        if(remoteEntity == null){
            return null;
        }
        Site site = siteManager.getSite(remoteEntity.getSite());
        if(site == null){
            log.warn("Unable to import Entity {} because the ReferencedSite {} is currently not active -> return null",
                remoteEntity.getId(),remoteEntity.getSite());
            return null;
        }
View Full Code Here


            // NOTE: the site is determined from the
            // fise:TextAnnotation <-- dc:relation --
            // fise:EntityAnnotation -- entityhub:ste --> "{siteName}"^^xsd:string
            // data.
            // TODO: add configuration to include/exclude Sites by name
            Site site = siteManager.getSite(savedEntity.getSite());
            Collection<String> types = null; // potential types of entities
            boolean casesensitive = false; // TODO: make configurable
            String savedEntityLabel =
                    casesensitive ? savedEntity.getName() : savedEntity.getName().toLowerCase();

            // Determine the context used for disambiguation
            // TODO: make this configurable options

            String disambiguationContext;
            // (0.a) The easiest way is to just use the selection context
            // disambiguationContext = savedEntity.getContext();
            // (0.b) Calculate a context based on a moving window
            String window =
                    getDisambiguationContext(textContent, savedEntity.getName(), savedEntity.getStart(), 100);
            log.info("Use Window: '{}' for '{}'", window, savedEntity.getName());

            // (1) The contextSelections:
            // All other selected text within the selection context
            List<String> contextSelections =
                    getSelectionsInContext(savedEntity.getName(), disData.allSelectedTexts, window);
            // savedEntity.getContext());
            disambiguationContext = unionString(false, contextSelections);

            // (2) I do not understand this variant (see comment for the
            // EntitiesInRange(..) method
            // List<String> L = EntitiesInRange(disData.directoryTextAnotation,
            // (savedEntity.getStart() + savedEntity.getEnd()) / 2);
            // disambiguationContext = unionString(false,contextSelections);

            // (3) one can build a combination of the above
            // disambiguationContext = unionString(true, //unique adds
            // Collections.singleton(savedEntity.getName()), //the selected text
            // Collections.singleton(context), //the context
            // contextSelections); //other selected parsed in the context

            // or just the name of the entity AND the context
            // disambiguationContext = unionString(false,
            // Collections.singleton(savedEntity.getName()),
            // contextSelections);

            // (4) TODO: I would also like to have the possibility to disambiguate
            // using URIs of Entities suggested for other TextAnnotations
            // within the context.

            // make the similarity query on the Entityhub using the collected
            // information
            QueryResultList<Entity> results;
            log.info(" - Query '{}' for {}@{} with context '{}'", new Object[] {site.getId(),
                    savedEntityLabel, contentLangauge, disambiguationContext});
            if (!StringUtils.isBlank(disambiguationContext)) {
                try {
                    results = query(site, savedEntityLabel, contentLangauge, disambiguationContext);
                } catch (SiteException e) {
                    // TODO we could also try to catch those errors ...
                    throw new EngineException("Unable to disambiguate Mention of '" + savedEntity.getName()
                            + "' on Entityhub Site '" + site.getId() + "!", e);
                }
                log.debug(" - {} results returned by query {}", results.size(), results.getQuery());
                // match the results with the suggestions
                disambiguateSuggestions(results, savedEntity);
            } else {
View Full Code Here

    }


   
    public void computeEnhancements(ContentItem ci) throws EngineException {
        final Site site;
        if (referencedSiteID != null) { // lookup the referenced site
            site = siteManager.getSite(referencedSiteID);
            // ensure that it is present
            if (site == null) {
                String msg = String.format(
                    "Unable to enhance %s because Referenced Site %s is currently not active!", ci.getUri()
                            .getUnicodeString(), referencedSiteID);
                log.warn(msg);
                // TODO: throwing Exceptions is currently deactivated. We need a
                // more clear
                // policy what do to in such situations
                // throw new EngineException(msg);
                return;
            }
            // and that it supports offline mode if required
            if (isOfflineMode() && !site.supportsLocalMode()) {
                log.warn(
                    "Unable to enhance ci {} because OfflineMode is not supported by ReferencedSite {}.", ci
                            .getUri().getUnicodeString(), site.getId());
                return;
            }
        } else { // null indicates to use the Entityhub to lookup Entities
            site = null;
        }
View Full Code Here

     */
    protected Entity importEntity(Entity remoteEntity) throws YardException{
        if(remoteEntity == null){
            return null;
        }
        Site site = siteManager.getSite(remoteEntity.getSite());
        if(site == null){
            log.warn("Unable to import Entity {} because the ReferencedSite {} is currently not active -> return null",
                remoteEntity.getId(),remoteEntity.getSite());
            return null;
        }
View Full Code Here

        this.siteId = siteId;
    }
   
    @Override
    public boolean supportsOfflineMode() {
        Site site = getService();
        //Do not throw an exception here if the site is not available. Just return false
        return site == null ? false : site.supportsLocalMode();
    }
View Full Code Here

            if(_siteManager == null){
                throw new IllegalStateException("Unable to lookup ReferencedSite '"
                        +siteId+"' because ReferencedSiteManager service is unavailable!");
            }
        }
        Site site = _siteManager.getSite(siteId);
        if (site == null) {
            String message = String.format("ReferencedSite '%s' not acitve!",siteId);
            log.error(message);
            throw new WebApplicationException(
                Response.status(Status.NOT_FOUND).entity(message).build());
View Full Code Here

    public Entity get(UriRef id,Set<UriRef> fields, String ... languages) {
        if(id == null || id.getUnicodeString().isEmpty()){
            return null;
        }
        org.apache.stanbol.entityhub.servicesapi.model.Entity entity;
        Site site = getSearchService();
        if(site == null){
            throw new IllegalStateException("ReferencedSite "+siteId+" is currently not available");
        }
        try {
            entity = site.getEntity(id.getUnicodeString());
        catch (SiteException e) {
            throw new IllegalStateException("Exception while getting "+id+
                " from the ReferencedSite "+site.getId(),e);
        }
        if(entity != null){
            Set<String> languageSet;
            if(languages == null || languages.length < 1){
                languageSet = null;
View Full Code Here

                                           Set<UriRef> includeFields,
                                           List<String> search,
                                           String[] languages,
                                           Integer limit, Integer offset) throws IllegalStateException {
        //build the query and than return the result
        Site site = getSearchService();
        if(site == null){
            throw new IllegalStateException("ReferencedSite "+siteId+" is currently not available");
        }
        queryStats.begin();
        FieldQuery query = EntitySearcherUtils.createFieldQuery(site.getQueryFactory(),
            field, includeFields, search, languages);
        if(limit != null && limit > 0){
            query.setLimit(limit);
        } else if(this.limit != null){
            query.setLimit(this.limit);
        }
        if(offset != null && offset.intValue() > 0){
            query.setOffset(offset.intValue());
        }
        QueryResultList<Representation> results;
        try {
            results = site.find(query);
        } catch (SiteException e) {
            throw new IllegalStateException("Exception while searchign for "+
                search+'@'+Arrays.toString(languages)+"in the ReferencedSite "+
                site.getId(), e);
        }
        queryStats.complete();
        if(!results.isEmpty()){
            Set<String> languagesSet = new HashSet<String>(Arrays.asList(languages));
            Collection<Entity> entities = new ArrayList<Entity>(results.size());
View Full Code Here

        }
    }

    @Override
    public boolean supportsOfflineMode() {
        Site site = getSearchService();
        //Do not throw an exception here if the site is not available. Just return false
        return site == null ? false : site.supportsLocalMode();
    }
View Full Code Here

    public Entity get(UriRef id,Set<UriRef> includeFields) {
        if(id == null || id.getUnicodeString().isEmpty()){
            return null;
        }
        org.apache.stanbol.entityhub.servicesapi.model.Entity entity;
        Site site = getSearchService();
        if(site == null){
            throw new IllegalStateException("ReferencedSite "+siteId+" is currently not available");
        }
        try {
            entity = site.getEntity(id.getUnicodeString());
        catch (SiteException e) {
            throw new IllegalStateException("Exception while getting "+id+
                " from the ReferencedSite "+site.getId(),e);
        }
        return entity == null ? null : new EntityhubEntity(entity.getRepresentation());
    }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.entityhub.servicesapi.site.Site

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.