-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR introduces logic which labels entities with their DBpedia ontological classes. Using this logic, it creates a file which tags every unique entity found for the AI map dataset with their respective classes. closes #120
- Loading branch information
Showing
5 changed files
with
150 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { promises as fs } from 'fs'; | ||
|
||
import { Command, InvalidArgumentError } from 'commander'; | ||
import * as _ from 'lamb'; | ||
|
||
import { arxliveCopy } from 'conf/config.mjs'; | ||
import { getClasses } from 'dbpedia/requests.mjs'; | ||
import { getEntities } from 'es/entities.mjs'; | ||
|
||
const program = new Command(); | ||
program.option( | ||
'-d, --domain <domain>', | ||
'ES domain on which to aggregate', | ||
arxliveCopy | ||
); | ||
program.option('-i, --index <index>', 'ES index from which to get titles'); | ||
program.option('-f, --path <path>', 'Path to file containing DBpedia titles'); | ||
program.requiredOption('-o, --out <output>', 'Path of output file'); | ||
|
||
program.parse(); | ||
const options = program.opts(); | ||
|
||
const main = async () => { | ||
if (!options.index && !options.path) { | ||
throw new InvalidArgumentError(` | ||
You must specify either the index containing the DBpedia entities | ||
or a path to the file containing the entities\' titles` | ||
); | ||
} | ||
if (options.index && options.path) { | ||
throw new InvalidArgumentError(` | ||
Ambigous input. Do you want to use the index or the file as input?` | ||
); | ||
} | ||
|
||
// previous checks garauntee the following: | ||
const titles = options.index | ||
? await getEntities(options.index) | ||
: JSON.parse(await fs.readFile(options.path)); | ||
|
||
const sample=titles.slice(100, 110); | ||
console.log(sample); | ||
console.log(await getClasses(sample, { depth: 10, squash: true, fullURI:true })); | ||
|
||
}; | ||
|
||
main(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.