Permalink
Browse files

Merge branch 'master' of github.com:cmader/qSKOS

  • Loading branch information...
cmader committed Apr 13, 2012
2 parents 04c4f6e + 43472cc commit c7a3b21a174df9f2dc54db5016c982dca3e9265e
@@ -11,6 +11,8 @@
import org.openrdf.OpenRDFException;
import org.openrdf.model.Resource;
import org.openrdf.model.URI;
+import org.openrdf.repository.Repository;
+import org.openrdf.repository.sparql.SPARQLRepository;
import org.openrdf.rio.RDFFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,7 +54,7 @@
private final Logger logger = LoggerFactory.getLogger(QSkos.class);
- private Set<String> sparqlEndPoints = new HashSet<String>();
+ private Set<Repository> otherRepositories = new HashSet<Repository>();
private ResourceAvailabilityChecker resourceAvailabilityChecker;
private HierarchyAnalyzer hierarchyAnalyer;
@@ -245,7 +247,7 @@ public ConceptLabelsResult findNotDisjointLabels() throws OpenRDFException {
{
InLinkFinder inLinkFinder = new InLinkFinder(
vocabRepository,
- sparqlEndPoints);
+ otherRepositories);
inLinkFinder.setProgressMonitor(progressMonitor);
return inLinkFinder.findMissingInLinks(findAuthoritativeConcepts().getData(), randomSubsetSize_percent);
}
@@ -294,7 +296,15 @@ public void setProgressMonitor(IProgressMonitor progressMonitor) {
}
public void addSparqlEndPoint(String endpointUrl) {
- sparqlEndPoints.add(endpointUrl);
+ otherRepositories.add(new SPARQLRepository(endpointUrl));
+ }
+
+ /**
+ * Adds the repository containing the vocabulary that's about to test to the list of
+ * other repositories. This is only useful for in-link testing purposes.
+ */
+ public void addRepositoryLoopback() {
+ otherRepositories.add(vocabRepository.getRepository());
}
public void setAuthoritativeResourceIdentifier(String authResourceIdentifier) {
@@ -15,7 +15,7 @@
import org.openrdf.query.QueryLanguage;
import org.openrdf.query.TupleQuery;
import org.openrdf.query.TupleQueryResult;
-import org.openrdf.repository.sparql.SPARQLRepository;
+import org.openrdf.repository.Repository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,30 +30,23 @@
private final Logger logger = LoggerFactory.getLogger(InLinkFinder.class);
private Collection<URI> authoritativeConcepts;
- private Set<SPARQLRepository> sparqlEndpoints;
+ private Set<Repository> repositories;
private Map<URI, Set<URI>> conceptReferencingResources = new HashMap<URI, Set<URI>>();
public InLinkFinder(
VocabRepository vocabRepository,
- Set<String> sparqlEndpoints)
+ Set<Repository> repositories)
{
super(vocabRepository);
- createSparqlRepositories(sparqlEndpoints);
- }
-
- private void createSparqlRepositories(Set<String> sparqlEndpoints) {
- this.sparqlEndpoints = new HashSet<SPARQLRepository>();
- if (sparqlEndpoints == null || sparqlEndpoints.isEmpty()) {
- logger.warn("no SPARQL endpoints defined");
+ if (repositories == null || repositories.isEmpty()) {
+ logger.warn("no repository for querying defined");
}
else {
- for (String sparqlEndpoint : sparqlEndpoints) {
- this.sparqlEndpoints.add(new SPARQLRepository(sparqlEndpoint));
- }
+ this.repositories = repositories;
}
}
-
+
public CollectionResult<URI> findMissingInLinks(
Collection<URI> authoritativeConcepts,
Float randomSubsetSize_percent) throws OpenRDFException
@@ -89,12 +82,12 @@ private void createSparqlRepositories(Set<String> sparqlEndpoints) {
private void rankConcept(URI concept)
throws OpenRDFException
{
- for (SPARQLRepository sparqlEndpoint : sparqlEndpoints) {
+ for (Repository sparqlEndpoint : repositories) {
rankConceptByEndpoint(concept, sparqlEndpoint);
}
}
- private void rankConceptByEndpoint(URI concept, SPARQLRepository endpoint)
+ private void rankConceptByEndpoint(URI concept, Repository endpoint)
throws OpenRDFException
{
String query = "SELECT distinct ?resource WHERE " +
@@ -18,18 +18,16 @@
@Before
public void setUp() throws OpenRDFException, IOException {
qSkosRankConcepts = setUpInstance("rankConcepts.rdf");
- qSkosRankConcepts.addSparqlEndPoint("http://sparql.sindice.com/sparql");
+ qSkosRankConcepts.addRepositoryLoopback();
}
- /* temporarily disabled, sindice seems to be broken...
@Test
public void testInLinksAsDbPedia() throws OpenRDFException {
qSkosRankConcepts.setAuthoritativeResourceIdentifier("dbpedia.org");
Collection<URI> conceptsMissingInLinks = qSkosRankConcepts.findMissingInLinks().getData();
Assert.assertTrue(conceptsMissingInLinks.isEmpty());
}
- */
@Test
public void testInLinksAsSTW() throws OpenRDFException {
@@ -8,11 +8,18 @@
xmlns:skos="http://www.w3.org/2004/02/skos/core#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
>
+ <!-- out-link part -->
<rdf:Description rdf:about="http://myvocab.org/singer">
<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
<skos:narrower rdf:resource="http://dbpedia.org/resource/Michael_Jackson"/>
</rdf:Description>
<rdf:Description rdf:about="http://zbw.eu/stw/descriptor/13845-2">
<skos:narrower rdf:resource="http://zbw.eu/stw/descriptor/11994-2"/>
</rdf:Description>
+
+ <!-- in-link part -->
+ <rdf:Description rdf:about="http://othervocab.org/charts">
+ <rdf:first rdf:resource="http://dbpedia.org/resource/Michael_Jackson"/>
+ </rdf:Description>
+
</rdf:RDF>

0 comments on commit c7a3b21

Please sign in to comment.