Skip to content

Commit

Permalink
Merge branch 'release/4.6.1'
Browse files Browse the repository at this point in the history
remiceres committed Dec 12, 2024
2 parents e6f675f + 071bb5e commit 3792877
Showing 102 changed files with 3,287 additions and 3,968 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/release-github.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Publish GitHub Release

on:
workflow_dispatch:
inputs:
ref:
description: 'Tag to run workflow on'
required: true
push:
tags:
- "v*.*.*"
@@ -14,6 +19,8 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref_name }}

- name: Set up JDK 11
uses: actions/setup-java@v4
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Corese Changelog

## Version 4.6.1 – 2024-12-12

### Added

- Code cleanup and refactoring to improve readability and maintainability.
- Reworking of the Property class as a proper singleton.
- HTTPHeaders class created to centralize repeated definitions of HTTP headers.
- Elasticsearch's integration.
- EdgeChangeListener class created to listen to edge changes and deletion.
- Add SLF4J dependency to the project.

### Fixed

- Fixed possibility of apparition of XML comment into JSON results.
- Fixed missing SLF4J dependency.

### Changed

- Cleaned documentation website.

## Version 4.6.0 – 2024-10-28

### Added
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ Add this dependency to your `pom.xml` file:
<dependency>
<groupId>fr.inria.corese</groupId>
<artifactId>corese-core</artifactId>
<version>4.6.0</version>
<version>4.6.1</version>
</dependency>
```

@@ -36,7 +36,7 @@ Add this dependency to your `pom.xml` file:
Include the following in your `build.gradle` file:

``` gradle
implementation 'fr.inria.corese:corese-core:4.6.0'
implementation 'fr.inria.corese:corese-core:4.6.1'
```

**JAR:**
@@ -45,10 +45,7 @@ You can download the latest version of the **Corese-Core** JAR from the [release

## Documentation

Explore the available documentation to help you get started with Corese-Core:

- [Getting Started Guide](https://corese-stack.github.io/corese-core/v4.6.0/getting_started/getting_started_with_corese-core.html)
- [API Documentation](https://corese-stack.github.io/corese-core/v4.6.0/java_api/library_root.html)
Explore the available documentation on Corese-Core pages: [Corese-Core Documentation](https://corese-stack.github.io/corese-core/).

## Contributions and Community

@@ -60,6 +57,5 @@ We value contributions and feedback from the community! Here’s how you can eng

## Useful Links

- [Corese Official Website](https://corese-stack.github.io/corese-core/v4.6.0/)
- **Mailing List:** <[email protected]>
- **Join the Mailing List:** Send an email to <[email protected]> with the subject: `subscribe`
44 changes: 31 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ plugins {

// Tooling plugins
`jacoco` // For code coverage reports
id("org.gradlex.extra-java-module-info") version "1.8" // Module metadata for JARs without module info
id("com.github.johnrengelman.shadow") version "8.1.1" // Bundles dependencies into a single JAR
id("org.gradlex.extra-java-module-info") version "1.9" // Module metadata for JARs without module info
id("com.gradleup.shadow") version "8.3.5" // Bundles dependencies into a single JAR
}

/////////////////////////
@@ -21,7 +21,7 @@ object Meta {
// Project coordinates
const val groupId = "fr.inria.corese"
const val artifactId = "corese-core"
const val version = "4.6.0"
const val version = "4.6.1"

// Project description
const val desc = "Corese is a Semantic Web Factory (triple store and SPARQL endpoint) implementing RDF, RDFS, SPARQL 1.1 Query and Update, Shacl. STTL. LDScript."
@@ -74,18 +74,23 @@ dependencies {
implementation("fr.inria.corese.org.semarglproject:semargl-core:${semargl_version}") // Semargl core for RDF parsing and transformation
implementation("com.github.jsonld-java:jsonld-java:0.13.4") // JSON-LD processing for Linked Data in JSON format
implementation("junit:junit:4.13.2") // JUnit framework for unit testing in Java
api("org.slf4j:slf4j-api:2.0.9") // Simple Logging Facade for Java (SLF4J)
}

// Configure extra Java module information for dependencies without module-info
extraJavaModuleInfo {
// If a library is missing module info, the build process will not fail.
failOnMissingModuleInfo.set(false)
automaticModule("fr.com.hp.hpl.jena.rdf.arp:arp", "arp")
automaticModule("com.github.jsonld-java:jsonld-java", "jsonld.java")
automaticModule("commons-lang:commons-lang", "commons.lang")

// Map automatic module names for non-modular libraries.
automaticModule("fr.com.hp.hpl.jena.rdf.arp:arp", "arp") // Module for Jena RDF ARP
automaticModule("com.github.jsonld-java:jsonld-java", "jsonld.java") // Module for JSON-LD Java
automaticModule("commons-lang:commons-lang", "commons.lang") // Module for Commons Lang
automaticModule("fr.inria.lille.shexjava:shexjava-core", "shexjava.core")
automaticModule("org.eclipse.rdf4j:rdf4j-model", "rdf4j.model")
}


/////////////////////////
// Publishing settings //
/////////////////////////
@@ -171,8 +176,8 @@ publishing {
// Configure artifact signing
signing {
// Retrieve the GPG signing key and passphrase from environment variables for secure access.
val signingKey = providers.environmentVariable("GPG_SIGNING_KEY").forUseAtConfigurationTime()
val signingPassphrase = providers.environmentVariable("GPG_SIGNING_PASSPHRASE").forUseAtConfigurationTime()
val signingKey = providers.environmentVariable("GPG_SIGNING_KEY")
val signingPassphrase = providers.environmentVariable("GPG_SIGNING_PASSPHRASE")

// Sign the publications if the GPG signing key and passphrase are available.
if (signingKey.isPresent && signingPassphrase.isPresent) {
@@ -187,9 +192,9 @@ nexusPublishing {
// Configure Sonatype OSSRH repository for publishing.
sonatype {
// Retrieve Sonatype OSSRH credentials from environment variables.
val ossrhUsername = providers.environmentVariable("OSSRH_USERNAME").forUseAtConfigurationTime()
val ossrhPassword = providers.environmentVariable("OSSRH_PASSWORD").forUseAtConfigurationTime()
val ossrhUsername = providers.environmentVariable("OSSRH_USERNAME")
val ossrhPassword = providers.environmentVariable("OSSRH_PASSWORD")

// Set the credentials for Sonatype OSSRH if they are available.
if (ossrhUsername.isPresent && ossrhPassword.isPresent) {
username.set(ossrhUsername.get())
@@ -206,10 +211,10 @@ nexusPublishing {
// Task configuration //
/////////////////////////


// Set UTF-8 encoding for Java compilation tasks
tasks.withType<JavaCompile>() {
options.encoding = "UTF-8"
options.compilerArgs.add("-Xlint:none")
}

// Configure Javadoc tasks with UTF-8 encoding and disable failure on error.
@@ -225,6 +230,15 @@ tasks.withType<Javadoc>() {
tasks {
shadowJar {
this.archiveClassifier = "jar-with-dependencies"
}
}

// Configure Javadoc tasks to disable doclint warnings.
tasks {
javadoc {
options {
(this as CoreJavadocOptions).addBooleanOption("Xdoclint:none", true)
}
}
}

@@ -248,6 +262,10 @@ tasks.jacocoTestReport {
// Set the test task to be followed by Jacoco report generation.
// This ensures that test coverage reports are always generated after tests.
tasks.test {
// testLogging {
// events("passed", "skipped", "failed") // Affiche les résultats des tests
// showStandardStreams = true // Affiche les sorties console des tests
// }
finalizedBy(tasks.jacocoTestReport)
}

@@ -261,4 +279,4 @@ tasks.withType<PublishToMavenLocal>().configureEach {
// This guarantees that artifacts are signed before they are published to Maven repositories.
tasks.withType<PublishToMavenRepository>().configureEach {
dependsOn(tasks.withType<Sign>())
}
}
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ To this end a script must be executed and write the output to the output html di

```shell
./docs/switcher_generator.sh build/html/switcher.json build/html/index.html
./docs/switcher_generator.sh docs/source/_static/switcher.json build/html/index.html
```

Both sphinx-multiversion and switcher_generator work on tags following the ```^v[0-9]+\.[0-9]+\.[0-9]+$``` syntax and ordered by refname.
153 changes: 0 additions & 153 deletions docs/source/_static/Corese-square-logo-transparent.svg

This file was deleted.

166 changes: 0 additions & 166 deletions docs/source/_static/Corese-square-logo-white-background.svg

This file was deleted.

200 changes: 0 additions & 200 deletions docs/source/_static/corese.svg

This file was deleted.

198 changes: 198 additions & 0 deletions docs/source/_static/logo/badge_github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
274 changes: 274 additions & 0 deletions docs/source/_static/logo/badge_maven.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
144 changes: 144 additions & 0 deletions docs/source/_static/logo/corese-core_doc_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions docs/source/_static/logo/corese-core_doc_fav.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
144 changes: 144 additions & 0 deletions docs/source/_static/logo/corese-core_doc_light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 20 additions & 13 deletions docs/source/_static/switcher.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
[
{
"Name": "v5.0.0 (latest)",
"version": "stable",
"url": "https://corese-stack.github.io/corese-core/v5.0.0/",
"preferred": true
},
{
"name": "v4.5.6 (stable)",
"version": "stable",
"url": "https://corese-stack.github.io/corese-core/v4.5.6/"
}
]
[
{
"name": "v4.6.1 (latest)",
"version": "stable",
"url": "https://corese-stack.github.io/corese-core/v4.6.1/",
"preferred": true
},
{
"name": "v4.6.0 (stable)",
"version": "stable",
"url": "https://corese-stack.github.io/corese-core/v4.6.0/",
"preferred": false
},
{
"name": "dev",
"version": "unstable",
"url": "https://corese-stack.github.io/corese-core/dev/",
"preferred": false
}
]
76 changes: 0 additions & 76 deletions docs/source/apis.rst

This file was deleted.

16 changes: 8 additions & 8 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -64,31 +64,31 @@
html_js_files = []

# Project logo, to place at the top of the sidebar.
html_logo = "_static/corese.svg"
html_logo = "_static/logo/corese-core_doc_light.svg"

# Icon to put in the browser tab.
html_favicon = "_static/Corese-square-logo-transparent.svg"
html_favicon = "_static/logo/corese-core_doc_fav.svg"

# Modify the title to get good social-media links
html_title = "CORESE"
html_short_title = "CORESE"
html_title = "Corese"
html_short_title = "Corese"

# -- Theme Options -----------------------------------------------------------
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"logo": {
"image_relative": "_static/corese.svg",
"image_light": "_static/corese.svg",
"image_dark": "_static/corese.svg"
"image_relative": "_static/logo/corese-core_doc_light.svg",
"image_light": "_static/logo/corese-core_doc_light.svg",
"image_dark": "_static/logo/corese-core_doc_dark.svg"
},
"navbar_center": [ "navbar-nav" ],
"navbar_end": ["navbar-icon-links", "version-switcher"],
"icon_links": [
{
"name": "GitHub",
"url": "https://github.com/Wimmics/corese",
"url": "https://github.com/corese-stack/corese-core",
"icon": "fab fa-github-square"
}
],
20 changes: 8 additions & 12 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -4,15 +4,13 @@
contain the root `toctree` directive.
.. image:: _static/corese.svg
.. image:: _static/logo/corese-core_doc_light.svg
:align: center
:width: 400px

.. centered:: Software platform for the Semantic Web of Linked Data

Corese is a software platform implementing and extending the standards of the Semantic Web. It allows to create, manipulate, parse, serialize, query, reason and validate RDF data.

Corese is a software platform that implements and extends the standards of the Semantic Web. It enables users to create, manipulate, parse, serialize, query, reason about, and validate RDF data.

Corese-Core is a Java library that provides the core functionalities of Corese. It allows developers to build applications that process RDF data and programmatically leverage Corese's features via its API.

.. Define named hyperlinks for the references of W3C standards
.. _RDF: https://www.w3.org/RDF/
@@ -67,13 +65,13 @@ Corese is a software platform implementing and extending the standards of the Se

.. raw:: html

<h3>Contributions and discussions</h3>
<h3>Contributions and discussions about Corese-Core</h3>

.. _discussion forum: https://github.com/orgs/corese-stack/discussions
.. _issue reports: https://github.com/corese-stack/corese-core/issues
.. _pull requests: https://github.com/Wimmics/corese/pulls/
.. _pull requests: https://github.com/corese-stack/corese-core/pulls

For support questions, comments, and any ideas for improvements youd like to discuss, please use our `discussion forum`_. We welcome everyone to contribute to `issue reports`_, suggest new features, and create `pull requests`_.
For support questions, comments, and any ideas for improvements you`d like to discuss, please use our `discussion forum`_. We welcome everyone to contribute to `issue reports`_, suggest new features, and create `pull requests`_.


