Mitko_jos

za Filip vbs lab1 od 18 do 26

Oct 25th, 2015
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. //ova ti e od 18 do 26
  2.  
  3. static final String inputFileName = "C:\\Users\\Mitko\\Documents\\lab1_vbs\\hifm-dataset.ttl";
  4. static String MitkoJosifoskiUri="http://somewhere/MitkoJosifoski";
  5.  
  6. public static void main(String[] args) {
  7.  
  8. Model model = ModelFactory.createDefaultModel();
  9.  
  10. InputStream in = FileManager.get().open(inputFileName);
  11. if (in == null) {
  12. throw new IllegalArgumentException("File not found.");
  13. }
  14.  
  15. model.read(in, "", "TTL");
  16.  
  17. String himfOntPrefix="http://purl.org/net/hifm/ontology#";
  18. String resurs = "http://purl.org/net/hifm/data#37737";
  19. String similar = himfOntPrefix + "similarTo";
  20. String priceWat = himfOntPrefix + "refPriceWithVAT";
  21.  
  22. Resource r1 = model.getResource(resurs);
  23. Property cenaProperty = model.getProperty(priceWat);
  24.  
  25. Statement stm = r1.getProperty(RDFS.label);
  26. System.out.println("GO RAZLEDUVAME LEKOT " + stm.getObject().toString());
  27. Statement stm2 = r1.getProperty(cenaProperty);
  28. System.out.println("Cena: " + stm2.getObject().toString());
  29.  
  30.  
  31. Property p1 = model.getProperty(similar);
  32.  
  33. StmtIterator l1 = r1.listProperties(p1);
  34. while(l1.hasNext()) {
  35. Statement s1 = l1.nextStatement();
  36. String drugLek = s1.getObject().toString();
  37. Resource r2 = model.getResource(drugLek);
  38.  
  39.  
  40. Statement stm3 = r2.getProperty(RDFS.label);
  41. System.out.println("GO RAZLEDUVAME LEKOT " + stm3.getSubject().toString() + " - " + stm3.getObject().toString());
  42. Statement stm4 = r2.getProperty(cenaProperty);
  43. System.out.println("Cena: " + stm4.getObject().toString());
  44. }
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment