Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. public static HashMap<String,List<Table_token>> getHashMapFromTokenTable() throws SQLException, Exception{
  2.  
  3. DbAccess.initConnection();
  4. List<Table_token> listFrom_token = new ArrayList();
  5. HashMap<String,List<Table_token>> hMapIdPath = new HashMap<String,List<Table_token>>();
  6.  
  7. String query = "select * from token";
  8. resultSet = getResultSetByQuery(query);
  9.  
  10. while(resultSet.next()){
  11.  
  12. String token=resultSet.getString(3);
  13. String path=resultSet.getString(4);
  14. String word=resultSet.getString(5);
  15. String lemma=resultSet.getString(6);
  16. String postag=resultSet.getString(7);
  17. String isTerminal=resultSet.getString(8);
  18. Table_token t_token = new Table_token();
  19. t_token.setIdToken(token);
  20. t_token.setIdPath(path);
  21. t_token.setWord(word);
  22. t_token.setLemma(lemma);
  23. t_token.setPosTag(postag);
  24. t_token.setIsTerminal(isTerminal);
  25. listFrom_token.add(t_token);
  26. System.out.println("path "+path+" path2: "+token);
  27. int row = resultSet.getRow();
  28.  
  29. if(resultSet.next()){
  30. if((resultSet.getString(4).compareTo(path)!=0)){
  31. hMapIdPath.put(path, listFrom_token);
  32. listFrom_token.clear();
  33. }
  34. resultSet.absolute(row);
  35.  
  36. }
  37. if(resultSet.isLast()){
  38. hMapIdPath.put(path, listFrom_token);
  39. listFrom_token.clear();
  40. }
  41.  
  42. }
  43.  
  44. DbAccess.closeConnection();
  45.  
  46. return hMapIdPath;
  47.  
  48. }
  49.  
  50. mysql> select * from token where idpath='p000003361';
  51. +---------+------------+----------------------+------------+
  52. | idDoc | idSentence | idToken | idPath |
  53. +---------+------------+----------------------+------------+
  54. | d000095 | s000000048 | t0000000000000019231 | p000003361 |
  55. | d000095 | s000000048 | t0000000000000019232 | p000003361 |
  56. | d000095 | s000000048 | t0000000000000019233 | p000003361 |
  57. +---------+------------+----------------------+------------+
  58. 3 rows in set (0.04 sec)
  59.  
  60. listFrom_token.clear();
  61.  
  62. listFrom_token = new ArrayList<Table_token>();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement