This repository has been archived by the owner on Nov 18, 2019. It is now read-only.
-
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.
- Loading branch information
Showing
8 changed files
with
5,737 additions
and
222 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 |
---|---|---|
|
@@ -65,3 +65,6 @@ lib/ | |
|
||
# Secret files | ||
token.txt | ||
|
||
# Useless format files | ||
data/*.xlsx |
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
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,51 @@ | ||
#!/usr/bin/env node | ||
/* eslint-disable no-console */ | ||
|
||
const csv = require('csv-string'); | ||
const { promises } = require('fs'); | ||
const { difference, intersection } = require('ramda'); | ||
const { depleteString } = require('../lib/strings'); | ||
const { isIn } = require('../lib/rnsr'); | ||
const RNSR = require('../data/RNSR.json'); | ||
|
||
promises | ||
.readFile(`${__dirname}/../data/2014_AdressesCorpusTest.tsv`, { | ||
encoding: 'utf8', | ||
}) | ||
.then((tsv) => csv.parse(tsv, '\t')) | ||
.then((lines) => { | ||
console.log('found\texpected\taddress'); | ||
const rnsrAddresses = lines.slice(1); | ||
let expectedNb = 0; | ||
const { foundNb, wronglyFoundNb } = rnsrAddresses.reduce(({ | ||
foundNb: alreadyFound, | ||
wronglyFoundNb: alreadyWronglyFound, | ||
}, rnsrAddress) => { | ||
const depletedAddress = depleteString(rnsrAddress[1]); | ||
const isInAddress = isIn(depletedAddress); | ||
const rnsrIds = RNSR.structures.structure | ||
.filter(isInAddress) | ||
.map((s) => s.num_nat_struct); | ||
|
||
const expectedIds = rnsrAddress[0].split(' ; '); | ||
expectedNb += expectedIds.length; | ||
|
||
const foundIds = intersection(rnsrIds, expectedIds); | ||
if (foundIds.length < expectedIds.length) { | ||
console.log(`${rnsrIds}\t${expectedIds}\t${depletedAddress}`); | ||
} | ||
const wronglyFoundIds = difference(rnsrIds, expectedIds); | ||
return { | ||
foundNb: alreadyFound + foundIds.length, | ||
wronglyFoundNb: alreadyWronglyFound + wronglyFoundIds.length, | ||
}; | ||
}, { foundNb: 0, wronglyFoundNb: 0 }); | ||
const recall = foundNb / expectedNb; | ||
console.log('recall:', recall); | ||
console.log('found:', foundNb); | ||
console.log('total:', expectedNb); | ||
const precision = foundNb / (foundNb + wronglyFoundNb); | ||
console.log('precision:', precision); | ||
console.log('wrongs:', wronglyFoundNb); | ||
console.log('total found:', foundNb + wronglyFoundNb); | ||
}); |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.