Skip to content

Commit

Permalink
Add longer fixtures when franc supports 200+ languages
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 9, 2014
1 parent 5cb5016 commit 98cfcb1
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion script/build-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@ support = require('../data/support');
customFixtures = require('../data/custom-fixtures');
udhr = require('udhr').json();

/**
* The minimum number of speakers to be included in
* `franc`: 1,000,000.
*/

var THRESHOLD;

if (process.env.THRESHOLD) {
THRESHOLD = Number(process.env.THRESHOLD);
}

if (THRESHOLD !== THRESHOLD || THRESHOLD === undefined) {
THRESHOLD = 1e6;
}

if (THRESHOLD < 1e5) {
console.log(
'Long fixtures will be created, because ' +
'the given threshold (`' + THRESHOLD + '`) ' +
'includes language very similar to others.'
);
} else {
console.log(
'Short fixtures will be created, because ' +
'the given threshold (`' + THRESHOLD + '`) ' +
'does not include languages very similar to ' +
'others.'
);
}

/**
* Get fixtures from UDHR preambles and notes.
*/
Expand Down Expand Up @@ -43,7 +73,7 @@ support.forEach(function (language) {
);
}

fixture = fixture.slice(0, 200);
fixture = fixture.slice(0, THRESHOLD >= 1e5 ? 200 : 500);

data.push(fixture);
});
Expand Down

0 comments on commit 98cfcb1

Please sign in to comment.