- Timestamp:
- 10/08/08 13:59:53 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/greenstone/Greenstone3Connection.java
r313 r352 17 17 import java.util.Set; 18 18 19 import org.apache.xerces.parsers.DOMParser;19 //import org.apache.xerces.parsers.DOMParser; 20 20 import org.w3c.dom.Document; 21 21 import org.w3c.dom.NamedNodeMap; … … 425 425 StringReader sr = new StringReader(result); 426 426 InputSource is = new InputSource(sr); 427 DOMParser p = new DOMParser(); 428 429 try { 430 p.parse(is); 431 } catch (SAXException se) { 432 System.err.println(se); 433 } catch (IOException ioe) { 434 System.err.println(ioe); 435 } 436 Document d = p.getDocument(); 437 NodeList metadataList = d.getElementsByTagName("metadata"); 438 for (int i = 0; i < metadataList.getLength(); i++) { 439 Node n = metadataList.item(i); 440 NamedNodeMap nnm = n.getAttributes(); 441 Node att = nnm.getNamedItem("name"); 442 if (att.getNodeValue().compareTo("numDocsMatched") == 0) { 443 queryOutcome.setHowManyDocsMatched(n.getFirstChild() 444 .getNodeValue()); 445 } else if (att.getNodeValue().compareTo("numDocsReturned") == 0) { 446 queryOutcome.setHowManyDocsReturned(n.getFirstChild() 447 .getNodeValue()); 448 } 449 } 450 451 NodeList documentList = d.getElementsByTagName("documentNode"); 452 for (int i = 0; i < documentList.getLength(); i++) { 453 Node n = documentList.item(i); 454 NamedNodeMap nnm = n.getAttributes(); 455 Node nid = nnm.getNamedItem("nodeID"); 456 Node nscore = nnm.getNamedItem("rank"); 457 String docID = nid.getFirstChild().getNodeValue(); 458 queryOutcome.addResult(docID, firstDoc + i, nscore.getFirstChild() 459 .getNodeValue()); 460 } 461 query.addQueryOutcome(queryOutcome); 462 Query q = (Query) query.clone(); 463 queryList.add(q); 464 465 for (int i = 0; i < documentList.getLength(); i++) { 466 Node n = documentList.item(i); 467 NamedNodeMap nnm = n.getAttributes(); 468 Node nid = nnm.getNamedItem("nodeID"); 469 Node nscore = nnm.getNamedItem("rank"); 470 String docID = nid.getFirstChild().getNodeValue(); 471 472 QueryContext queryContext = new QueryContext(firstDoc + i, nscore 473 .getFirstChild().getNodeValue(), q); 474 if (allResults.containsKey(docID)) { 475 ResultDocument resultDocument = (ResultDocument) allResults 476 .get(docID); 477 resultDocument.incrementFrequencyReturned(); 478 resultDocument.addQueryContext(queryContext); 479 allResults.put(docID, resultDocument); 480 } else { 481 ResultDocument resultDocument = new ResultDocument(); 482 resultDocument.addQueryContext(queryContext); 483 allResults.put(docID, resultDocument); 484 } 485 } 486 return queryOutcome; 427 428 429 430 431 432 433 434 435 436 437 return null; 438 439 // DOMParser p = new DOMParser(); 440 // 441 // try { 442 // p.parse(is); 443 // } catch (SAXException se) { 444 // System.err.println(se); 445 // } catch (IOException ioe) { 446 // System.err.println(ioe); 447 // } 448 // Document d = p.getDocument(); 449 // NodeList metadataList = d.getElementsByTagName("metadata"); 450 // for (int i = 0; i < metadataList.getLength(); i++) { 451 // Node n = metadataList.item(i); 452 // NamedNodeMap nnm = n.getAttributes(); 453 // Node att = nnm.getNamedItem("name"); 454 // if (att.getNodeValue().compareTo("numDocsMatched") == 0) { 455 // queryOutcome.setHowManyDocsMatched(n.getFirstChild() 456 // .getNodeValue()); 457 // } else if (att.getNodeValue().compareTo("numDocsReturned") == 0) { 458 // queryOutcome.setHowManyDocsReturned(n.getFirstChild() 459 // .getNodeValue()); 460 // } 461 // } 462 // 463 // NodeList documentList = d.getElementsByTagName("documentNode"); 464 // for (int i = 0; i < documentList.getLength(); i++) { 465 // Node n = documentList.item(i); 466 // NamedNodeMap nnm = n.getAttributes(); 467 // Node nid = nnm.getNamedItem("nodeID"); 468 // Node nscore = nnm.getNamedItem("rank"); 469 // String docID = nid.getFirstChild().getNodeValue(); 470 // queryOutcome.addResult(docID, firstDoc + i, nscore.getFirstChild() 471 // .getNodeValue()); 472 // } 473 // query.addQueryOutcome(queryOutcome); 474 // Query q = (Query) query.clone(); 475 // queryList.add(q); 476 // 477 // for (int i = 0; i < documentList.getLength(); i++) { 478 // Node n = documentList.item(i); 479 // NamedNodeMap nnm = n.getAttributes(); 480 // Node nid = nnm.getNamedItem("nodeID"); 481 // Node nscore = nnm.getNamedItem("rank"); 482 // String docID = nid.getFirstChild().getNodeValue(); 483 // 484 // QueryContext queryContext = new QueryContext(firstDoc + i, nscore 485 // .getFirstChild().getNodeValue(), q); 486 // if (allResults.containsKey(docID)) { 487 // ResultDocument resultDocument = (ResultDocument) allResults 488 // .get(docID); 489 // resultDocument.incrementFrequencyReturned(); 490 // resultDocument.addQueryContext(queryContext); 491 // allResults.put(docID, resultDocument); 492 // } else { 493 // ResultDocument resultDocument = new ResultDocument(); 494 // resultDocument.addQueryContext(queryContext); 495 // allResults.put(docID, resultDocument); 496 // } 497 // } 498 // return queryOutcome; 487 499 } 488 500 … … 554 566 StringReader sr = new StringReader(result); 555 567 InputSource is = new InputSource(sr); 556 DOMParser p = new DOMParser();557 try {558 p.parse(is);568 //DOMParser p = new DOMParser(); 569 /* try { 570 //p.parse(is); 559 571 } catch (SAXException se) { 560 572 System.err.println(se); 561 573 } catch (IOException ioe) { 562 574 System.err.println(ioe); 563 } 564 Document d = p.getDocument(); 575 }*/ 576 //Document d = p.getDocument(); 577 Document d = null; 565 578 NodeList metadataList = d.getElementsByTagName("metadata"); 566 579 String metadataval = null; … … 690 703 StringReader sr = new StringReader(result); 691 704 InputSource is = new InputSource(sr); 692 DOMParser p = new DOMParser();693 try {694 p.parse(is);695 } catch (SAXException se) {696 System.err.println(se);697 } catch (IOException ioe) {698 System.err.println(ioe);699 }705 // DOMParser p = new DOMParser(); 706 // try { 707 // p.parse(is); 708 // } catch (SAXException se) { 709 // System.err.println(se); 710 // } catch (IOException ioe) { 711 // System.err.println(ioe); 712 // } 700 713 701 714 String returnName = null; 702 715 703 Document d = p.getDocument(); 716 //Document d = p.getDocument(); 717 Document d = null; 704 718 NodeList metadataList = d.getElementsByTagName("metadata"); 705 719 for (int i = 0; i < metadataList.getLength(); i++) { … … 736 750 StringReader sr = new StringReader(result); 737 751 InputSource is = new InputSource(sr); 738 DOMParser p = new DOMParser();739 try {740 p.parse(is);741 } catch (SAXException se) {742 System.err.println(se);743 } catch (IOException ioe) {744 System.err.println(ioe);745 }746 Document d = p.getDocument();747 752 // DOMParser p = new DOMParser(); 753 // try { 754 // p.parse(is); 755 // } catch (SAXException se) { 756 // System.err.println(se); 757 // } catch (IOException ioe) { 758 // System.err.println(ioe); 759 // } 760 // Document d = p.getDocument(); 761 Document d = null; 748 762 NodeList childList = d.getElementsByTagName("classifierNode"); 749 763 NodeList documentList = d.getElementsByTagName("documentNode");
Note:
See TracChangeset
for help on using the changeset viewer.