How to setup custom attributes for my new document source in carrot2 api?

classic Classic list List threaded Threaded
25 messages Options
12
Reply | Threaded
Open this post in threaded view
|

How to setup custom attributes for my new document source in carrot2 api?

savannah_beckett
I want to add custom attributes for my new document source in carrot2 api.  I looked at the files in stable branch in the sourceforge for attribute xml example, and I found that it does not have org.carrot2.source.boss.BossDocumentSource.xml.  But I found same xml file in the carrot2-core.jar in the carrot2-java-api.  Why?  How does carrot2-java-api's carrot2-core.jar get the file and how does it compile?  

How do I define custom attributes for new document source in api?  I am not talking about DCS anymore.
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Stanislaw Osinski
Administrator
I want to add custom attributes for my new document source in carrot2 api.  I
looked at the files in stable branch in the sourceforge for attribute xml
example, and I found that it has
org.carrot2.sound.boss.BossDocumentSource.xml.  But I cannot find same xml
file in the carrot2-core.jar in the carrot2-java-api.  Why?  How do I define
custom attributes for new document source in api?  I am not talking about
DCS anymore.

If you're invoking clustering from Java code, you don't need those XMLs -- they contain metadata required to e.g. display attribute information (title, description) in the workbench.

The way you define custom attributes is right in the document source class -- just declare a field and add annotations as in the ExampleDocumentSource (query, results, modulo, documents are all attributes). The XML files you mentioned are generated based on the annotations, but you don't need them to run clustering from your Java code.

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

savannah_beckett
yeah, I just figured out that some of the xml file were generated during compilation.
I want to create new document source because I like the ability to cache.  

In the examples, it has codes like these:
attributes.put(AttributeNames.QUERY, "war");
attributes.put(AttributeNames.RESULTS, 50);

In the case of custom attributes, how do I set them?  the custom attributes are not part of AttributeNames.  My new code doesn't compile because of these custom attributes.
Thanks.

Stanislaw Osinski wrote
>
> I want to add custom attributes for my new document source in carrot2 api.
>  I
> looked at the files in stable branch in the sourceforge for attribute xml
> example, and I found that it has
> org.carrot2.sound.boss.BossDocumentSource.xml.  But I cannot find same xml
> file in the carrot2-core.jar in the carrot2-java-api.  Why?  How do I
> define
> custom attributes for new document source in api?  I am not talking about
> DCS anymore.


If you're invoking clustering from Java code, you don't need those XMLs --
they contain metadata required to e.g. display attribute information (title,
description) in the workbench.

The way you define custom attributes is right in the document source class
-- just declare a field and add annotations as in the ExampleDocumentSource
(query, results, modulo, documents are all attributes). The XML files you
mentioned are generated based on the annotations, but you don't need them to
run clustering from your Java code.

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
Carrot2-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Stanislaw Osinski
Administrator
yeah, I just figured out that some of the xml file were generated during
compilation.
I want to create new document source because I like the ability to cache.

Good point, without a document source you wouldn't be able to cache the input documents.
 
In the examples, it has codes like these:
attributes.put(AttributeNames.QUERY, "war");
attributes.put(AttributeNames.RESULTS, 50);

In the case of custom attributes, how do I set them?  the custom attributes
are not part of AttributeNames.  My new code doesn't compile because of
these custom attributes.

Ok, here it goes: each attribute needs to have an identifier (we call it a key). AttributeNames have constants for some common attributes like query or results. If you don't declare the key explicitly in the @Attribute annotation, the key would be assumed according to the description here:

http://download.carrot2.org/stable/javadoc/org/carrot2/util/attribute/Attribute.html#key()

There is a utility method you can use to get the key of an attribute:

http://download.carrot2.org/stable/javadoc/org/carrot2/util/attribute/AttributeUtils.html#getKey(java.lang.Class,%20java.lang.String)

As this call is somehow bound to the implementation details (field name), if you prefer, you can also define a constant in your document source class:

public static final String CUSTOM_ATTRIBUTE = "key-for-custom-attribute";

@Input
@Processing
@Attribute(key = CUSTOM_ATTRIBUTE)
public int customAttribute;

and then simply:

attributes.put(YourDocumentSourceClass.CUSTOM_ATTRIBUTE)

Cheers,

S.


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

