Package org.carrot2.util.resource

Examples of org.carrot2.util.resource.ResourceLookup


        final Controller ctrl1 = ControllerFactory.createPooling();
        final ILexicalData data1;
        {
            ctrl1.init(ImmutableMap.<String, Object> of(
                resourceLookupKey,
                new ResourceLookup(new DirLocator(tempDir1), classpathLocator)));

            final ProcessingResult result = ctrl1.process(
                Collections.<String, Object> emptyMap(), TestComponent.class);

            data1 = result.getAttribute("english");
            assertTrue(data1.isCommonWord(new MutableCharArray("uniquea")));
        }

        // Create another pooling controller, same folder, but different resource lookup.
        final Controller ctrl2 = ControllerFactory.createPooling();
        final ILexicalData data2;
        {
            ctrl2.init(ImmutableMap.<String, Object> of(
                resourceLookupKey,
                new ResourceLookup(new DirLocator(tempDir1), classpathLocator)));

            final ProcessingResult result = ctrl2.process(
                Collections.<String, Object> emptyMap(), TestComponent.class);

            data2 = result.getAttribute("english");
View Full Code Here


        // Create pooling controller, use tempDir1
        final Controller ctrl1 = ControllerFactory.createPooling();
        {
            ctrl1.init(ImmutableMap.<String, Object> of(
                resourceLookupKey,
                new ResourceLookup(new DirLocator(tempDir1.getPath()), classpathLocator),
                resourceReloadKey,
                true));
   
            final ProcessingResult result = ctrl1.process(
                Collections.<String, Object> emptyMap(), TestComponent.class);
            final ILexicalData data = result.getAttribute("english");

            assertTrue(data.isCommonWord(new MutableCharArray("uniquea")));
            assertFalse(data.isCommonWord(new MutableCharArray("uniqueb")));
        }

        // Create pooling controller, use tempDir2
        final Controller ctrl2 = ControllerFactory.createPooling();
        {
            ctrl2.init(ImmutableMap.<String, Object> of(resourceLookupKey,
                new ResourceLookup(new DirLocator(tempDir2.getPath()), classpathLocator)));
   
            final ProcessingResult result = ctrl2.process(
                Collections.<String, Object> emptyMap(), TestComponent.class);
            final ILexicalData data = result.getAttribute("english");
View Full Code Here

public class ComponentSuitesTest extends CarrotTestCase
{
    @Test
    public void testNullValues_Carrot973() throws Exception
    {
        ResourceLookup resourceLookup = new ResourceLookup(new ClassLocator(getClass()));

        IResource resource = resourceLookup.getFirst("suite-nullvalues.xml");
        assertThat(resource).isNotNull();
        ProcessingComponentSuite suite =
            ProcessingComponentSuite.deserialize(resource, resourceLookup);

        // Must not throw an exception.
View Full Code Here

    @Test
    public void testCarrot2DefaultComponentSuite() throws Exception
    {
        // Default suites should be reachable via context class loader.
        ResourceLookup resourceLookup = new ResourceLookup(
            new ContextClassLoaderLocator());

        checkSuite("suite-dcs.xml", resourceLookup);
        checkSuite("suite-doc.xml", resourceLookup);
        checkSuite("suite-workbench.xml", resourceLookup);
View Full Code Here

    @Test
    public void testIncludes() throws Exception
    {
        // Test suite should be reachable via this class's class loader.
        ResourceLookup resourceLookup = new ResourceLookup(
            new ClassLocator(this.getClass()));

        IResource resource = resourceLookup.getFirst("suite-including.xml");
        assertThat(resource).isNotNull();
        ProcessingComponentSuite suite = ProcessingComponentSuite.deserialize(resource,
            resourceLookup);

        assertThat(suite).isNotNull();
View Full Code Here

    private void onCommit(Map<Object, Object> session)
    {
        this.initializationException = null;
        try
        {
            ResourceLookup resourceLookup = PersisterHelpers.getResourceLookup(session);
            loadAttributeSets(resourceLookup);
            bindableDescriptor =
                BindableDescriptorBuilder.buildDescriptor(newInitializedInstance());
        }
        catch (Throwable e)
View Full Code Here

     * Private constructor. Reads the available algorithms from the component suite.
     */
    private BatchApp() throws Exception
    {
        final File suitesDir = new File("suites");
        ResourceLookup suiteLookup = new ResourceLookup(
            new DirLocator(suitesDir));

        IResource suite = suiteLookup.getFirst("suite-batch.xml");
        if (suite == null)
            throw new RuntimeException(
                "Could not find suite-batch.xml in "
                    + suitesDir.getAbsolutePath());

View Full Code Here

    private int process() throws Exception
    {
        final Controller controller = ControllerFactory.createPooling();
        final Map<String, Object> initAttributes = ImmutableMap.<String, Object> of(
            AttributeUtils.getKey(DefaultLexicalDataFactory.class, "resourceLookup"),
            new ResourceLookup(new DirLocator("resources")));

        controller.init(
            initAttributes,
            componentSuite.getComponentConfigurations());       
View Full Code Here

        if (algorithms == null) algorithms = newArrayList();
        if (includes == null) includes = newArrayList();
        if (otherComponents == null) otherComponents = newArrayList();

        // Acquire contextual resource lookup from the session.
        final ResourceLookup resourceLookup = PersisterHelpers.getResourceLookup(session);

        // Load included suites. Currently, we don't check for cycles.
        final List<ProcessingComponentSuite> suites = Lists.newArrayList();

        for (ProcessingComponentSuiteInclude include : includes)
        {
            final IResource resource = resourceLookup.getFirst(include.suite);
            if (resource == null)
            {
                throw new Exception("Could not locate resource: " + include.suite);
            }
            suites.add(deserialize(resource, resourceLookup));
View Full Code Here

            } else {
                resourcesDir = new File(environment.configFile(), resourcesPath);
            }
            logger.info("Resources dir: {}", resourcesDir.getAbsolutePath());

            final ResourceLookup resourceLookup = new ResourceLookup(
                    new DirLocator(resourcesDir),
                    new ClassLoaderLocator(ControllerSingleton.class.getClassLoader()));

            // Parse suite's descriptors with loggers turned off (shut them up a bit).
            final String suiteResourceName = c2Settings.get(
                    DEFAULT_SUITE_PROPERTY_NAME,
                    DEFAULT_SUITE_RESOURCE);
            final IResource suiteResource = resourceLookup.getFirst(suiteResourceName);
            if (suiteResource == null) {
                throw new ElasticsearchException(
                        "Could not find algorithm suite: " + suiteResourceName);
            }
View Full Code Here

TOP

Related Classes of org.carrot2.util.resource.ResourceLookup

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.