Developing Components

Developing Own DL-Learner Components

In order to write your own component, you need to implement the appropriate interface, e.g. for writing a learning algorithm, you need to implement the “Learning Algorithm” interface. You can find the list of components here.

Example Learning Algorithm

To give an overview of the main building blocks of a learning algorithm implementation we added the naive AL learner which builds simple AL concepts up to a certain length and returns the concept that best matches the given learning problem. AL only allows the following elements:

To build the learning algorithm the following methods need to be implemented

  • init()
  • start()
  • stop()
  • isRunning()
  • getCurrentlyBestDescription()/getCurrentlyBestEvaluatedDescription()

Whereas the init() method is used for simple initialization tasks, the main work is done in start(). Here we construct all possible AL concept descriptions based on the considered concept length according to the following building plan:

length concepts to add
1
  • top (owl:Thing)
  • bottom (owl:Nothing)
  • all atomic concepts
2
  • negations of all atomic concepts
3
  • limited existential quantification of all roles
  • value restrictions of all roles with all atomic concepts as role fillers
  • concept intersections with all atomic concepts
> 3
  • value restrictions of all roles with concepts of length-2 as role fillers
  • concept intersections of concepts of length-1 and atomic concepts

Afterwards we exhaustively evaluate the generated concepts storing the best score which can then be retrieved by a call of the getCurrentlyBestDescription() or getCurrentlyBestEvaluatedDescription() method, respectively. Finally the stop() method can do some clean up. In our example only the boolean variable running is set to False, which is used by the isRunning() method to indicate whether the algorithm is running.

This example learning algorithm can be run setting the configuration option alg.type = "naiveALLearner". A complete configuration file can be found here.

Example Refinement Operator Component

(Background: scientific article on refinement operators in DL-Learner)
The source code for an extremely simple refinement operator, which takes a description and returns nothing, can be found here.
To use it in a configuration file, for instance the father toy example, you need to specify the class in which your new operator is implemented:


operator.type = "org.dllearner.refinementoperators.ExampleOperator"
alg.type = "celoe"
alg.operator = operator

Everything else is the same as in the example linked above.

You need to make sure that Java can actually find your class, i.e. it needs to be in your classpath.

Shortcuts in Conf Files

In the above example, you had to specify the full class name in conf files. You can use annotations to avoid this:

@Component Ann(name = "example refinement operator", shortName = "exop", version = 0.1)

In addition, the class has to be added to AnnComponentManager (if you are a DL-Learner developer) or you need to call AnnComponentManager.setComponentClassNames(...) with all components which are relevant for you (if you are an external developer).

After that, you use operator.type = "example refinement operator" or operator.type = "exop" in your conf file.