public static ReviewerPubCitation getReviewerPubCitationByID(int pid) {
    Connection conn = null;
    PreparedStatement ps = null;
    ReviewerPubCitation rp = null;
    List<Integer> citationIds = null;
    List<Integer> referenceIds = null;
    try {
      conn = pool.getConnection();
      String query = "SELECT id, title, authors from " + rr_pub + " where id = ?";
      ps = conn.prepareStatement(query);
      ps.setInt(1, pid);
      ResultSet rs1 = ps.executeQuery();
      ResultSet rs2 = null;
      if (rs1.next()) {
        rp = new ReviewerPubCitation();
        rp.setPubId(rs1.getInt("id"));
        rp.setTitle(rs1.getString("title"));
        rp.setAuthorStr(rs1.getString("authors"));

        query = "SELECT citeid from " + rr_citation + " where citedid = ?";
        ps = conn.prepareStatement(query);
        ps.setInt(1, rp.getPubId());
        rs2 = ps.executeQuery();
        if (rs2.next()) {
          citationIds = new ArrayList<Integer>();
          citationIds.add(rs2.getInt("citeid"));
          rp.setCitationIds(citationIds);
          while (rs2.next()) {
            citationIds.add(rs2.getInt("citeid"));
          }
          rp.setCitationIds(citationIds);
        }

        query = "SELECT citedid from " + rr_citation + " where citeid = ?";
        ps = conn.prepareStatement(query);
        ps.setInt(1, rp.getPubId());
        rs2 = ps.executeQuery();
        if (rs2.next()) {
          referenceIds = new ArrayList<Integer>();
          referenceIds.add(rs2.getInt("citedid"));
          while (rs2.next()) {
            referenceIds.add(rs2.getInt("citedid"));
          }
          rp.setReferenceIds(referenceIds);
        }
      }
      return rp;
    } catch (SQLException e) {
      e.printStackTrace();
    } catch (Throwable e) {
      e.printStackTrace();
    } finally {
      ConnectionPool.close(conn);
    }
    return null;
  }
  public static HashMap<Integer, ReviewerPubCitation> getReviewerPubCitationAll() {
    Connection conn = null;
    PreparedStatement ps = null;
    String query = null;
    ResultSet rs = null;

    ReviewerPubCitation rp = null;

    HashMap<Integer, ReviewerPubCitation> citationNetworkMap =
        new HashMap<Integer, ReviewerPubCitation>();

    try {
      conn = pool.getConnection();

      query = "SELECT id, title, authors from " + rr_pub;
      ps = conn.prepareStatement(query);
      rs = ps.executeQuery();
      while (rs.next()) {
        rp = new ReviewerPubCitation();
        rp.setPubId(rs.getInt("id"));
        rp.setTitle(rs.getString("title"));
        rp.setAuthorStr(rs.getString("authors"));
        citationNetworkMap.put(rp.getPubId(), rp);
      }

      query = "SELECT citeid, citedid from " + rr_citation;
      ps = conn.prepareStatement(query);
      rs = ps.executeQuery();
      Integer citeid = null;
      Integer citedid = null;
      while (rs.next()) {
        citeid = rs.getInt("citeid");
        citedid = rs.getInt("citedid");
        rp = citationNetworkMap.get(citeid);
        rp.getReferenceIds().add(citedid);
        rp = citationNetworkMap.get(citedid);
        rp.getCitationIds().add(citeid);
      }
      return citationNetworkMap;

    } catch (SQLException e) {
      e.printStackTrace();
    } catch (Throwable e) {
      e.printStackTrace();
    } finally {
      ConnectionPool.close(conn);
    }
    return null;
  }
  public static List<ReviewerPubCitation> getReviewerPubCitationByID(List<Integer> pids) {
    Connection conn = null;
    PreparedStatement ps = null;
    ReviewerPubCitation rp = null;
    List<Integer> citationIds = null;
    List<Integer> referenceIds = null;
    List<ReviewerPubCitation> rps = new ArrayList<ReviewerPubCitation>();
    try {
      conn = pool.getConnection();
      String query = "SELECT id, title, authors from " + rr_pub + " where id in (";
      for (int i = 0; i < pids.size(); i++) {
        if (i < pids.size() - 1) {
          query += String.valueOf(pids.get(i)) + ",";
        } else {
          query += String.valueOf(pids.get(i));
        }
      }
      query += ")";
      ps = conn.prepareStatement(query);
      ResultSet rs1 = ps.executeQuery();
      ResultSet rs2 = null;
      while (rs1.next()) {
        rp = new ReviewerPubCitation();
        rp.setPubId(rs1.getInt("id"));
        rp.setTitle(rs1.getString("title"));
        rp.setAuthorStr(rs1.getString("authors"));

        query = "SELECT citeid from " + rr_citation + " where citedid = ?";
        ps = conn.prepareStatement(query);
        ps.setInt(1, rp.getPubId());
        rs2 = ps.executeQuery();
        if (rs2.next()) {
          citationIds = new ArrayList<Integer>();
          citationIds.add(rs2.getInt("citeid"));
          rp.setCitationIds(citationIds);
          while (rs2.next()) {
            citationIds.add(rs2.getInt("citeid"));
          }
          rp.setCitationIds(citationIds);
        }

        query = "SELECT citedid from " + rr_citation + " where citeid = ?";
        ps = conn.prepareStatement(query);
        ps.setInt(1, rp.getPubId());
        rs2 = ps.executeQuery();
        if (rs2.next()) {
          referenceIds = new ArrayList<Integer>();
          referenceIds.add(rs2.getInt("citedid"));
          while (rs2.next()) {
            referenceIds.add(rs2.getInt("citedid"));
          }
          rp.setReferenceIds(referenceIds);
        }
        rps.add(rp);
      }
      if (rps.size() > 0) {
        return rps;
      } else {
        return null;
      }
    } catch (SQLException e) {
      e.printStackTrace();
    } catch (Throwable e) {
      e.printStackTrace();
    } finally {
      ConnectionPool.close(conn);
    }
    return null;
  }
