|
Carrot2 Framework
API Specification |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.carrot2.apiexample.Example
public final class Example
This is an example of using the Carrot2 API and components
directly from a Java application. The walk-through starts
in the main(String[]) method (command-line application's
entry point).
| Constructor Summary | |
|---|---|
Example()
|
|
| Method Summary | |
|---|---|
(package private) static void |
displayResults(ArrayOutputComponent.Result result)
In this method we display documents and clusters received from an output component of type ArrayOutputComponent.Result. |
static void |
main(String[] args)
Carrot2 API example |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Example()
| Method Detail |
|---|
public static void main(String[] args)
Carrot2 is composed of components bound together in a processing chain. To start clustering search results we will need at least three components:
RawCluster. The role of an output component is to do something
with clusters once you receive them from the clusterer. The easiest
way is to save them in an array and wait until all the processing is
finished (all the clusters are available). A more advanced application
could use (display?) clusters as soon as they appear from the clustering
component. In this example we will buffer the output clusters in
an array.
The next step after deciding which components to use is to
create an instance of a LocalController which provides
the facility for executing queries and assembling a fully
functional processing chain. This is explained in initLocalController()
method.
Once you have a fully configured LocalController, running
queries is quite trivial. The only thing you need to do is to invoke
LocalController.query(String, String, java.util.Map) method,
passing it a process identifier, a query and a Map of
request parameters. These parameters can be used by certain components
to alter their behaviour or settings for the duration of a single
query. Each component will expose a different set of parameters,
so you'll need to take a look at source code to see what is available.
Note that an instance of a LocalController is thread-safe
and may (should!) be reused.
The result of running a query is an instance of a ProcessingResult
interface. The actual output depends a lot on the last (output) component
in the chain, so you'll need to see what is available. In our case, the
result is a buffered array of snippets and clusters of type
ArrayOutputComponent.Result. We can display
documents (snippets) and clusters by fetching data from this
object. This procedure is shown in
displayResults(ArrayOutputComponent.Result) method.
LocalController.
args - Command line arguments are not used in this application.static void displayResults(ArrayOutputComponent.Result result)
In this method we display documents and clusters received from
an output component of type ArrayOutputComponent.Result.
|
Please refer to project documentation at
http://project.carrot2.org |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||