savannah_beckett
I got org.carrot2.core.ComponentInitializationException: java.lang.IllegalArgumentException  when I ran my code.  Do you know why?  Can I pass an object as a attribute?

 public void init(ServletConfig config) throws ServletException {
    try {
      this.conf = NutchConfiguration.get(config.getServletContext());
      bean = NutchBean.get(config.getServletContext(), this.conf);
    } catch (IOException e) {
      throw new ServletException(e);
    }
}
........................................
In another function in same class, I have:
    attributes.put(AttributeUtils.getKey (ContextDocumentSource.class, "attConf"), this.conf);

..............................................
In documentsource:
   @Processing
    @Input
    @Attribute
    @Internal
    public Configuration attConf;
..........................................
I got this exception when I ran my code

org.carrot2.core.ComponentInitializationException: java.lang.IllegalArgumentException: Non-primitive typed attribute org.apache.nutch.searcher.ContextDocumentSource#attConf must have the @ImplementingClasses constraint.
        sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        org.carrot2.util.ExceptionUtils.wrapAs(ExceptionUtils.java:62)
        org.carrot2.core.CachingController$ComponentInstantiationListener.objectInstantiated(CachingController.java:565)
        org.carrot2.core.CachingController$ComponentInstantiationListener.objectInstantiated(CachingController.java:485)
        org.carrot2.util.pool.SoftUnboundedPool.borrowObject(SoftUnboundedPool.java:117)
        org.carrot2.core.CachingController.borrowProcessingComponent(CachingController.java:341)
        org.carrot2.core.CachingController.access$800(CachingController.java:53)
        org.carrot2.core.CachingController$CachedProcessingComponent.prepareDescriptors(CachingController.java:702)
        org.carrot2.core.CachingController$CachedProcessingComponent.process(CachingController.java:646)
        org.carrot2.core.ControllerUtils.performProcessing(ControllerUtils.java:87)
        org.carrot2.core.ControllerUtils.performProcessing(ControllerUtils.java:130)
        org.carrot2.core.CachingController.processInternal(CachingController.java:291)
        org.carrot2.core.CachingController.process(CachingController.java:236)
        org.apache.nutch.searcher.SearchContextServlet.doGet(SearchContextServlet.java:134)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



Stanislaw Osinski wrote
>
> yeah, I just figured out that some of the xml file were generated during
> compilation.
> I want to create new document source because I like the ability to cache.


Good point, without a document source you wouldn't be able to cache the
input documents.


> In the examples, it has codes like these:
> attributes.put(AttributeNames.QUERY, "war");
> attributes.put(AttributeNames.RESULTS, 50);
>
> In the case of custom attributes, how do I set them?  the custom attributes
> are not part of AttributeNames.  My new code doesn't compile because of
> these custom attributes.


Ok, here it goes: each attribute needs to have an identifier (we call it a
key). AttributeNames have constants for some common attributes like query or
results. If you don't declare the key explicitly in the @Attribute
annotation, the key would be assumed according to the description here:

http://download.carrot2.org/stable/javadoc/org/carrot2/util/attribute/Attribute.html#key()

There is a utility method you can use to get the key of an attribute:

http://download.carrot2.org/stable/javadoc/org/carrot2/util/attribute/AttributeUtils.html#getKey(java.lang.Class,%20java.lang.String)

As this call is somehow bound to the implementation details (field name), if
you prefer, you can also define a constant in your document source class:

public static final String CUSTOM_ATTRIBUTE = "key-for-custom-attribute";

@Input
@Processing
@Attribute(key = CUSTOM_ATTRIBUTE)
public int customAttribute;

and then simply:

attributes.put(YourDocumentSourceClass.CUSTOM_ATTRIBUTE)

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
Carrot2-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Stanislaw Osinski
Administrator
> I got org.carrot2.core.ComponentInitializationException:
> java.lang.IllegalArgumentException  when I ran my code.  Do you know why?
> Can I pass an object as a attribute?

Absolutely. This is the bit I forgot to put in the document source
example -- for attributes of non-primitive types, you need to add
@ImplementingClasses annotation that lists the allowed types of values
to be assigned:

http://download.carrot2.org/stable/javadoc/org/carrot2/util/attribute/constraint/ImplementingClasses.html

There is an attribute of that annotation (strict = false) that will
allow any assignable value. If you don't know in advance the exact
types of values that attConf will get, add this annotation to your
attConf attribute:

