Package org.apache.stanbol.enhancer.engines.entitylinking

Examples of org.apache.stanbol.enhancer.engines.entitylinking.LabelTokenizer


                            higest = null;
                        }
                        EntityLinkingEngine engine = entityLinkingEngine;
                        ServiceTracker tracker = labelTokenizerTracker;
                        if(engine != null && tracker != null){
                            LabelTokenizer lt = (LabelTokenizer)
                                    (reference.equals(higest) || higest == null ? service :
                                        tracker.getService(higest));
                            if(!lt.equals(engine.getLabelTokenizer())){
                                log.info(" ... setting LabelTokenizer of Engine '{}' to {}",
                                    engine.getName(),lt);
                                engine.setLabelTokenizer(lt);
                            }
                        }//if engine or tracker is null deactivate was already called
                    }
                    return service;
                }

                @Override
                public void removedService(ServiceReference reference, Object service) {
                    synchronized (labelTokenizersRefs) {
                        labelTokenizersRefs.remove(reference); //override
                        EntityLinkingEngine engine = entityLinkingEngine;
                        ServiceTracker tracker = labelTokenizerTracker;
                        if(engine != null && tracker != null){
                            if(labelTokenizersRefs.isEmpty()){
                                log.info(" ... setting LabelTokenizer of Engine '{}' to null",
                                    engine.getName());
                                engine.setLabelTokenizer(null);
                            } else {
                                LabelTokenizer lt = (LabelTokenizer)tracker.getService(
                                    labelTokenizersRefs.last());
                                if(!lt.equals(engine.getLabelTokenizer())){
                                    log.info(" ... setting LabelTokenizer of Engine '{}' to {}",
                                        engine.getName(),lt);
                                    engine.setLabelTokenizer(lt);
                                }
                            }
                        } //if engine or tracker is null deactivate was already called
                    }
                    bundleContext.ungetService(reference);
                }
                   
                @Override
                public void modifiedService(ServiceReference reference, Object service) {
                    synchronized (labelTokenizersRefs) {
                        labelTokenizersRefs.remove(reference); //override
                        labelTokenizersRefs.add(reference);
                        ServiceReference higest;
                        try {
                            higest = labelTokenizersRefs.last();
                        } catch (NoSuchElementException e) {
                            higest = null;
                        }
                        EntityLinkingEngine engine = entityLinkingEngine;
                        ServiceTracker tracker = labelTokenizerTracker;
                        if(engine != null && tracker != null){
                            LabelTokenizer lt = (LabelTokenizer)
                                    (reference.equals(higest) || higest == null ? service :
                                        tracker.getService(higest));
                            if(!lt.equals(engine.getLabelTokenizer())){
                                log.info(" ... setting LabelTokenizer of Engine '{}' to {}",
                                    engine.getName(),lt);
                                engine.setLabelTokenizer(lt);
                            }
                        } //if engine or tracker is null deactivate was already called
View Full Code Here


                synchronized (labelTokenizersRefs) {
                    labelTokenizersRefs.add(reference);
                    ServiceReference higest = labelTokenizersRefs.last();
                    EntityLinkingEngine engine = entityLinkingEngine;
                    if(engine != null){
                        LabelTokenizer lt = (LabelTokenizer)
                                (higest.equals(reference) ? service :
                                    labelTokenizerTracker.getService(higest));
                        if(!lt.equals(engine.getLabelTokenizer())){
                            log.info(" ... setting LabelTokenizer of Engine '{}' to {}",
                                engine.getName(),lt);
                            engine.setLabelTokenizer(lt);
                        }
                    }
                }
                return service;
            }

            @Override
            public void removedService(ServiceReference reference, Object service) {
                synchronized (labelTokenizersRefs) {
                    labelTokenizersRefs.remove(reference); //override
                    EntityLinkingEngine engine = entityLinkingEngine;
                    if(engine != null){
                        if(labelTokenizersRefs.isEmpty()){
                            log.info(" ... setting LabelTokenizer of Engine '{}' to null",
                                engine.getName());
                            engine.setLabelTokenizer(null);
                        } else {
                            LabelTokenizer lt = (LabelTokenizer)labelTokenizerTracker.getService(
                                labelTokenizersRefs.last());
                            if(!lt.equals(engine.getLabelTokenizer())){
                                log.info(" ... setting LabelTokenizer of Engine '{}' to {}",
                                    engine.getName(),lt);
                                engine.setLabelTokenizer(lt);
                            }
                        }
                    }
                }
                bundleContext.ungetService(reference);
            }
               
            @Override
            public void modifiedService(ServiceReference reference, Object service) {
                synchronized (labelTokenizersRefs) {
                    labelTokenizersRefs.remove(reference); //override
                    labelTokenizersRefs.add(reference);
                    ServiceReference higest = labelTokenizersRefs.last();
                    EntityLinkingEngine engine = entityLinkingEngine;
                    if(engine != null){
                        LabelTokenizer lt = (LabelTokenizer)
                            (higest.equals(reference) ? service :
                                labelTokenizerTracker.getService(higest));
                        if(!lt.equals(engine.getLabelTokenizer())){
                            log.info(" ... setting LabelTokenizer of Engine '{}' to {}",
                                engine.getName(),lt);
                            engine.setLabelTokenizer(lt);
                        }
                    }
View Full Code Here

     * @see org.apache.stanbol.enhancer.engines.keywordextraction.impl.LabelTokenizerManager#tokenize(java.lang.String, java.lang.String)
     */
    @Override
    public String[] tokenize(String label,String language){
        for(ServiceReference ref : getTokenizers(language)){
            LabelTokenizer tokenizer = (LabelTokenizer)labelTokenizerTracker.getService(ref);
            if(tokenizer != null){
                log.trace(" > use Tokenizer {} for language {}",tokenizer.getClass(),language);
                String[] tokens = tokenizer.tokenize(label, language);
                if(tokens != null){
                    if(log.isTraceEnabled()){
                        log.trace("   - tokenized {} -> {}",label, Arrays.toString(tokens));
                    }
                    return tokens;
View Full Code Here

TOP

Related Classes of org.apache.stanbol.enhancer.engines.entitylinking.LabelTokenizer

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.