.. #############################################################################
@@ -86,7 +84,7 @@ For support questions, comments, and any ideas for improvements you’d like to

<div style="visibility: hidden;">

CORESE documentation
Home Page
===================================

.. raw:: html
@@ -98,6 +96,4 @@ CORESE documentation

Installation <install.md>
User Guide <user_guide>
API Reference <apis>
Demo <https://corese.inria.fr/>

Java API <java_api/library_root>
44 changes: 35 additions & 9 deletions docs/source/install.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,57 @@
# Download and install corese-core
# Installation

Download from [maven-central](https://central.sonatype.com/namespace/fr.inria.corese)
## Corese Core

## corese-core
[![Badge Maven Central](./_static/logo/badge_maven.svg)](https://central.sonatype.com/artifact/fr.inria.corese/corese-core) [![Badge Github Release](./_static/logo/badge_github.svg)](https://github.com/corese-stack/corese-core/releases)

```xml
<!-- Maven -->
<dependency>
<groupId>fr.inria.corese</groupId>
<artifactId>corese-core</artifactId>
<version>4.5.6</version>
<version>X.Y.Z</version> <!-- replace X.Y.Z with the version number -->
</dependency>
```

## corese-storage-plugin
```Groovy
// Gradle
implementation 'fr.inria.corese:corese-core:X.Y.Z' // replace X.Y.Z with the version number
```

## Storage Modules

**Jena storage:**

[![Badge Maven Central](./_static/logo/badge_maven.svg)](https://central.sonatype.com/artifact/fr.inria.corese/corese-jena) [![Badge Github Release](./_static/logo/badge_github.svg)](https://github.com/corese-stack/corese-plugin-storage-jena/releases)

```xml
<!-- jena storage -->
<!-- Maven -->
<dependency>
<groupId>fr.inria.corese</groupId>
<artifactId>corese-jena</artifactId>
<version>4.5.6</version>
<version>X.Y.Z</version> <!-- replace X.Y.Z with the version number -->
</dependency>
```

```Groovy
// Gradle
implementation 'fr.inria.corese:corese-jena:X.Y.Z' // replace X.Y.Z with the version number
```

**RDF4J storage:**

[![Badge Maven Central](./_static/logo/badge_maven.svg)](https://central.sonatype.com/artifact/fr.inria.corese/corese-rdf4j) [![Badge Github Release](./_static/logo/badge_github.svg)](https://github.com/corese-stack/corese-plugin-storage-rdf4j/releases)

<!-- rdf4j storage -->
```xml
<!-- Maven -->
<dependency>
<groupId>fr.inria.corese</groupId>
<artifactId>corese-rdf4j</artifactId>
<version>4.5.6</version>
<version>X.Y.Z</version> <!-- replace X.Y.Z with the version number -->
</dependency>
```

```Groovy
// Gradle
implementation 'fr.inria.corese:corese-rdf4j:X.Y.Z' // replace X.Y.Z with the version number
```
28 changes: 16 additions & 12 deletions docs/source/user_guide.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
User Guide
===============
==========

.. toctree::
:hidden:
@@ -9,19 +9,23 @@ User Guide
Federated and distributed queries <federation/federated_and_distributed_queries.md>
SPARQL service extension <advanced/SPARQL_Service_Extension.md>

`Getting started with corese-core <getting_started/getting_started_with_corese-core.html>`_
--------------
Welcome to the Corese-Core User Guide! This guide will help you get started with Corese-Core, configure storage systems, perform federated queries, and extend SPARQL functionalities.

`Configuring and connecting to different storage systems in corese <storage/configuring_and_connecting_to_different_storage_systems_in_corese.html>`_
---------------
Contents:
---------

`Federated and distributed queries <federation/federated_and_distributed_queries.md>`_
---------------------------------

`SPARQL service extension <advanced/SPARQL_service_extension.md>`_
---------------------------------

.. At the moment this TOC is not used. It is just a placeholder for future use.
1. Getting Started with Corese-Core
Learn how to use main features of Corese-Core.
`Getting started with Corese-Core <getting_started/getting_started_with_corese-core.html>`_

2. Configuring Storage Systems
Guide to configuring and connecting to different storage systems.
`Configuring and connecting to different storage systems in Corese <storage/configuring_and_connecting_to_different_storage_systems_in_corese.html>`_

3. Federated Queries
Run distributed and federated queries seamlessly.
`Federated and distributed queries <federation/federated_and_distributed_queries.html>`_

4. Advanced SPARQL Features
Explore advanced SPARQL extensions for enhanced query capabilities.
`SPARQL service extension <advanced/SPARQL_service_extension.html>`_
16 changes: 0 additions & 16 deletions src/main/java/fr/inria/corese/core/Corese.java

This file was deleted.

8 changes: 0 additions & 8 deletions src/main/java/fr/inria/corese/core/EventLogger.java
Original file line number Diff line number Diff line change
@@ -142,8 +142,6 @@ void methodcall(Event type, Event e, Object o) {
* Call delete with query edge because target edge has null predicate in the graph Index
*/
void funcall(Event type, Event e, Object o, Object o2) {
boolean b = getEventManager().isVerbose();
getEventManager().setVerbose(false);
try {
switch (type) {
case Process:
@@ -161,9 +159,6 @@ void funcall(Event type, Event e, Object o, Object o2) {
} catch (EngineException ex) {
java.util.logging.Logger.getLogger(EventLogger.class.getName()).log(Level.SEVERE, null, ex);
}
finally {
getEventManager().setVerbose(b);
}
}

IDatatype funcall(String name, Edge edge) throws EngineException {
@@ -238,9 +233,6 @@ void logNodeManager(NodeManager nm) {
nm.getIndex(), nm.size() , nm.count(),
(nm.size() > 0) ? ((float) nm.count()) / nm.size() : 0,
mgr.getGraph().size()));
// if (nm.getIndex()==-1) {
// logger.info(nm.toString());
// }
}

NodeManager getNodeMgr() {
48 changes: 3 additions & 45 deletions src/main/java/fr/inria/corese/core/EventManager.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package fr.inria.corese.core;

import fr.inria.corese.core.compiler.eval.Interpreter;
import fr.inria.corese.core.compiler.parser.Transformer;
import fr.inria.corese.core.api.Engine;
import static fr.inria.corese.core.Event.Finish;
import static fr.inria.corese.core.Event.Process;
import static fr.inria.corese.core.Event.Start;
import fr.inria.corese.core.logic.Entailment;
import fr.inria.corese.core.util.Property;
import static fr.inria.corese.core.util.Property.Value.LOG_NODE_INDEX;
@@ -26,10 +22,8 @@
public class EventManager implements EventHandler {

private static Logger logger = LoggerFactory.getLogger(EventManager.class);
public static boolean DEFAULT_VERBOSE = false;

private Graph graph;
private boolean verbose = DEFAULT_VERBOSE;
private boolean isEntail = true;
private boolean isUpdate = false;
private boolean isDelete = false;
@@ -75,7 +69,6 @@ void send(Event type, Event e) {
}

void send(Event type, Event e, Object o) {
trace(type, e, o);
switch (type) {
case Start:
start(e);
@@ -102,7 +95,7 @@ public void process(Event e) {
}

public void process(Event e, Object o1, Object o2) {
//trace(Process, e, o1, o2);
//trace(Process, e, o1, o2);
switch(e) {
case Insert:
setUpdate(true); break;
@@ -144,7 +137,6 @@ public void insert(Edge e) {


public void start(Event e, Object o) {
trace(Start, e, o);
switch (e) {
case Query:
// sparql query
@@ -227,7 +219,6 @@ public void start(Event e, Object o) {


public void finish(Event e, Object o) {
trace(Finish, e, o);
switch (e) {
// insert after delete may require up to date NodeIndex
// we must compute node index after delete
@@ -304,9 +295,9 @@ void setEntailment(boolean b) {
getEntailment().setActivate(b);
}
}

void log(Property.Value prop, Event type, Event e, Object o) {
if (Property.booleanValue(prop)) {
if (Property.getBooleanValue(prop)) {
getLog().log(type, e, o);
}
}
@@ -370,46 +361,13 @@ void setEntail(boolean b) {
public boolean isEntail() {
return isEntail;
}


void trace(Event type, Event e) {
trace(type, e, null);
}

void trace(Event type, Event e, Object o) {
trace(type, e, o, null);
}
void trace(Event type, Event e, Object o, Object o2) {
if (verbose) {
getLog().trace(type, e, o, o2);
}
}

EventLogger getLog() {
if (log == null) {
log = new EventLogger(this);
}
return log;
}

/**
* @return the debug
*/
public boolean isVerbose() {
return verbose;
}

/**
* @param debug the debug to set
*/
public void setVerbose(boolean debug) {
this.verbose = debug;
}

public void setTrackUpdate(boolean track) {
setVerbose(track);
getLog().setMethod(track);
}

public void setDeletion(boolean deletion) {
this.deletion = deletion;
1,303 changes: 549 additions & 754 deletions src/main/java/fr/inria/corese/core/Graph.java

Large diffs are not rendered by default.

78 changes: 33 additions & 45 deletions src/main/java/fr/inria/corese/core/GraphCompare.java
Original file line number Diff line number Diff line change
@@ -1,46 +1,44 @@
package fr.inria.corese.core;

import fr.inria.corese.core.kgram.api.core.Edge;
import fr.inria.corese.core.kgram.api.core.Node;
import java.util.HashMap;
import java.util.Iterator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.inria.corese.core.kgram.api.core.Edge;

import java.util.HashMap;
import java.util.Iterator;

/**
*
* @author Olivier Corby, Wimmics INRIA I3S, 2016
*
*/
public class GraphCompare {
private static Logger logger = LoggerFactory.getLogger(GraphCompare.class);

Graph g1, g2;
GraphCompare(Graph g1, Graph g2){

GraphCompare(Graph g1, Graph g2) {
this.g1 = g1;
this.g2 = g2;
}
public boolean compare(boolean isGraph, boolean detail, boolean isDebug) {


public boolean compare(boolean isGraph, boolean detail) {
g1.prepare();
g2.prepare();

boolean ok = true;

if (g1.size() != g2.size()) {
logger.error("** Graph Size: " + g1.size() + " != " + g2.size());
ok = false;
}

for (Node pred1 : g1.getProperties()) {
Node pred2 = g2.getPropertyNode(pred1.getLabel());
if (pred2 == null){
ok = false;
logger.error("** Graph Pred: " + pred1 + " undefined in G2 " );
}
else {
if (pred2 == null) {
ok = false;
logger.error("** Graph Pred: " + pred1 + " undefined in G2 ");
} else {
int s1 = g1.size(pred1);
int s2 = g2.size(pred2);
if (s1 != s2) {
@@ -64,9 +62,6 @@ public boolean compare(boolean isGraph, boolean detail, boolean isDebug) {

if (pred2 == null) {
if (l1.iterator().hasNext()) {
if (isDebug) {
logger.error("Missing in g2: " + pred1);
}
return false;
}
} else {
@@ -80,9 +75,6 @@ public boolean compare(boolean isGraph, boolean detail, boolean isDebug) {
// node index
boolean b = compare(g2, pred2, t, ent1, isGraph);
if (!b) {
if (isDebug) {
logger.error("Missing in g2: " + ent1);
}
return false;
}
} else {
@@ -93,10 +85,6 @@ public boolean compare(boolean isGraph, boolean detail, boolean isDebug) {

Edge ent2 = it.next();
if (!compare(ent1, ent2, t, isGraph)) {
if (isDebug) {
logger.error(ent1.toString());
logger.error(ent2.toString());
}
return false;
}
}
@@ -107,10 +95,10 @@ public boolean compare(boolean isGraph, boolean detail, boolean isDebug) {
return true;
}

/**
* TODO: may return false negative because it does not backtrack
* It should be a projection ...
*/
/**
* TODO: may return false negative because it does not backtrack
* It should be a projection ...
*/
boolean compare(Graph g2, Node pred2, TBN t, Edge ent1, boolean isGraph) {
Iterable<Edge> l2 = g2.getEdges(pred2);
Iterator<Edge> it = l2.iterator();
@@ -136,8 +124,8 @@ boolean compare(Edge ent1, Edge ent2, TBN t, boolean isGraph) {
return false;
}
}
if (isGraph){

if (isGraph) {
return ent1.getGraph().equals(ent2.getGraph());
}
return true;
@@ -163,37 +151,37 @@ boolean compare(Node n1, Node n2, TBN t) {
}

class TBN extends HashMap<Node, Node> {
HashMap<Node, Integer> count ;
TBN(){

HashMap<Node, Integer> count;

TBN() {
count = new HashMap<Node, Integer>();
}

boolean same(Node n1, Node n2) {
if (containsKey(n1)) {
boolean b = get(n1).equals(n2);
if (b){
if (b) {
count.put(n1, count.get(n1) + 1);
}
return b;
} else {
put(n1, n2);
count.put(n1, 1);
return true;
return true;
}
}
void pop(Node n){
if (n.isBlank()){

void pop(Node n) {
if (n.isBlank()) {
if (count.containsKey(n)) {
count.put(n, count.get(n) - 1);
if (count.get(n) == 0){
count.put(n, count.get(n) - 1);
if (count.get(n) == 0) {
remove(n);
}
}
}

}
}

14 changes: 13 additions & 1 deletion src/main/java/fr/inria/corese/core/GraphStore.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.inria.corese.core;

import fr.inria.corese.core.elasticsearch.EdgeChangeListener;
import fr.inria.corese.core.logic.Entailment;
import fr.inria.corese.core.kgram.api.core.Node;
import fr.inria.corese.core.sparql.datatype.DatatypeMap;
@@ -27,7 +28,7 @@ public static GraphStore create() {
}

public static GraphStore create(boolean b) {
GraphStore gs = new GraphStore();
GraphStore gs = create();
if (b) {
gs.setEntailment();
}
@@ -152,4 +153,15 @@ public void setStore(HashMap<String, Graph> store) {
this.store = store;
}

/**
* Adds listener to default graph and named graphs
*/
@Override
public void addEdgeChangeListener(EdgeChangeListener listener) {
super.addEdgeChangeListener(listener);
for(Graph g : getNamedGraphs()) {
g.addEdgeChangeListener(listener);
}
}

}
41 changes: 21 additions & 20 deletions src/main/java/fr/inria/corese/core/api/Loader.java
Original file line number Diff line number Diff line change
@@ -5,22 +5,23 @@
import java.io.InputStream;

public interface Loader {
static final int RDFXML_FORMAT = 0;
static final int RDFA_FORMAT = 1;
static final int TURTLE_FORMAT = 2;
static final int NT_FORMAT = 3;
static final int JSONLD_FORMAT = 4;
static final int RULE_FORMAT = 5;
static final int QUERY_FORMAT = 6;
static final int UNDEF_FORMAT = 7;
static final int TRIG_FORMAT = 8;
static final int NQUADS_FORMAT = 9;
static final int WORKFLOW_FORMAT = 10;
static final int OWL_FORMAT = 11;
static final int XML_FORMAT = 12;
static final int JSON_FORMAT = 13;

static final String ACCEPT = "Accept";
public enum format {
RDFXML_FORMAT,
RDFA_FORMAT,
TURTLE_FORMAT,
NT_FORMAT,
JSONLD_FORMAT,
RULE_FORMAT,
QUERY_FORMAT,
UNDEF_FORMAT,
TRIG_FORMAT,
NQUADS_FORMAT,
WORKFLOW_FORMAT,
OWL_FORMAT,
XML_FORMAT,
JSON_FORMAT
}

static final String JSONLD_FORMAT_STR = "application/ld+json";
static final String JSON_FORMAT_STR = "application/json";
static final String RDFXML_FORMAT_STR = "application/rdf+xml";
@@ -40,7 +41,7 @@ public interface Loader {

void parse(String path, String source) throws LoadException;

void parse(String path, String source, String base, int format) throws LoadException;
void parse(String path, String source, String base, Loader.format format) throws LoadException;


@Deprecated
@@ -50,7 +51,7 @@ public interface Loader {
void load(String path, String source);

@Deprecated
void load(String path, String base, String source, int format) throws LoadException;
void load(String path, String base, String source, Loader.format format) throws LoadException;

@Deprecated
void load(InputStream stream, String str) throws LoadException;
@@ -62,8 +63,8 @@ public interface Loader {
void loadWE(String path, String source) throws LoadException;

RuleEngine getRuleEngine();
int getFormat(String path);

format getFormat(String path);


}
14 changes: 7 additions & 7 deletions src/main/java/fr/inria/corese/core/api/Log.java
Original file line number Diff line number Diff line change
@@ -4,18 +4,18 @@


public interface Log {
public static final int LOAD = 0;
public static final int QUERY = 1;
public static final int UPDATE = 2;

enum Operation {
LOAD, QUERY, UPDATE
}

void reset();

void log(int type, Object obj);
void log(Log.Operation type, Object obj);

void log(int type, Object obj1, Object obj2);
void log(Log.Operation type, Object obj1, Object obj2);

List<Object> get(int type);
List<Object> get(Log.Operation type);


}
Original file line number Diff line number Diff line change
@@ -17,46 +17,7 @@ public class Utils {
* @return
*/
public static String format(double d) {
return String.format("%2.4f", d);
}

/**
* Print a specific msg
* @param alg
* @param s1
* @param s2
* @param parameter
* @param sim
*/
public static void msg(String alg, String s1, String s2, String parameter, double sim) {
if (SHOW_MSG) {
System.out.println("\t [" + alg + ", "+parameter+"]: " + s1 + ", " + s2 + ", " + String.format("%2.4f", sim));
}
}

/**
* Print a message
*
* @param msg
*/
public static void msg(String msg) {
if (SHOW_MSG) {
System.out.println(msg);
}
}

/**
* Print a message with an exceptional message
*
* @param msg
* @param exceptional
*/
public static void msg(String msg, boolean exceptional) {
if (exceptional) {
System.out.println(msg);
} else {
msg(msg);
}
return String.format("%2.4f", d).replace(',', '.'); // Had to add the replace to force replace the ","
}

/**
Original file line number Diff line number Diff line change
@@ -42,7 +42,6 @@ public AlgType getType() {

@Override
public double calculate(String s1, String s2, String parameters) {
Utils.msg("Base-" + this.getType().name(), s1, s2, parameters, MIN);
return MIN;
}

Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ public Equality() {
@Override
public double calculate(String s1, String s2, String paramter) {
double sim = MAX;
Utils.msg("Eq", s1, s2, paramter, sim);
return sim;
}
}
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ public double calculate(String s1, String s2, String parameter) {
sim = jaroSim + prefix * (0.1 * (1.0 - jaroSim));
}

Utils.msg("Jaro-Winkler", s1, s2, parameter, sim);
return sim;
}

Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@ public NGram(int n) {
@Override
public double calculate(String s1, String s2, String parameter) {
double sim = this.calculate(s1, s2);
Utils.msg("N-Gram" + NG, s1, s2, parameter, sim);
return sim;
}

Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
import fr.inria.corese.core.sparql.triple.parser.Variable;
import fr.inria.corese.core.compiler.api.QueryVisitor;
import fr.inria.corese.core.kgram.core.Query;
import static fr.inria.corese.core.approximate.algorithm.Utils.msg;
import fr.inria.corese.core.approximate.algorithm.Parameters;
import static fr.inria.corese.core.approximate.ext.ASTRewriter.S;
import fr.inria.corese.core.approximate.strategy.ApproximateStrategy;
@@ -109,8 +108,6 @@ else for (Exp ee : e) {
}

private void process(Exp exp, Triple t) {
//for(Exp exp: ast.gets)
msg("------ BEFORE -----\n" + exp, false);

//1 pre process, choose strategies for each atom
Map<Integer, TripleWrapper> map = new HashMap<Integer, TripleWrapper>();
@@ -119,11 +116,6 @@ private void process(Exp exp, Triple t) {
init(t, t.getPredicate(), P, map);
init(t, t.getObject(), O, map);

msg("\n------ pre-process lsit-----");
for (TripleWrapper value : map.values()) {
msg(value.toString());
}

//2 rewrite triples in AST
List<Exp> filters = new ArrayList<>();
List<Optional> options = new ArrayList<Optional>();
@@ -141,8 +133,6 @@ private void process(Exp exp, Triple t) {
for (Optional option : options) {
exp.add(option);
}

msg("\n------ AFTER -----\n" + exp, false);
}

//choose the Strategy for the URI and put them into a list
@@ -174,12 +164,6 @@ else if (dt.isLiteral() && relaxLiteral){
if (dt.getCode() == IDatatype.STRING ||
dt.getCode() == IDatatype.LITERAL ){ //(dt.getDatatypeURI().equals(xsdstring) ) {
add(lst, LITERAL_LEX);

//@lang=en ??
// if (atom.getLang() == null ||
// (atom.getLang() != null && atom.getLang().equalsIgnoreCase("en"))) {
// add(lst, LITERAL_WN);
// }
}
}

Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@
import fr.inria.corese.core.approximate.algorithm.ISimAlgorithm;
import fr.inria.corese.core.approximate.algorithm.SimAlgorithmFactory;
import static fr.inria.corese.core.approximate.algorithm.Utils.format;
import static fr.inria.corese.core.approximate.algorithm.Utils.msg;
import fr.inria.corese.core.approximate.algorithm.impl.BaseAlgorithm;
import fr.inria.corese.core.query.PluginImpl;

@@ -37,7 +36,6 @@ public IDatatype eval(Expr exp, Environment env, Producer p) {
ApproximateSearchEnv appxEnv = env.getAppxSearchEnv();
double d = appxEnv.aggregate(env);
IDatatype sim = plugin.getValue(d);
msg("[Eval sim() ]: " + sim);
return sim;
default:
return null;
@@ -49,7 +47,6 @@ public IDatatype eval(Expr exp, Environment env, Producer p, Object[] args) {
switch (exp.oper()) {

case APPROXIMATE:
msg("[Eval appx ... ]: " + exp);
//0. check parameters
return eval(exp, env, param);

@@ -105,7 +102,6 @@ private IDatatype approximate(IDatatype dt1, IDatatype dt2, String parameter, St

//3 finalize
boolean filtered = combinedSim > threshold;
msg("\t [Similarity,\t " + dt1 + ",\t" + dt2 + "]: c:" + format(singleSim) + ", all:" + format(combinedSim) + ", " + filtered);

if (notExisted) {
appxEnv.add(var, dt2, dt1, algs, singleSim);
Original file line number Diff line number Diff line change
@@ -446,7 +446,8 @@ public void setCurrentEval(Eval e) {

void tune(Eval kgram, Query q, Mapping m) {
ASTQuery ast = q.getAST();
boolean event = ast.hasMetadata(Metadata.EVENT);
// boolean event = ast.hasMetadata(Metadata.EVENT);
boolean event = true;
// Dataset ds parameter in QueryProcess is set as ast defaultDataset
tune(kgram, ast.getDefaultDataset(), m, event);
if (q.isInitMode()) {
Original file line number Diff line number Diff line change
@@ -26,14 +26,11 @@ public QuerySolverVisitorExtension(Eval ev) {

@Override
public IDatatype update(Query q, List<Edge> delete, List<Edge> insert) {
System.out.println("My Visitor update");
return super.update(q, delete, insert);
}

@Override
public IDatatype insert(IDatatype path, Edge triple) {
System.out.println("My Visitor insert: " + triple);
return path;
//return super.insert(path, triple);
}
}
Original file line number Diff line number Diff line change
@@ -249,10 +249,8 @@ void define(ASTQuery ast, ASTExtension aext, Query q) {
if (pub || exp.isPublic()) {
definePublic(exp, q);
}
if (exp.hasMetadata(Metadata.UPDATE)) {
// @update event function => detail mode for Construct insert/delete
q.setDetail(true);
}
// Detail mode for Construct insert/delete
q.setDetail(true);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package fr.inria.corese.core.elasticsearch;


import fr.inria.corese.core.kgram.api.core.Edge;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

public abstract class EdgeChangeListener {
private static final Logger logger = LoggerFactory.getLogger(EdgeChangeListener.class);

public void onEdgeInsert(Edge edge) {
onBulkEdgeChange(List.of(), List.of(edge));
}

public void onBulkEdgeInsert(List<Edge> edgeList) {
onBulkEdgeChange(List.of(), edgeList);
}

public void onEdgeDelete(Edge edge) {
onBulkEdgeChange(List.of(edge), List.of());
}

public void onBulkEdgeDelete(List<Edge> edgeList) {
onBulkEdgeChange(edgeList, List.of());
}

public abstract void onBulkEdgeChange(List<Edge> delete, List<Edge> insert);
}
12 changes: 0 additions & 12 deletions src/main/java/fr/inria/corese/core/index/EdgeManager.java
Original file line number Diff line number Diff line change
@@ -350,25 +350,17 @@ Iterable<Edge> getEdgesBasic(Node subject, Node object) {
// iterate edges with node and node2
return new EdgeManagerIterate(this, beginIndex, object.getIndex());
}
else if (getGraph().isDebugSparql()) {
traceEdgeList();
}

return null;
}

// node is bound, enumerate edges where node = edge.getNode(index)
Iterable<Edge> getEdgesBasic(Node node) {
int beginIndex = findNodeIndex(node);
getGraph().trace("Get edges: node=%s label=%s index=%s place=%s",
node, node.getLabel(), node.getIndex(), beginIndex);

if (beginIndex >= 0 && beginIndex < getEdgeList().size()) {
return new EdgeManagerIterate(this, beginIndex);
}
else if (getGraph().isDebugSparql()) {
traceEdgeList();
}

return null;
}
@@ -419,11 +411,7 @@ int find(Edge edge) {
*/
Edge findEdge(Edge edge) {
int i = findEdgeEqualWithoutMetadata(edge);
getGraph().trace("Find edge: %s place=%s", edge, i);
if (i == -1) {
if (getGraph().isDebugSparql()) {
traceEdgeList();
}
return null;
}
return getEdgeList().get(i);
Loading

0 comments on commit 3792877

Please sign in to comment.