@ImplementingClasses(classes = {}, strict = false)

I've added an example non-primitive field to DocumentSourceExample (in
trunk) as well.

On a more general note, Dawid -- maybe specifying the
@ImplementingClasses constraint shouldn't be obligatory? It's useful
for Workbench as a list of values to display in the combo box, but
I've seen most of the instances declaring strict = false anyway. If
@Implementing classes is not specified or has empty classes array,
Workbench could simply show a plain text field where the user could
type any class name.

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Dawid Weiss-2

> On a more general note, Dawid -- maybe specifying the
> @ImplementingClasses constraint shouldn't be obligatory? It's useful
> for Workbench as a list of values to display in the combo box, but
> I've seen most of the instances declaring strict = false anyway. If
> @Implementing classes is not specified or has empty classes array,

strict could have false as the default value...

> Workbench could simply show a plain text field where the user could
> type any class name.

-1. The GUI should have sensible defaults, I don't see the point of being able
to type in the class name if you don't know which class loader is going to be
used to load it, where the class actually lives, where it could possible be
added, etc... If an attribute can be used from the GUI (by regular users), it
should provide defaults.

D.



------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Stanislaw Osinski
Administrator
>> On a more general note, Dawid -- maybe specifying the
>> @ImplementingClasses constraint shouldn't be obligatory? It's useful
>> for Workbench as a list of values to display in the combo box, but
>> I've seen most of the instances declaring strict = false anyway. If
>> @Implementing classes is not specified or has empty classes array,
>
> strict could have false as the default value...

But that doesn't change much, you'd still need to add the annotation,
possibly with empty classes array...

>> Workbench could simply show a plain text field where the user could
>> type any class name.
>
> -1. The GUI should have sensible defaults, I don't see the point of being
> able
> to type in the class name if you don't know which class loader is going to
> be
> used to load it, where the class actually lives, where it could possible be
> added, etc... If an attribute can be used from the GUI (by regular users),
> it
> should provide defaults.

True. The problem is that this specific UI requirement has impact on
code that may never run in the UI context (creates the need to declare
dummy @ImplementingClasses constraints). So maybe the editor should
ignore / display as read only those attributes that don't declare
@ImplementingClasses?

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Dawid Weiss-2

> But that doesn't change much, you'd still need to add the annotation,
> possibly with empty classes array...

Ok, I see your point. In case of missing @ImplementingClasses annotation, the
implicit constraint would be equivalent to @ImplementingClasses = { ? extends
<fieldType> , strict = false }?

> code that may never run in the UI context (creates the need to declare
> dummy @ImplementingClasses constraints). So maybe the editor should
> ignore / display as read only those attributes that don't declare
> @ImplementingClasses?

I believe if there is no @ImplementingClasses associated with a field, it should
be ignore in the GUI.

Dawid

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Stanislaw Osinski
Administrator
> But that doesn't change much, you'd still need to add the annotation,
> possibly with empty classes array...

Ok, I see your point. In case of missing @ImplementingClasses annotation, the
implicit constraint would be equivalent to @ImplementingClasses = { ? extends
<fieldType> , strict = false }?

