This repository contains a tool for extracting knowledge graph schema fragments connected to one or more chosen classes via SPARQL endpoint. Once the fragment is extracted, its classes are saved to classes.json.
The easiest way to run the extractor is using Node.js.
After Node.js is installed, run npm istall to install dependencies.
Then run node fragmentFromEndpoint.mjs to start fragment extraction.
Parameters can be changed in fragmentFromEndpoint.mjs before running the extractor.
Parameters include:
mainClasses- a list of classes (class IRIs) around which to extract the schema fragment.fragmentClassCount- desired size of fragment (number of classes).alpha- damping factor for PageRank (only needed if the algorithm "limited-ppr" is used).tol- epsillon for PageRank (only needed if the algorithm "limited-ppr" is used).endpoint- SPARQL endpoint to query.adjLimit- maximum number of class-property-class relations of each property direction (where class is subject or object) to examine for each class. Used to prevent insignificant relations comsuming a lot of time.bothDirections- change how edge weights are calculated.trueto use both classes of an edge for weight calculation.falseto use only the first (the one for which adj is being calculated).weightByCPCsum- change how edge weights are calculated.trueto use total cpc count for edge weight calculation.falseto use class instance count.algorithm- which algorithm to use for fragment extraction. Options:"trivial","heuristic","limited-ppr". The trivial algorithm is by far the fastest but only includes direct neighbors of the main classes in the fragment. The heuristic algorithm and Limited PPR are similar in terms of fragment extraction time and results; both also include further connected classes.excludeEquivalent- whether to exclude duplicate equivalent classes from adjacency list (e.g. only include Person or NaturalPerson but not both). Very time-consuming as it queries SPARQL endpoint for each pairs of neighbors.excludeSubSuper- whether to exclude subclasses and superclasses from adjacency list if one of them is already included (e.g. if Person is included do not include Animal). Very time-consuming as it queries SPARQL endpoint for each pairs of neighbors. If used in combination withexcludeEquivalent, some sub-/superclasses may still be included.limit- maximum concurrency (how many queries can be run at the same time). Check limits of your chosen SPARQL endpoint to decide the value.saveAdjCnt,saveClassSizes,saveEquivalentGroups- whether to save various types of information found from queries to files. When fragments are being extracted in the future,adjCntandclassSizescan be read from the files to reduce the number of queries needed.