Guest User

Untitled

a guest
Jun 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. import org.jdom.*;
  2. import org.jdom.input.SAXBuilder;
  3. import org.jdom.xpath.XPath;
  4.  
  5. import java.io.IOException;
  6. import java.util.List;
  7.  
  8. public class bars {
  9.  
  10.  
  11. public void toon(){
  12. SAXBuilder parser = new SAXBuilder();
  13. Document document = null;
  14. try {
  15. /*OEFENING 1
  16. document = parser.build("./bars.xml");
  17. XPath xPath = XPath.newInstance("//y-axis-title"); oef 1.1
  18. XPath xPath = XPath.newInstance("//bars/bar[@number = 4]");
  19. XPath xPath = XPath.newInstance("//bar[@number = 5]");
  20. */
  21.  
  22. /*OEFENING 2
  23. document = parser.build("./moreover.xml");
  24. XPath xPath = XPath.newInstance("//article[@code = 13549014]/harvest_time");
  25. */
  26.  
  27. document = parser.build("./informationgain.xml");
  28.  
  29. /* OEFENING 3
  30. XPath xPath = XPath.newInstance("//n-gram[@frequency < 10]");
  31. XPath xPath = XPath.newInstance("//n-gram[@frequency < 10 and @gain > 0.5]");
  32. XPath xPath = XPath.newInstance("//n-gram[contains(.,'=') ]")
  33. XPath xPath = XPath.newInstance("//n-gram[string-length()>10 ]");*/
  34. XPath xPath = XPath.newInstance("//n-gram[substring(.,1,2)='de' ]");
  35. List<Element> elements = xPath.selectNodes(document);
  36.  
  37. System.out.println(elements.size());
  38. for(Element element : elements){
  39. System.out.println(element.getValue());
  40. }
  41. } catch (JDOMException e) {
  42. System.out.println("");
  43. } catch (IOException e) { }
  44. System.out.println("");
  45. }
  46.  
  47.  
  48. }
Add Comment
Please, Sign In to add comment