Ejemplo n.º 1
0
  public AutoSPARQLSession(
      Dataset dataset,
      String cacheDir,
      String servletContextPath,
      QuestionProcessor questionPreprocessor) {
    this.dataset = dataset;
    this.servletContextPath = servletContextPath;
    this.questionPreprocessor = questionPreprocessor;

    endpoint = dataset.getEndpoint();

    search = dataset.getSearchIndex();
    search.setQuestionPreprocessor(questionPreprocessor);

    constructCache =
        new ExtractionDBCache(cacheDir + "/" + endpoint.getPrefix() + "/construct-cache");
    selectCache = new ExtractionDBCache(cacheDir + "/" + endpoint.getPrefix() + "/select-cache");

    exampleFinder =
        new ExampleFinder(endpoint, selectCache, constructCache, search, questionPreprocessor);

    property2LabelMap = new TreeMap<String, String>();
    property2DatatypeMap = new HashMap<String, Class>();
    propertiesCache = new TreeMap<String, Map<String, Object>>();
    examplesCache = new HashMap<String, Example>();
  }
Ejemplo n.º 2
0
  public AutoSPARQLSession(String cacheDir, String servletContextPath, String solrURL) {
    this.servletContextPath = servletContextPath;

    constructCache =
        new ExtractionDBCache(cacheDir + "/" + endpoint.getPrefix() + "/construct-cache");
    selectCache = new ExtractionDBCache(cacheDir + "/" + endpoint.getPrefix() + "/select-cache");
    search = new SolrSearch(solrURL);
    exampleFinder =
        new ExampleFinder(endpoint, selectCache, constructCache, search, questionPreprocessor);
  }
Ejemplo n.º 3
0
 public void saveSPARQLQuery(Store store) throws AutoSPARQLException {
   List<Example> posExamples = new ArrayList<Example>();
   for (String uri : exampleFinder.getPositiveExamples()) {
     posExamples.add(examplesCache.get(uri));
   }
   List<Example> negExamples = new ArrayList<Example>();
   for (String uri : exampleFinder.getNegativeExamples()) {
     negExamples.add(examplesCache.get(uri));
   }
   store.saveSPARQLQuery(
       question,
       exampleFinder.getCurrentQuery(),
       endpoint.getLabel(),
       posExamples,
       negExamples,
       exampleFinder.getLastSuggestedExample());
 }