/**
   * abnerNER would analyze words and give confidence
   *
   * @param args sentences to be processed
   * @param arg0 information input
   * @throws AnalysisEngineProcessException
   */
  public static void abnerNER(String[] args, JCas arg0) {

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

    /** use abner to find gene names from words */
    Tagger t = new Tagger();
    for (int i = 1; i < args.length; ++i) {
      String s = args[i];
      String[][] ents = t.getEntities(s);

      /** use HashMap to store words selected by Abner */
      for (int j = 0; j < ents[0].length; j++) {
        ConfMap.put(ents[0][j], 1.0);
      }
    }

    // TODO Auto-generated method stub
    FSIterator<org.apache.uima.jcas.tcas.Annotation> ite =
        arg0.getAnnotationIndex(NameTag.type).iterator();

    while (ite.hasNext()) {
      /** get the words selected by LingPipe */
      String name = ((NameTag) ite.get()).getText();

      /** set the confidence for words selected by both LingPipe and Abner as 1 */
      if (ConfMap.containsKey(name)) {
        ((NameTag) ite.get()).setConfidenceAbner(1.0);
      } else {
        ((NameTag) ite.get()).setConfidenceAbner(0.0);
      }
      ite.next();
    }
  }
Example #2
0
  public static final void createPost(Post post) {
    Connection connection = null;
    PreparedStatement stmt = null;
    String sql =
        "INSERT INTO post ("
            + Post.LUSER_ID
            + ","
            + Post.LINK
            + " ,"
            + Post.BODY
            + ","
            + Post.MIME
            + ") VALUES ( ?, ?, ?, ? ) RETURNING id";
    try {
      connection = DBConnection.getConnection();
      stmt = connection.prepareStatement(sql);
      stmt.setString(1, post.getUser_id());
      stmt.setString(2, (post.getLink() != null) ? post.getLink().toString() : "null");
      stmt.setString(3, post.getBody());
      stmt.setString(4, post.getMime());
      ResultSet id = stmt.executeQuery();
      id.next();
      Logger.getLogger(PostMapper.class.getName())
          .log(Level.SEVERE, "post number " + id.getInt("id"));
      if (post.getTags() != null) {
        post.setId(id.getInt("id"));
        Tagger.tagAs(post);
      }
      stmt.close();
    } catch (SQLException ex) {
      Logger.getLogger(PostMapper.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      if (stmt != null)
        try {
          stmt.close();
        } catch (SQLException e1) {
          e1.printStackTrace();
        }

      if (connection != null) {
        try {
          connection.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }
  }
Example #3
0
 String tagFor(final String str, final String fallback) {
   return tagger.tagFor(str, fallback);
 }