public static ArrayList<QueryData> parseOSMOQueryData(TupleQueryResult qres) {
      ArrayList<QueryData> queryDataList = new ArrayList<QueryData>();

      try {
        while (qres.hasNext()) {
          BindingSet b = qres.next();
          Set names = b.getBindingNames();
          QueryData queryData = new QueryData();

          for (Object n : names) {
            if (((String) n).equalsIgnoreCase("queryID")) {
              String str =
                  (b.getValue((String) n) == null) ? null : b.getValue((String) n).stringValue();
              queryData.setId(str);
              System.out.print("srvcStatus id: " + queryData.getId() + " ");
            } else if (((String) n).equalsIgnoreCase("queryString")) {
              String str =
                  (b.getValue((String) n) == null) ? null : b.getValue((String) n).stringValue();
              queryData.setQueryString(str);
              System.out.print("srvcStatusTime : " + queryData.getQueryString() + " ");
            }
          }
          queryDataList.add(queryData);
        } // while
        return queryDataList;
      } catch (QueryEvaluationException e) {
        e.printStackTrace();
        return null;
      } catch (Exception e) {
        e.printStackTrace();
        return null;
      }
    }
Beispiel #2
0
 /** @return true to indicate that the parameter was processed */
 public boolean update(Config.Builder builder, QueryData data) {
   String value = data.getParam(name);
   if (value == null) {
     return false;
   }
   return configUpdater.update(value, builder);
 }
  @Test
  public void testUniqueNameForDoubleNormalized() {
    Assume.assumeTrue(postProcessorExists);

    String aql =
        "cat=/(S|.P)/ >[func=/M(O|NR)/] cat=\"PP\" & #2 >[func=\"AC\"] lemma=\"an\" & #3 _=_ pos=/APPR(ART)?/ & #2 >[func=\"NK\"] pos=\"NN\"";

    // perform the initial parsing
    QueryData data = parser.parse(aql, new LinkedList<Long>());
    Assert.assertEquals(1, data.getAlternatives().size());
    List<QueryNode> alt = data.getAlternatives().get(0);
    Assert.assertEquals(7, alt.size());

    Assert.assertEquals(6, alt.get(5).getId());
    Assert.assertEquals("x6(2)", alt.get(5).getVariable());

    Assert.assertEquals(7, alt.get(6).getId());
    Assert.assertEquals("x7(2)", alt.get(6).getVariable());
  }
Beispiel #4
0
  @Override
  protected void doGet(HttpExchange exchange, QueryData data, Config config) throws IOException {
    Compilation compilation = getCompilation(exchange, data, config);
    if (compilation == null) {
      return;
    }

    String configId = config.getId();
    List<JsInput> inputs;
    if (compilation.usesModules()) {
      ModuleConfig moduleConfig = config.getModuleConfig();
      Map<String, List<JsInput>> moduleToInputs;
      try {
        moduleToInputs = moduleConfig.partitionInputsIntoModules(config.getManifest());
      } catch (CompilationException e) {
        throw new RuntimeException(e);
      }

      String module = data.getParam("module");
      inputs = moduleToInputs.get(module);
    } else {
      try {
        inputs = config.getManifest().getInputsInCompilationOrder();
      } catch (CompilationException e) {
        HttpUtil.writeErrorMessageResponse(exchange, e.getMessage());
        return;
      }
    }

    // Build up the list of hyperlinks.
    Function<JsInput, String> converter =
        InputFileHandler.createInputNameToUriConverter(server, exchange, configId);
    SoyListData inputData = new SoyListData();
    for (JsInput input : inputs) {
      SoyMapData inputDatum = new SoyMapData();
      inputDatum.put("href", converter.apply(input));
      inputDatum.put("name", input.getName());
      inputData.add(inputDatum);
    }
    SoyMapData soyData = new SoyMapData();
    soyData.put("inputs", inputData);
    soyData.put("configId", configId);

    // Write the response.
    Headers responseHeaders = exchange.getResponseHeaders();
    responseHeaders.set("Content-Type", "text/html");
    String html = TOFU.newRenderer("org.plovr.list").setData(soyData).render();
    exchange.sendResponseHeaders(200, html.length());
    Writer responseBody = new OutputStreamWriter(exchange.getResponseBody());
    responseBody.write(html);
    responseBody.close();
  }
  @Override
  public double getScore(DocData Doc, QueryData query, RankingModel rModel) {

    HashMap<String, Double> FeatureWeights = rModel.FeatureWeights;

    TermFreqUtil.enableStemming = true;

    List<String> termVector = new ArrayList<String>();

    List<Double> queryVector =
        Vectorizer.getQueryVector(
            query.GetQueryString(),
            termVector,
            TermSmoothingType.LOGARITHM,
            DocSmoothingType.IDF,
            rModel);

    Map<DocFeature, List<Double>> docVector =
        Vectorizer.getDocumentVector(
            Doc,
            termVector,
            TermSmoothingType.LOGARITHM,
            DocSmoothingType.NONE,
            NormalizationType.LENGTH,
            rModel);

    HashMap<String, Double> FeatureVariable = new HashMap<String, Double>();

    double FeatureURL = VectorUtil.dot(queryVector, docVector.get(DocFeature.URL));
    double FeatureTitle = VectorUtil.dot(queryVector, docVector.get(DocFeature.TITLE));
    double FeatureBody = VectorUtil.dot(queryVector, docVector.get(DocFeature.BODY));
    double FeatureHeaderL = VectorUtil.dot(queryVector, docVector.get(DocFeature.HEADER));
    double FeatureAnchor = VectorUtil.dot(queryVector, docVector.get(DocFeature.ANCHOR));

    double FirstPos = getFirstPos(Doc, query);

    FeatureVariable.put("task4_W_url", FeatureURL);
    FeatureVariable.put("task4_W_title", FeatureTitle);
    FeatureVariable.put("task4_W_body", FeatureBody);
    FeatureVariable.put("task4_W_header", FeatureHeaderL);
    FeatureVariable.put("task4_W_anchor", FeatureAnchor);
    FeatureVariable.put("task4_W_first_pos", FirstPos);

    try {

      return LinearModel.CalculateScore(FeatureVariable, FeatureWeights);
    } catch (NoSuchFieldException e) {
      e.printStackTrace();
    }
    return 0;
  }