示例#1
0
  // TODO move to script, paralelize addTerm!
  public void process(String text) throws Exception {
    this.text.append(' ').append(text);

    SearchClient client =
        new SearchClient(
            "WIsykmzV34GpQo23EGZ0F38QqYu2y8wrq.hLmYjXjNpkA5L4MCzCeL1mniq82m9w5oSMbXHi");
    ContentAnalysisRequest request = new ContentAnalysisRequest(text);

    ContentAnalysisResults result = client.termExtractionSearch(request);

    String[] yterms = result.getExtractedTerms();
    for (int i = 0; i < yterms.length; i++) {
      addTerm(yterms[i]);
    }
  }
示例#2
0
  public static String[] getAddresses(String name, int numResults, String withinURL) {
    String query = "";
    if (withinURL != null && withinURL.length() > 0) query += "inurl:" + withinURL + " ";

    query += name;

    ArrayList<String> arrayList = new ArrayList<String>();

    SearchClient client =
        new SearchClient("OzomwBrV34GSUD6G3vWHVV43nlVF.srrxIT88JqkrDhrTPAqLMhNBwZa6TT.8WuJmCU-");

    // Create the web search request. In this case we're searching for
    // java-related hits.
    WebSearchRequest request = new WebSearchRequest(query);
    request.setResults(numResults);

    try {
      // Execute the search.
      WebSearchResults results = client.webSearch(request);

      // Iterate over the results.
      for (int i = 0; i < results.listResults().length; i++) {
        WebSearchResult result = results.listResults()[i];

        // Print out the document title and URL.
        arrayList.add(result.getUrl());
      }
    } catch (IOException e) {
      // Most likely a network exception of some sort.
      System.err.println("Error calling Yahoo! Search Service: " + e.toString());
      e.printStackTrace(System.err);
    } catch (SearchException e) {
      // An issue with the XML or with the service.
      System.err.println("Error calling Yahoo! Search Service: " + e.toString());
      e.printStackTrace(System.err);
    }
    String[] dummy = new String[0];
    return arrayList.toArray(dummy);
  }