Exactly and this is enforced when binding values (you can't assign a non-assignable value). Therefore, @ImplementingClasses can be optional on the core level.
 
> code that may never run in the UI context (creates the need to declare
> dummy @ImplementingClasses constraints). So maybe the editor should
> ignore / display as read only those attributes that don't declare
> @ImplementingClasses?

I believe if there is no @ImplementingClasses associated with a field, it should
be ignore in the GUI.
 
Ok, in that case, I'll make the @ImplementingClasses optional, all our core components have them anyway so Workbench should be fine.

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

savannah_beckett
I added that  @ImplementingClasses line to my code and I got another exception, it has something to do with a hack to reset that attribute when I read the carrot2 code.

org.carrot2.core.ProcessingException: Could not reset attribute values
        org.carrot2.core.CachingController$ComponentResetListener.passivate(CachingController.java:565)
        org.carrot2.core.CachingController$ComponentResetListener.passivate(CachingController.java:523)
        org.carrot2.util.pool.SoftUnboundedPool.returnObject(SoftUnboundedPool.java:156)
        org.carrot2.core.CachingController$CachedProcessingComponent.prepareDescriptors(CachingController.java:669)
        org.carrot2.core.CachingController$CachedProcessingComponent.process(CachingController.java:598)
        org.carrot2.core.ControllerUtils.performProcessing(ControllerUtils.java:92)
        org.carrot2.core.ControllerUtils.performProcessing(ControllerUtils.java:135)
        org.carrot2.core.CachingController.processInternal(CachingController.java:279)
        org.carrot2.core.CachingController.process(CachingController.java:224)
        org.apache.nutch.searcher.SearchContextServlet.doGet(SearchContextServlet.java:134)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Stanislaw Osinski wrote
>
> > But that doesn't change much, you'd still need to add the annotation,
> > possibly with empty classes array...
>
> Ok, I see your point. In case of missing @ImplementingClasses annotation,
> the
> implicit constraint would be equivalent to @ImplementingClasses = { ?
> extends
> <fieldType> , strict = false }?


Exactly and this is enforced when binding values (you can't assign a
non-assignable value). Therefore, @ImplementingClasses can be optional on
the core level.


> > code that may never run in the UI context (creates the need to declare
> > dummy @ImplementingClasses constraints). So maybe the editor should
> > ignore / display as read only those attributes that don't declare
> > @ImplementingClasses?
>
> I believe if there is no @ImplementingClasses associated with a field, it
> should
> be ignore in the GUI.


Ok, in that case, I'll make the @ImplementingClasses optional, all our core
components have them anyway so Workbench should be fine.

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
Carrot2-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Stanislaw Osinski
Administrator
I added that  @ImplementingClasses line to my code and I got another
exception, it has something to do with a hack to reset that attribute when I
read the carrot2 code.

Which version of Carrot2 are you using? In v3.0.1 we've refactored the code a bit to get rid of these kinds of problems:

http://download.carrot2.org/stable/carrot2-java-api-3.0.1.zip

Also, if the configuration attribute is read once per component instance (ie. it doesn't need to change between requests) you could make it an @Init attribute instead of a @Processing attribute:

@Init
@Processing
@Attribute
@ImplementingClasses(...)

read it in the init() method (it will have been bound at that time already) and configure your document source based on the attribute.

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

savannah_beckett
I tried both versions, I got same exception.  

I removed @Processing and added @Init, I got same exception.

I don't understand what you meant when you said "read it in the init() method (it will have been bound at that time already) and configure your document source based on the attribute.".

my code is:
    attributes.put(AttributeUtils.getKey (ContextDocumentSource.class, "attConf"), this.conf);
    controller.init (attributes);
    ProcessingResult result = controller.process(attributes, ContextDocumentSource.class, LingoClusteringAlgorithm.class);


Stanislaw Osinski wrote
>
> I added that  @ImplementingClasses line to my code and I got another
> exception, it has something to do with a hack to reset that attribute when
> I
> read the carrot2 code.


Which version of Carrot2 are you using? In v3.0.1 we've refactored the code
a bit to get rid of these kinds of problems:

http://download.carrot2.org/stable/carrot2-java-api-3.0.1.zip

Also, if the configuration attribute is read once per component instance
(ie. it doesn't need to change between requests) you could make it an @Init
attribute instead of a @Processing attribute:

@Init
@Processing
@Attribute
@ImplementingClasses(...)

read it in the init() method (it will have been bound at that time already)
and configure your document source based on the attribute.

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
Carrot2-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Stanislaw Osinski
Administrator
I tried both versions, I got same exception.

I removed @Processing and added @Init, I got same exception.

Strange... Can you share some larger chunk of code so that I can debug the problem locally?

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

savannah_beckett
I reexamined all my attributes and fiddle with all those @flags, and now I don't get the exception anymore.  I think the exception may be caused by an @internal that's not supposed to be in a non-primitive attribute.

Is ProcessingResult.serialize the only way to translate the clustering result to xml?  Serialization hurts performance.  I am writing a servlet, and it should send the clustering xml back to the requester, I don't want to save it into a file.  What's the best way to do it?
Thanks.

Stanislaw Osinski wrote
>
> I tried both versions, I got same exception.
>
> I removed @Processing and added @Init, I got same exception.


Strange... Can you share some larger chunk of code so that I can debug the
problem locally?

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
Carrot2-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Stanislaw Osinski
Administrator
I reexamined all my attributes and fiddle with all those @flags, and now I
don't get the exception anymore.  I think the exception may be caused by an
@internal that's not supposed to be in a non-primitive attribute.

In fact, @Internal can be applied to any type, so it shouldn't break things... The aim of @Internal is to mark those attributes which you may want to give some special handling:

http://download.carrot2.org/head/javadoc/org/carrot2/core/attribute/Internal.html

E.g. Workbench does not display @Internal attributes with configuration = false, while the webapp does not allow to set any @Internal attributes to prevent e.g. sniffing over the server's file system (e.g. Lucene index path is an @Internal(configuration = true) attribute -- Workbench will display it, but the webapp won't allow to set it from the request parameters).
 
Is ProcessingResult.serialize the only way to translate the clustering
result to xml?  Serialization hurts performance.  I am writing a servlet,
and it should send the clustering xml back to the requester.  What's the
best way to do it?

Well, you can first try ProcessingResult.serialize() and if you find the performance unsatisfactory, you can always try to write some custom code. In reality, serialization cost will be negligible compared to clusteirng time, so in most cases it's not going to be an issue.

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

savannah_beckett
Thanks.  I got my code working now.  Is it possible to turn off attributes in the clustering result in xml, just like turning off document or cluster?

Stanislaw Osinski wrote
>
> I reexamined all my attributes and fiddle with all those @flags, and now I
> don't get the exception anymore.  I think the exception may be caused by an
> @internal that's not supposed to be in a non-primitive attribute.


In fact, @Internal can be applied to any type, so it shouldn't break
things... The aim of @Internal is to mark those attributes which you may
want to give some special handling:

http://download.carrot2.org/head/javadoc/org/carrot2/core/attribute/Internal.html

E.g. Workbench does not display @Internal attributes with configuration =
false, while the webapp does not allow to set any @Internal attributes to
prevent e.g. sniffing over the server's file system (e.g. Lucene index path
is an @Internal(configuration = true) attribute -- Workbench will display
it, but the webapp won't allow to set it from the request parameters).


> Is ProcessingResult.serialize the only way to translate the clustering
> result to xml?  Serialization hurts performance.  I am writing a servlet,
> and it should send the clustering xml back to the requester.  What's the
> best way to do it?


Well, you can first try ProcessingResult.serialize() and if you find the
performance unsatisfactory, you can always try to write some custom code. In
reality, serialization cost will be negligible compared to clusteirng time,
so in most cases it's not going to be an issue.

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
Carrot2-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Stanislaw Osinski
Administrator
Thanks.  I got my code working now.  Is it possible to turn off attributes in
the clustering result in xml, just like turning off document or cluster?

Not at the moment, I'll try to get such an option into trunk:

http://issues.carrot2.org/browse/CARROT-483

You can set yourself as a watcher on this issue to get some notification when it's resolved.

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

savannah_beckett
the groups in the xml don't seem to rank by score.  What do u rank groups by in xml?  
Are the sites in the overall list ranked by score?  And the sites ranked by score inside each group?
Thanks.

Stanislaw Osinski wrote
>
> Thanks.  I got my code working now.  Is it possible to turn off attributes
> in
> the clustering result in xml, just like turning off document or cluster?


Not at the moment, I'll try to get such an option into trunk:

http://issues.carrot2.org/browse/CARROT-483

You can set yourself as a watcher on this issue to get some notification
when it's resolved.

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
Carrot2-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
Reply | Threaded
Open this post in threaded view
|

Re: How to setup custom attributes for my new document source in carrot2 api?

Stanislaw Osinski
Administrator
the groups in the xml don't seem to rank by score.  What do u rank groups by
in xml?

In fact, the order in XML depends on the sorting produced by the clustering algorithm. For Lingo this is determined by the following attribute:

http://download.carrot2.org/head/manual/#section.attribute.LingoClusteringAlgorithm.scoreWeight

Set to 1.0 to get clusters sorted purely by score.
 
Are the sites in the overall list ranked by score?  

Sites are ordered in the same way as they were ordered on the input.
 
And the sites ranked by
score inside each group?

Same thing here, documents in clusters are ordered in the same way they were ordered on the input. Currently, we don't use the SCORE attribute of individual documents.

Cheers,

S.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Carrot2-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/carrot2-developers
12