public String apply(Document document) { final LanguageCode language = document.getLanguage(); return language != null ? language.name() : ""; } });
public DocumentRefid apply(Document document) { return new DocumentRefid(document.getStringId()); } });
public ProcessingComponentConfiguration getComponentConfiguration() { return new ProcessingComponentConfiguration(getComponentClass(), id, getAttributes()); }
/** * Returns this document's {@link #LANGUAGE}. */ public LanguageCode getLanguage() { return getField(LANGUAGE); }
/** * Sets this document's {@link #LANGUAGE}. * * @param language the language to set * @return this document for convenience */ public Document setLanguage(LanguageCode language) { return setField(LANGUAGE, language); }
@Override protected void afterFetch(SearchEngineResponse response) { for (Document document : response.results) { document.setLanguage(LanguageCode.ENGLISH); } }
/** * Creates a {@link Cluster} with the provided <code>phrase</code> to be used as the * cluster's label and <code>documents</code> contained in the cluster. * * @param phrase the phrase to form the cluster's label * @param documents documents contained in the cluster */ public Cluster(String phrase, Document... documents) { addPhrases(phrase); addDocuments(documents); }
public Double apply(Cluster cluster) { return cluster.isOtherTopics() ? 1.0 : -1.0; } });
@Override public void recycle(IProcessingComponent component, String id) { // Dispose of the component right after it's been used. component.dispose(); }
public Integer apply(Cluster cluster) { return cluster.size(); } });
public Integer apply(Document document) { return document.getId(); } }
@Override public void recycle(IProcessingComponent component, String id) { // If not our wrapper, recycle. if (!(component instanceof CachedProcessingComponent)) { delegate.recycle(component, id); } // The wrapped actual components are recycled in ValueProducer when // they're asked to perform processing. }
/** * If there are unclustered documents, appends the "Other Topics" group to the * <code>clusters</code>. * * @see #buildOtherTopics(List, List) */ public static Cluster appendOtherTopics(List<Document> allDocuments, List<Cluster> clusters) { return appendOtherTopics(allDocuments, clusters, OTHER_TOPICS_LABEL); }
/** * Returns the user name to use for HTTP Basic Authentication. */ protected String getUser() { return HttpAuthHub.getUser(); }
public void init(IControllerContext context, Map<String, Object> attributes, ProcessingComponentConfiguration... configurations) { delegate.init(context, attributes, configurations); }
@Override public String apply(Document doc) { return doc.getStringId(); } };
/** * Creates a simple controller with no processing component pooling and no results * caching. A controller with equivalent configuration can be obtained from * {@link ControllerFactory#createSimple()}, see that method for more information. For * more controller configurations, also see {@link ControllerFactory}. * * @see ControllerFactory */ Controller() { this(new SimpleProcessingComponentManager()); }
/** * Creates a controller with a custom {@link IProcessingComponentManager}, for experts * only. Use {@link ControllerFactory} to obtain controllers in typical * configurations. */ public Controller(IProcessingComponentManager componentManager) { HttpAuthHub.setupAuthenticator(); this.componentManager = componentManager; }
/** * Returns current statistics related to the processing performed in this controller, * including: number of queries, number of successful queries, processing times, cache * utilization if applicable. */ public ControllerStatistics getStatistics() { return statistics.getStatistics(); }
public void dispose(IProcessingComponent component, String parameter) { component.dispose(); } }