Difference between revisions of "XSearchLink Specification"
Line 2: | Line 2: | ||
Client examples (Java code) of how to use X-Link can be found here: | Client examples (Java code) of how to use X-Link can be found here: | ||
− | https://gcube.wiki.gcube-system.org/gcube/index.php/X | + | https://gcube.wiki.gcube-system.org/gcube/index.php/X-Link |
= Client Example = | = Client Example = |
Latest revision as of 13:29, 18 February 2014
This is a draft specification of X-Link.
Client examples (Java code) of how to use X-Link can be found here: https://gcube.wiki.gcube-system.org/gcube/index.php/X-Link
Client Example
EntityMiningComponent emc = new GateEntityMiningComponent("component_path_folder");
emc.startup(); // load entity mining tool, the categories that already exist, etc.
emc.printAvailableCategories();
XLink xlink = new XLink();
xlink.setEntityMiningComponent(emc);
HashSet<String> acceptedCategoryNames = new HashSet<String>();
acceptedCategoryNames.add("Species");
acceptedCategoryNames.add("WaterAreas");
TextExtractor extractor = new WebPageTextExtractor("http://en.wikipedia.org/wiki/Fisheries");
String content = extractor.extractText();
xlink.retrieveEntities(content, acceptedCategoryNames);
xlink.matchEntities();
ArrayList<Entity> entities = xlink.getEntities();
for (Entity entity : entities) {
System.out.println("Entity name: " + entity.getName());
System.out.println("Category: " + entity.getCategoryName());
System.out.println("Matching URIs: " + entity.getMatchingURIs());
System.out.println("-----");
}
xlink.storeMatchings(new File("folder_path"), "filename");
emc.shutdown(); // free memory
// add a new category to the component //
emc.startup();
emc.addNewCategory("shark", "url_of_sparql_endpoint", "uri_of_resource_class"); // throws CategoryAlreadyExistException, NotASparqlEndpointException, NotAURIException
acceptedCategoryNames.add("shark");
xlink.retrieveEntities(content, acceptedCategoryNames);
xlink.matchEntities();
ArrayList<Entity> entities = xlink.getEntities();
emc.shutdown(); // free memory
The 'Entity' Class
String getName ();
String getCategoryName ();
HashSet<String> getMatchingURIs ();
double getRank ();
HashMap<String, String> getProperties ();
void setName (String name);
void setCategoryName (String categoryName);
void setMatchingURIs(HashSet<String> matchingURIs);
void addMatchingURI (String uri);
void setRank (double rank);
void setProperties (HashMap<String, String> properties);
void addProperty (String propertyName, String propertyValue);
The 'Category' Class
void setName (String name);
void setEndpoint (Endpoint endpoint);
void setTemplateQuery (TemplateQuery template);
void setNamedEntities (Set<Entity> entities);
void setResourceClass (URI resourceClass);
void addNamedEntity (Entity entity);
String getName ();
Endpoint getEndpoint ();
TemplateQuery getTemplateQuery ();
Set<Entity> getNamedEntities ();
URI getResourceClass ();
The 'EntityMiningComponent' Class
void startup ();
void shutdown ();
HashSet<Category> getAvailableCategories ();
void addNewCategory (Category category);
void addNewCategory (String categoryName, URL endpoint, URI resourceClass);
void removeCategory (String categoryName);
void printAvailableCategories ();
The 'XLink' Class
void setEntityMiningComponent ();
void retrieveEntities (String content, HashSet<String> acceptedCategoryNames);
void matchEntities ();
File storeMatchings (String filename);
void storeMatchings (File folder, String filename);
void retrieveIncomingProperties ();
void retrieveOutcomingProperties ();
void retrieveAllProperties ();
ArrayList<Entity> getEntities ();