Difference between revisions of "XSearchLink Specification"
(Created page with "= Client Example = EntityMiningComponent emc = new EntityMiningComponent(File propertiesFile); emc.startup(); // load entity mining tool, the categories that already exist, et...") |
(→Client Example) |
||
Line 1: | Line 1: | ||
= Client Example = | = Client Example = | ||
− | + | EntityMiningComponent emc = new GateEntityMiningComponent("component_path_folder"); | |
− | EntityMiningComponent emc = new | + | |
emc.startup(); // load entity mining tool, the categories that already exist, etc. | 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>(); | 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"); | ||
Line 38: | Line 45: | ||
+ | |||
+ | // 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 = | = The 'Entity' Class = |
Revision as of 12:47, 16 June 2013
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 getEntityName ();
URI getEntityURI ();
void setEntityURI(URI uri);
The 'Category' Class
void setCategoryName (String name);
void setCategoryEndpoint (Endpoint endpoint);
void setCategoryTemplateQuery (TemplateQuery template);
void setCategoryNamedEntities (Set<Entity> entities);
void setCategoryResourceClass (URI resourceClass);
void addCategoryNamedEntity (Entity entity);
String getCategoryName ();
Endpoint getCategoryEndpoint ();
TemplateQuery getCategoryTemplateQuery ();
Set<Entity> getCategoryNamedEntities ();
URI getCategoryResourceClass ();
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 'XSearchLink' Class
void setEntityMiningComponent ();
Set<Entity> retrieveEntities (Document document, Set<String> acceptedCategoryNames);