Datasets:
Scholarly articles filter
I parsed this dataset to produce a fully native Parquet version (see collection at https://huggingface.co/collections/permutans/wikidata), which was great but I wanted to try going from the original Wikidata JSON dump itself. The difference between this dataset and the direct Wikidata JSON dump is that this one got "scholarly articles" filtered out.
The dataset card doesn't say precisely how they were filtered out, and I didn't want to assume it was just Q13442814.
I ran a comparison of the IDs from this dataset against those in the latest Wikidata dump and found the following categories which I believe were used to filter out the scholarly articles etc:
shape: (2, 2)
┌─────────┬──────────┐
│ missing ┆ len │
│ --- ┆ --- │
│ bool ┆ u32 │
╞═════════╪══════════╡
│ true ┆ 46440160 │
│ false ┆ 73630157 │
└─────────┴──────────┘ shape: (3, 3)
┌───────┬─────────┬──────────┐
│ new ┆ missing ┆ len │
│ --- ┆ --- ┆ --- │
│ bool ┆ bool ┆ u32 │
╞═══════╪═════════╪══════════╡
│ false ┆ false ┆ 73630157 │
│ false ┆ true ┆ 46440160 │
│ true ┆ true ┆ 1745325 │
└───────┴─────────┴──────────┘
old missing entities with no P31: 714789
Classes by old entities missing:
shape: (60, 5)
┌────────────┬──────────┬──────────┬──────────┬──────────────────────────────────┐
│ p31 ┆ entities ┆ missing ┆ share ┆ label │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ u32 ┆ u32 ┆ f64 ┆ str │
╞════════════╪══════════╪══════════╪══════════╪══════════════════════════════════╡
│ Q13442814 ┆ 45431973 ┆ 45431670 ┆ 0.999993 ┆ scholarly article │
│ Q871232 ┆ 513082 ┆ 512756 ┆ 0.999365 ┆ editorial │
│ Q2782326 ┆ 187464 ┆ 187464 ┆ 1.0 ┆ case report │
│ Q815382 ┆ 109685 ┆ 109685 ┆ 1.0 ┆ meta-analysis │
│ Q187685 ┆ 104180 ┆ 104177 ┆ 0.999971 ┆ doctoral thesis │
│ Q1348305 ┆ 93382 ┆ 93382 ┆ 1.0 ┆ erratum │
│ Q1907875 ┆ 47231 ┆ 47225 ┆ 0.999873 ┆ master's thesis │
│ Q18918145 ┆ 39615 ┆ 39604 ┆ 0.999722 ┆ academic journal article │
│ Q45182324 ┆ 23941 ┆ 23940 ┆ 0.999958 ┆ retracted paper │
│ Q23927052 ┆ 19956 ┆ 19955 ┆ 0.99995 ┆ conference paper │
│ Q591041 ┆ 13209 ┆ 12336 ┆ 0.933909 ┆ scientific publication │
│ Q47461344 ┆ 176126 ┆ 11834 ┆ 0.067191 ┆ written work │
│ Q637866 ┆ 26504 ┆ 11551 ┆ 0.435821 ┆ book review │
│ Q1402850 ┆ 8872 ┆ 8872 ┆ 1.0 ┆ field study report │
│ Q193842 ┆ 7351 ┆ 7004 ┆ 0.952796 ┆ geological map │
│ Q58632367 ┆ 7111 ┆ 6332 ┆ 0.890451 ┆ scholarly conference abstract │
│ Q15781350 ┆ 5340 ┆ 5336 ┆ 0.999251 ┆ final project report │
│ Q1266946 ┆ 5231 ┆ 5229 ┆ 0.999618 ┆ thesis │
│ Q15184295 ┆ 64567 ┆ 4549 ┆ 0.070454 ┆ Wikimedia module │
│ Q3099732 ┆ 5712 ┆ 4147 ┆ 0.726015 ┆ technical report │
│ Q7316896 ┆ 3947 ┆ 3947 ┆ 1.0 ┆ retraction notice │
│ Q580922 ┆ 2902 ┆ 2886 ┆ 0.994487 ┆ preprint │
│ Q21481766 ┆ 11041 ┆ 2570 ┆ 0.232769 ┆ scholarly chapter │
│ Q5 ┆ 13494455 ┆ 2371 ┆ 0.000176 ┆ human │
│ Q5246046 ┆ 2234 ┆ 2214 ┆ 0.991047 ┆ academic publishing │
│ Q69488 ┆ 1866 ┆ 1866 ┆ 1.0 ┆ MDMA │
│ Q732577 ┆ 33888 ┆ 1800 ┆ 0.053116 ┆ publication │
│ Q30749496 ┆ 1535 ┆ 1535 ┆ 1.0 ┆ diploma thesis │
│ Q11266439 ┆ 827542 ┆ 1458 ┆ 0.001762 ┆ Wikimedia template │
│ Q111475835 ┆ 1330 ┆ 1330 ┆ 1.0 ┆ bachelor's with honors thesis │
│ Q20202352 ┆ 76263 ┆ 1282 ┆ 0.01681 ┆ locality of Mexico │
│ Q486972 ┆ 601447 ┆ 1260 ┆ 0.002095 ┆ human settlement │
│ Q3331189 ┆ 821995 ┆ 1165 ┆ 0.001417 ┆ version, edition or translation │
│ Q4167836 ┆ 5759183 ┆ 1136 ┆ 0.000197 ┆ Wikimedia category │
│ Q7725634 ┆ 501529 ┆ 1059 ┆ 0.002112 ┆ literary work │
│ Q114609228 ┆ 22596 ┆ 1045 ┆ 0.046247 ┆ recurring sporting event edition │
│ Q17928402 ┆ 3619 ┆ 1024 ┆ 0.282951 ┆ blog post │
│ Q2352616 ┆ 2810 ┆ 978 ┆ 0.348043 ┆ catalog │
│ Q309481 ┆ 22552 ┆ 881 ┆ 0.039065 ┆ obituary │
│ Q56478376 ┆ 768 ┆ 764 ┆ 0.994792 ┆ expression of concern │
│ Q13406463 ┆ 380001 ┆ 666 ┆ 0.001753 ┆ Wikimedia list article │
│ Q27020041 ┆ 194005 ┆ 635 ┆ 0.003273 ┆ sports season │
│ Q264238 ┆ 1276 ┆ 617 ┆ 0.483542 ┆ newsletter │
│ Q1980247 ┆ 36860 ┆ 587 ┆ 0.015925 ┆ chapter │
│ Q21112633 ┆ 3025 ┆ 554 ┆ 0.18314 ┆ edition of a translation │
│ Q798134 ┆ 538 ┆ 538 ┆ 1.0 ┆ bachelor's thesis │
│ Q265158 ┆ 2533 ┆ 518 ┆ 0.204501 ┆ review │
│ Q4167410 ┆ 1519753 ┆ 492 ┆ 0.000324 ┆ Wikimedia disambiguation page │
│ Q114613919 ┆ 472 ┆ 472 ┆ 1.0 ┆ scientific note │
│ Q92998777 ┆ 471 ┆ 471 ┆ 1.0 ┆ opinion paper │
│ Q58901591 ┆ 471 ┆ 470 ┆ 0.997877 ┆ comparative study │
│ Q10885494 ┆ 466 ┆ 466 ┆ 1.0 ┆ academic conference paper │
│ Q16970 ┆ 294680 ┆ 423 ┆ 0.001435 ┆ church building │
│ Q132115645 ┆ 413 ┆ 413 ┆ 1.0 ┆ standard analytical method │
│ Q253623 ┆ 1442 ┆ 410 ┆ 0.284327 ┆ patent │
│ Q604733 ┆ 1206 ┆ 386 ┆ 0.320066 ┆ presentation │
│ Q59387148 ┆ 373 ┆ 373 ┆ 1.0 ┆ research report │
│ Q11032 ┆ 52203 ┆ 353 ┆ 0.006762 ┆ newspaper │
│ Q3240003 ┆ 14103 ┆ 344 ┆ 0.024392 ┆ bus route │
│ Q191067 ┆ 167467 ┆ 323 ┆ 0.001929 ┆ article │
└────────────┴──────────┴──────────┴──────────┴──────────────────────────────────┘
There are ones like "church building" which drop slightly (0.1%), in other words you can probably interpret this not as items being filtered out but by instances being added in new Wikidata releases.
On the other hand there are some like "review" at 20% which are not clear cut, "edition of a translation" (18%), newsletter (48%).
Some classes are missing in part: scientific publication 93%, geological map 95%, conference abstract 89%, technical report 73%, book review 44%.
The clear cut cases were over 99% reduced:
Classes with >= 99% of their old entities missing (>= 100):
shape: (38, 5)
┌────────────┬──────────┬──────────┬──────────┬──────────────────────────────────────┐
│ p31 ┆ entities ┆ missing ┆ share ┆ label │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ str ┆ u32 ┆ u32 ┆ f64 ┆ str │
╞════════════╪══════════╪══════════╪══════════╪══════════════════════════════════════╡
│ Q13442814 ┆ 45431973 ┆ 45431670 ┆ 0.999993 ┆ scholarly article │
│ Q871232 ┆ 513082 ┆ 512756 ┆ 0.999365 ┆ editorial │
│ Q2782326 ┆ 187464 ┆ 187464 ┆ 1.0 ┆ case report │
│ Q815382 ┆ 109685 ┆ 109685 ┆ 1.0 ┆ meta-analysis │
│ Q187685 ┆ 104180 ┆ 104177 ┆ 0.999971 ┆ doctoral thesis │
│ Q1348305 ┆ 93382 ┆ 93382 ┆ 1.0 ┆ erratum │
│ Q1907875 ┆ 47231 ┆ 47225 ┆ 0.999873 ┆ master's thesis │
│ Q18918145 ┆ 39615 ┆ 39604 ┆ 0.999722 ┆ academic journal article │
│ Q45182324 ┆ 23941 ┆ 23940 ┆ 0.999958 ┆ retracted paper │
│ Q23927052 ┆ 19956 ┆ 19955 ┆ 0.99995 ┆ conference paper │
│ Q1402850 ┆ 8872 ┆ 8872 ┆ 1.0 ┆ field study report │
│ Q15781350 ┆ 5340 ┆ 5336 ┆ 0.999251 ┆ final project report │
│ Q1266946 ┆ 5231 ┆ 5229 ┆ 0.999618 ┆ thesis │
│ Q7316896 ┆ 3947 ┆ 3947 ┆ 1.0 ┆ retraction notice │
│ Q580922 ┆ 2902 ┆ 2886 ┆ 0.994487 ┆ preprint │
│ Q5246046 ┆ 2234 ┆ 2214 ┆ 0.991047 ┆ academic publishing │
│ Q69488 ┆ 1866 ┆ 1866 ┆ 1.0 ┆ MDMA │
│ Q30749496 ┆ 1535 ┆ 1535 ┆ 1.0 ┆ diploma thesis │
│ Q111475835 ┆ 1330 ┆ 1330 ┆ 1.0 ┆ bachelor's with honors thesis │
│ Q56478376 ┆ 768 ┆ 764 ┆ 0.994792 ┆ expression of concern │
│ Q798134 ┆ 538 ┆ 538 ┆ 1.0 ┆ bachelor's thesis │
│ Q114613919 ┆ 472 ┆ 472 ┆ 1.0 ┆ scientific note │
│ Q92998777 ┆ 471 ┆ 471 ┆ 1.0 ┆ opinion paper │
│ Q58901591 ┆ 471 ┆ 470 ┆ 0.997877 ┆ comparative study │
│ Q10885494 ┆ 466 ┆ 466 ┆ 1.0 ┆ academic conference paper │
│ Q132115645 ┆ 413 ┆ 413 ┆ 1.0 ┆ standard analytical method │
│ Q59387148 ┆ 373 ┆ 373 ┆ 1.0 ┆ research report │
│ Q1385450 ┆ 294 ┆ 294 ┆ 1.0 ┆ dissertation │
│ Q130709863 ┆ 278 ┆ 278 ┆ 1.0 ┆ book or chapter │
│ Q54670950 ┆ 228 ┆ 227 ┆ 0.995614 ┆ conference poster │
│ Q51282918 ┆ 159 ┆ 159 ┆ 1.0 ┆ Doctor of Philosophy thesis │
│ Q51282711 ┆ 150 ┆ 150 ┆ 1.0 ┆ Doctor of Clinical Psychology thesis │
│ Q15706459 ┆ 146 ┆ 145 ┆ 0.993151 ┆ research article │
│ Q111475860 ┆ 124 ┆ 124 ┆ 1.0 ┆ postgraduate diploma thesis │
│ Q51283092 ┆ 121 ┆ 121 ┆ 1.0 ┆ Master of Arts thesis │
│ Q58900768 ┆ 115 ┆ 115 ┆ 1.0 ┆ consensus statement │
│ Q58897583 ┆ 112 ┆ 112 ┆ 1.0 ┆ comment │
│ Q58898636 ┆ 107 ┆ 107 ┆ 1.0 ┆ evaluation study │
└────────────┴──────────┴──────────┴──────────┴──────────────────────────────────────┘
All seem to be correct here except "MDMA"
old missing entities covered by those classes: 45665518 of 46440160
P31 sets of the uncovered ones:
shape: (30, 3)
┌────────────────┬────────┬──────────────────────────────────────────┐
│ p31 ┆ len ┆ label │
│ --- ┆ --- ┆ --- │
│ list[str] ┆ u32 ┆ str │
╞════════════════╪════════╪══════════════════════════════════════════╡
│ [] ┆ 714789 ┆ │
│ ["Q591041"] ┆ 12234 ┆ scientific publication │
│ ["Q58632367"] ┆ 6290 ┆ scholarly conference abstract │
│ ["Q15184295"] ┆ 4549 ┆ Wikimedia module │
│ ["Q3099732"] ┆ 3996 ┆ technical report │
│ ["Q5"] ┆ 2358 ┆ human │
│ ["Q11266439"] ┆ 1458 ┆ Wikimedia template │
│ ["Q21481766"] ┆ 1285 ┆ scholarly chapter │
│ ["Q20202352"] ┆ 1151 ┆ locality of Mexico │
│ ["Q4167836"] ┆ 1136 ┆ Wikimedia category │
│ ["Q486972"] ┆ 1122 ┆ human settlement │
│ ["Q114609228"] ┆ 1019 ┆ recurring sporting event edition │
│ ["Q17928402"] ┆ 999 ┆ blog post │
│ ["Q7725634"] ┆ 811 ┆ literary work │
│ ["Q13406463"] ┆ 661 ┆ Wikimedia list article │
│ ["Q27020041"] ┆ 633 ┆ sports season │
│ ["Q264238"] ┆ 610 ┆ newsletter │
│ ["Q4167410"] ┆ 489 ┆ Wikimedia disambiguation page │
│ ["Q16970"] ┆ 419 ┆ church building │
│ ["Q253623"] ┆ 409 ┆ patent │
│ ["Q11032"] ┆ 347 ┆ newspaper │
│ ["Q3240003"] ┆ 344 ┆ bus route │
│ ["Q134556"] ┆ 314 ┆ single │
│ ["Q130526446"] ┆ 301 ┆ governmental testimony │
│ ["Q18340514"] ┆ 277 ┆ events in a specific year or time period │
│ ["Q1477856"] ┆ 274 ┆ fact sheet │
│ ["Q267628"] ┆ 265 ┆ column │
│ ["Q728937"] ┆ 236 ┆ railway line │
│ ["Q7433672"] ┆ 216 ┆ science book │
│ ["Q41298"] ┆ 193 ┆ magazine │
└────────────────┴────────┴──────────────────────────────────────────┘
Therefore I would suggest that to reproduce the filter you should use:
EXCLUDE_P31 = {
"Q13442814", # scholarly article
"Q871232", # editorial
"Q2782326", # case report
"Q815382", # meta-analysis
"Q187685", # doctoral thesis
"Q1348305", # erratum
"Q1907875", # master's thesis
"Q18918145", # academic journal article
"Q45182324", # retracted paper
"Q23927052", # conference paper
"Q1402850", # field study report
"Q15781350", # final project report
"Q1266946", # thesis
"Q7316896", # retraction notice
"Q580922", # preprint
"Q5246046", # academic publishing
"Q30749496", # diploma thesis
"Q111475835", # bachelor's with honors thesis
"Q56478376", # expression of concern
"Q798134", # bachelor's thesis
"Q114613919", # scientific note
"Q92998777", # opinion paper
"Q58901591", # comparative study
"Q10885494", # academic conference paper
"Q132115645", # standard analytical method
"Q59387148", # research report
"Q1385450", # dissertation
"Q130709863", # book or chapter
"Q54670950", # conference poster
"Q51282918", # Doctor of Philosophy thesis
"Q51282711", # Doctor of Clinical Psychology thesis
"Q15706459", # research article
"Q111475860", # postgraduate diploma thesis
"Q51283092", # Master of Arts thesis
"Q58900768", # consensus statement
"Q58897583", # comment
"Q58898636", # evaluation study
}
If there was a different approach I'd be interested to know though :-)
Very cool! In case there's any condition that you missed, you can find the filtering code in this Github repo
It's based on the WDQS graph split rules