Esempio n. 4
0
  public static void main(String args[]) {

    ReviewerSearchByCitation.citationNetworkMap = ReviewerCitationDao.getReviewerPubCitationAll();
    ReviewerSearchByCitation.personMap = ReviewerPersonDao.getReviewerPersonAll();

    DataLoader4ADMA loader = DataLoader4ADMA.getInstance();
    List<ReviewerPaper> rpList = loader.getReviewerPaperFullTextData();

    if (rpList != null) {
      ReviewerPubCitation rpc = null;
      List<Integer> referenceIds = null;
      ReviewerSearchByCitation rSearch = null;
      String authorStr = null, titleStr = null;

      StringBuilder sb = new StringBuilder();
      File f =
          new File("E:/1-Tsinghua/Reviewer Recommendation/Experiments/FCS/ReviewersForFCS.txt");
      FileWriter fw = null;

      for (ReviewerPaper rp : rpList) { // for each reviewing paper
        System.out.println("--------------------------------------------------------------");
        System.out.println("Begin to process paper: " + rp.getTitle());
        referenceIds = new ArrayList<Integer>();
        for (CitedPaper cp : rp.getCiteList()) { // for each reference
          authorStr = cp.getAuthorDefault();
          titleStr = cp.getTitleDefault();
          if (authorStr != null && titleStr != null) {
            rpc = ReviewerSearchByCitation.MatchReviewerPub(authorStr, titleStr);
            if (rpc != null) {
              referenceIds.add(rpc.getPubId());
            }
          }
        }

        rp.setReferenceIds(referenceIds);
        rp.setR_old((double) ReviewerSearchByCitation.citationNetworkMap.size());
        rSearch =
            new ReviewerSearchByCitation(
                rp, 0.90, 0.001 * ReviewerSearchByCitation.citationNetworkMap.size());
        rSearch.RandomWalkWithRestarts();
        rSearch.ReviewerScore();
        List<Pair<Integer, Double>> rank = rSearch.ReviewerRank();
        sb.setLength(0);
        sb.append(rp.getTitle() + ":\r\n");
        for (int i = 0; i < 100; i++) {
          sb.append("(" + String.valueOf(i + 1) + ")\t ID: " + rank.get(i).getKey().toString());
          sb.append(";\t Score:" + rank.get(i).getValue().toString());
          sb.append(
              ";\t Name:"
                  + ReviewerSearchByCitation.personMap.get(rank.get(i).getKey()).getName()
                  + "\r\n");
        }
        sb.append("\r\n");
        try {
          fw = new FileWriter(f, true);
          fw.write(sb.toString());
          System.out.println(sb.toString());
          fw.flush();
          fw.close();
        } catch (IOException e) {
          e.printStackTrace();
        }

        ReviewerSearchByCitation.ClearCitationScore();
        ReviewerSearchByCitation.ClearPersonScore();
        System.out.println("Processing is end: " + rp.getTitle());
        System.out.println("--------------------------------------------------------------");
      }
    }
  }