---
name: "Biblio::Thesaurus::ModRewrite"
section: "3pm"
platform: "linux"
package: "libbiblio-thesaurus-modrewrite-perl"
version: "0.03-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Biblio::Thesaurus::ModRewrite"
---

# Biblio::Thesaurus::ModRewrite(3pm)

a module to manipulate ontologies

## NAME

Biblio::Thesaurus::ModRewrite - a module to manipulate ontologies

## VERSION

Version 0.02

## SYNOPSIS

```
  use Biblio::Thesaurus;
  use Biblio::Thesaurus::ModRewrite;
  my $code = "Lisbon 'city-of' Portugal => add (Lisbon 'city-of' Europe).";
  $thesaurus = thesaurusLoad($file);
  $obj = Biblio::Thesaurus::ModRewrite->new($thesaurus);
  $obj->process($code);
```

## DESCRIPTION

This module implements a compiler to run programs written in a domain specific language that can be used to manipulate information in ontologies. This domain specific language is called OML and is  described in the next section.

## OML

OML is a domain specific language that can be used to describe operations that manipulate information in a ontology. Programs written in OML are a set of rules that are executed in order, each rule looks something like:

```
  pattern => action .
```

Which means that when the `"pattern"` is found the given `"action"` block is executed.

### Patterns

Patterns describe information in the ontology. A pattern can be used to represent terms, relations, relations between terms, or any combination of any of these.

### Actions

The action block is used to describe the operations that are going to be executed if a given pattern is found.

## FUNCTIONS

### new

This function creates a new object and stores the source file for the thesaurus given as argument.

### process

This function processes source code written in OML. This and `"new"` should be the only functions you need to call to use this module.

### parseFile

This function parses the source code and builds a parsing tree. The parser is defined in the Biblio::Thesaurus::ModRewrite::Parser module.

### buildSemanticTree

This function calculates the solution node for every pattern in the parsing tree.

### calc\_set

This function calculates the solution for a given pattern.

### \_intersect

This function is used by `"calc_set"` and should not be called on it's own.

### \_comum

This function is used by `"calc_set"` and should not be called on it's own.

### \_union

This function is used by `"calc_set"` and should not be called on it's own.

### run\_program

This function executes every action for each rule in an OML program.

### execute

This function is used to execute an action.

## EXAMPLES

Look in the *examples* and *bin* directory for sample programs.

## AUTHOR

Nuno Carvalho, `"<smash@cpan.org>"`

J.Joao Almeida, `"<jj@di.uminho.pt>"`

Alberto Simoes, `"<albie@alfarrabio.di.uminho.pt>"`

## COPYRIGHT & LICENSE

Copyright 2008 Nuno Carvalho, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
