Skip to content

Commit

Permalink
Merge pull request #347 from spencermountain/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
spencermountain authored Mar 29, 2020
2 parents 4e93108 + 3a14e13 commit 2cafa91
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 21 deletions.
15 changes: 12 additions & 3 deletions builds/wtf_wikipedia-client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion builds/wtf_wikipedia-client.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion builds/wtf_wikipedia-client.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion builds/wtf_wikipedia-client.mjs

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions builds/wtf_wikipedia.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* wtf_wikipedia 8.1.0 MIT */
/* wtf_wikipedia 8.1.1 MIT */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('https')) :
typeof define === 'function' && define.amd ? define(['https'], factory) :
Expand Down Expand Up @@ -3893,6 +3893,7 @@
};

var skipSpanRow = function skipSpanRow(row) {
row = row || [];
var len = row.length;
var hasTxt = row.filter(function (str) {
return str;
Expand Down Expand Up @@ -3998,7 +3999,15 @@
.split(/\n/).map(function (l) {
return l.trim();
});
var rows = _findRows(lines); //remove non-header span rows
var rows = _findRows(lines);
rows = rows.filter(function (r) {
return r;
});

if (rows.length === 0) {
return [];
} //remove non-header span rows


rows = removeMidSpans(rows); //support colspan, rowspan...

Expand Down Expand Up @@ -8797,7 +8806,7 @@

var category = fetchCategory;

var _version = '8.1.0';
var _version = '8.1.1';

var wtf = function wtf(wiki, options) {
return _01Document(wiki, options);
Expand Down
15 changes: 12 additions & 3 deletions builds/wtf_wikipedia.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* wtf_wikipedia 8.1.0 MIT */
/* wtf_wikipedia 8.1.1 MIT */
import https from 'https';

var parseUrl = function parseUrl(url) {
Expand Down Expand Up @@ -3887,6 +3887,7 @@ var cleanText = function cleanText(str) {
};

var skipSpanRow = function skipSpanRow(row) {
row = row || [];
var len = row.length;
var hasTxt = row.filter(function (str) {
return str;
Expand Down Expand Up @@ -3992,7 +3993,15 @@ var parseTable = function parseTable(wiki) {
.split(/\n/).map(function (l) {
return l.trim();
});
var rows = _findRows(lines); //remove non-header span rows
var rows = _findRows(lines);
rows = rows.filter(function (r) {
return r;
});

if (rows.length === 0) {
return [];
} //remove non-header span rows


rows = removeMidSpans(rows); //support colspan, rowspan...

Expand Down Expand Up @@ -8791,7 +8800,7 @@ var fetchCategory = function fetchCategory(category, lang, options) {

var category = fetchCategory;

var _version = '8.1.0';
var _version = '8.1.1';

var wtf = function wtf(wiki, options) {
return _01Document(wiki, options);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wtf_wikipedia",
"description": "parse wikiscript into json",
"version": "8.1.0",
"version": "8.1.1",
"author": "Spencer Kelly <[email protected]> (http://spencermounta.in)",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion plugins/classify/src/byInfobox/infoboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ module.exports = {
nfl_single_game: 'Event/SportsEvent', //1
nobility: 'Organization', //5
non_test_cricket_team: 'Organization/SportsTeam', //4
'non-profit': 'SportsTeam', //6
'non-profit': 'Organization/SportsTeam', //6
nrhp: '', //144
nycs: '', //7
officeholder: 'Person', //133
Expand Down
2 changes: 1 addition & 1 deletion plugins/classify/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const plugin = function(models) {

// dont classify these
if (skipPage(doc, options)) {
return null
return score(res, options)
}

//look for 'infobox person', etc
Expand Down
3 changes: 1 addition & 2 deletions plugins/classify/src/score.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ const getScore = function(detail) {
score *= 0.8
}
}

return {
root: root,
category: category,
score: score,
score: Math.ceil(score),
detail: detail
}
}
Expand Down
11 changes: 8 additions & 3 deletions scratch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ wtf.extend(require('./plugins/i18n/src'))
wtf.extend(require('./plugins/summary/src'))
wtf.extend(require('./plugins/category/src'))

// wtf.fetch('Toronto').then(doc => {
// let html = doc.html()
// console.log(html)
// wtf.fetch('Croatian language').then(doc => {
// console.log(doc.tables().map(t => t.json()))
// // let html = doc.html()
// // console.log(html)
// })

// wtf.fetchCategory('Larchmont, New York').then(res => {
Expand All @@ -28,3 +29,7 @@ wtf.extend(require('./plugins/category/src'))
// let doc = wtf(txt)
// let res = doc.classify()
// console.log(res)
let str = `
`
let doc = wtf(str)
console.log(doc.table())
2 changes: 1 addition & 1 deletion src/_version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = '8.1.0'
module.exports = '8.1.1'
5 changes: 5 additions & 0 deletions src/table/parse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const cleanText = function(str) {
}

const skipSpanRow = function(row) {
row = row || []
let len = row.length
let hasTxt = row.filter(str => str).length
//does it have 3 empty spaces?
Expand Down Expand Up @@ -127,6 +128,10 @@ const parseTable = function(wiki) {
.split(/\n/)
.map(l => l.trim())
let rows = findRows(lines)
rows = rows.filter(r => r)
if (rows.length === 0) {
return []
}

//remove non-header span rows
rows = removeMidSpans(rows)
Expand Down

0 comments on commit 2cafa91

Please sign in to comment.