Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static HashMap<String,List<Table_token>> getHashMapFromTokenTable() throws SQLException, Exception{
- DbAccess.initConnection();
- List<Table_token> listFrom_token = new ArrayList();
- HashMap<String,List<Table_token>> hMapIdPath = new HashMap<String,List<Table_token>>();
- String query = "select * from token";
- resultSet = getResultSetByQuery(query);
- while(resultSet.next()){
- String token=resultSet.getString(3);
- String path=resultSet.getString(4);
- String word=resultSet.getString(5);
- String lemma=resultSet.getString(6);
- String postag=resultSet.getString(7);
- String isTerminal=resultSet.getString(8);
- Table_token t_token = new Table_token();
- t_token.setIdToken(token);
- t_token.setIdPath(path);
- t_token.setWord(word);
- t_token.setLemma(lemma);
- t_token.setPosTag(postag);
- t_token.setIsTerminal(isTerminal);
- listFrom_token.add(t_token);
- System.out.println("path "+path+" path2: "+token);
- int row = resultSet.getRow();
- if(resultSet.next()){
- if((resultSet.getString(4).compareTo(path)!=0)){
- hMapIdPath.put(path, listFrom_token);
- listFrom_token.clear();
- }
- resultSet.absolute(row);
- }
- if(resultSet.isLast()){
- hMapIdPath.put(path, listFrom_token);
- listFrom_token.clear();
- }
- }
- DbAccess.closeConnection();
- return hMapIdPath;
- }
- mysql> select * from token where idpath='p000003361';
- +---------+------------+----------------------+------------+
- | idDoc | idSentence | idToken | idPath |
- +---------+------------+----------------------+------------+
- | d000095 | s000000048 | t0000000000000019231 | p000003361 |
- | d000095 | s000000048 | t0000000000000019232 | p000003361 |
- | d000095 | s000000048 | t0000000000000019233 | p000003361 |
- +---------+------------+----------------------+------------+
- 3 rows in set (0.04 sec)
- listFrom_token.clear();
- listFrom_token = new ArrayList<Table_token>();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement