dbpedia / extraction-framework

The software used to extract structured data from Wikipedia
850 stars 270 forks source link

extract more useful images #515

Open VladimirAlexiev opened 7 years ago

VladimirAlexiev commented 7 years ago

This bug is about extracting more useful images from Wikipedia. This PR is related: https://github.com/dbpedia/extraction-framework/pull/470.

The Berlin page as it was extracted in dbpedia has a number of images on wikipedia:

{{Infobox German state
|state_coa=Coat of arms of Berlin.svg
|flag=Flag_of_Berlin.svg
|map=Berlin in Germany and EU.png
# a whole collage/montage
|image_photo={{Photomontage|position=center
| photo1a = Siegessaeule Aussicht 10-13 img4 Tiergarten.jpg
| photo2a = Brandenburger Tor abends.jpg
| photo2b = Journalists during the Berlin Film Festival in 2008.jpg
| photo3a = East Side Gallery.JPG
| photo3b = Alte Nationalgalerie Berlin, 2011.jpg
| photo4a = Reichstag building Berlin view from west before sunset.jpg
{{multiple image
|image2=Über den Dächern von Berlin.jpg
...
{{multiple image
|image2=20150208 - Berlinale Palast and Red Carpet.JPG

These are extracted as follows http://dbpedia.org/page/Berlin:

dbp:stateCoa "Coat of arms of Berlin.svg"
dbp:flag "Flag_of_Berlin.svg"
# these below are actionable links:
foaf:depiction wiki-commons:Special:FilePath/Coat_of_arms_of_Berlin.svg
dbo:thumbnail wiki-commons:Special:FilePath/Coat_of_arms_of_Berlin.svg?width=300
dbp:image 20150208, 
  "Alte Nationalgalerie abends .jpg",
  "Cityscape Berlin.jpg,
  "Franziska Knuppe.jpg",
  "IFA 2012 IMG 7677.JPG",
  "Über den Dächern von Berlin.jpg".

Bugs:


The Lindsay Anderson page as it was extracted in dbpedia has the following image-related info on wikipedia:

{{Infobox person
| image       = Lindsay_anderson.jpg
| imagesize   = 215px

http://dbpedia.org/page/Lindsay_Anderson extracts only dbp:imagesize.

Bug: extract dbp:image and turn it into an actonable link wiki-commons:Special:FilePath/*. Note: #133 discusses images in the en namespace vs the commons namespace, so "actionable link" may not always mean "prepend a commons namespace", someone needs to research this.

chile12 commented 7 years ago

Hope to have a look at this before the next extraction.

Termilion commented 7 years ago

I was told to have a look at the ImageExtractor for this issue. Surprisingly the problems are not the caused by the ImageExtractor, because it extracts images to foaf:depiction instead of dbp:image. But since it is still in use anyway, I ran a few tests and reworked the code to find and extract more images. In the case of the mentioned Berlin page, the old extractor only extracted one image. The reworked extractor now extracts a total of 94 images from the Berlin page. The links are generated in the way you described and should be working as intended. Used on the complete german article dump it extracts 22 million triples, which is about 3,5 times as many images as the old version. The missing picture on the Lindsay Anderson page should be filtered due to its non-free copyright license, so that is not a bug.

VladimirAlexiev commented 7 years ago

@Termilion Could I take a look at the images for Berlin? Hundreds of images are not necessarily a good thing.

non-free copyright license

You're right. Checked::

Termilion commented 7 years ago

@VladimirAlexiev I definitely see your point. At first my goal was to get as many images as possible without thinking about the importance of the images.

Currently my code traverses the page tree recursively, limited by the configurable max depth. My first idea was to simply reduce the recursion depth (since more important images should appear less embedded), but that didn't have as much of an effect as I predicted. Without recursion we still have 78 Images. If we want to narrow it down any further, I would need to implement a check for specific patterns in which useful images appear. Let me know your thoughts about this, and I'll have a look at possible solutions.

Here is the List of Images extracted from the Berlin page:

  1. http://de.wikipedia.org/wiki/Datei:Flag_of_Berlin.svg
  2. http://de.wikipedia.org/wiki/Datei:Locator_map_Berlin_in_Germany.svg
  3. http://de.wikipedia.org/wiki/Datei:Coat_of_arms_of_Berlin.svg
  4. http://de.wikipedia.org/wiki/Datei:Siegessaeule_Aussicht_10-13_img4_Tiergarten.jpg
  5. http://de.wikipedia.org/wiki/Datei:EU_location_Berlin.svg
  6. http://de.wikipedia.org/wiki/Datei:Berlin_-_Aerial_view_-_2016.jpg
  7. http://de.wikipedia.org/wiki/Datei:Tiergartenimoktober.JPG
  8. http://de.wikipedia.org/wiki/Datei:Berlin,_administrative_divisions_(+districts_-boroughs_-pop)_-_de_-_colored.svg
  9. http://de.wikipedia.org/wiki/Datei:Coat_of_arms_of_Berlin.svg
  10. http://de.wikipedia.org/wiki/Datei:Berlin_Schloss_Charlottenburg_Gartenseite.JPG
  11. http://de.wikipedia.org/wiki/Datei:Botanischer_Garten_Berlin-Dahlem_10-2014_photo01_pond.jpg
  12. http://de.wikipedia.org/wiki/Datei:Panthera_tigris_corbetti_(Tierpark_Berlin)_841-723-(118).jpg
  13. http://de.wikipedia.org/wiki/Datei:Giraffe-berlin-zoo.jpg
  14. http://de.wikipedia.org/wiki/Datei:Chinesischer_Garten_Marzahn.JPG
  15. http://de.wikipedia.org/wiki/Datei:Luftbild_bln-schmoeckwitz.jpg
  16. http://de.wikipedia.org/wiki/Datei:Kloeden_Plan_Berlin_um_1230.JPG
  17. http://de.wikipedia.org/wiki/Datei:Memhardt_Grundriß_der_Beyden_Churf._Residentz_Stätte_Berlin_und_Cölln_1652_(1888).jpg
  18. http://de.wikipedia.org/wiki/Datei:Berlin_Nationaldenkmal_Kaiser_Wilhelm_mit_Schloss_1900.jpg
  19. http://de.wikipedia.org/wiki/Datei:Berlin_Unter_den_Linden_Victoria_Hotel_um_1900.jpg
  20. http://de.wikipedia.org/wiki/Datei:Potsdamer_Platz_1945.jpg
  21. http://de.wikipedia.org/wiki/Datei:Occupied_Berlin.svg
  22. http://de.wikipedia.org/wiki/Datei:Berlinermauer.jpg
  23. http://de.wikipedia.org/wiki/Datei:Bundesarchiv_Bild_183-1989-1118-028,_Berlin,_Grenzübergang_Bornholmer_Straße.jpg
  24. http://de.wikipedia.org/wiki/Datei:Berlin_-_Schloss_Bellevue1.jpg
  25. http://de.wikipedia.org/wiki/Datei:Population_pyramid_of_Berlin_(DE-2010-12-31).svg
  26. http://de.wikipedia.org/wiki/Datei:Metropolregion-BerlinBrandenburg-Infrastruktur.svg
  27. http://de.wikipedia.org/wiki/Datei:Berlin_nikolsburgerstrasse_trolle_14.06.2012_13-40-26.jpg
  28. http://de.wikipedia.org/wiki/Datei:Berlin_population2.svg
  29. http://de.wikipedia.org/wiki/Datei:Stuttgarter-Platz-a.jpg
  30. http://de.wikipedia.org/wiki/Datei:Berliner_Dom_vor_Sonnenuntergang.jpg
  31. http://de.wikipedia.org/wiki/Datei:Berlin_Neue_Synagoge_2010.jpg
  32. http://de.wikipedia.org/wiki/Datei:Berlin,_Mitte,_Bebelplatz,_Hedwigskathedrale_02.jpg
  33. http://de.wikipedia.org/wiki/Datei:Sehitlik-Moschee.jpg
  34. http://de.wikipedia.org/wiki/Datei:Reichstag_building_Berlin_view_from_west_before_sunset.jpg
  35. http://de.wikipedia.org/wiki/Datei:Bundeskanzleramt_in_Berlin_2010.jpg
  36. http://de.wikipedia.org/wiki/Datei:Berlin,_Mitte,_Invalidenstrasse,_Bundesministerium_fuer_Wirtschaft_und_Technologie_01.jpg
  37. http://de.wikipedia.org/wiki/Datei:Berlin_Rotes_Rathaus_B.JPG
  38. http://de.wikipedia.org/wiki/Datei:Abgeordnetenhaus.jpg
  39. http://de.wikipedia.org/wiki/Datei:Rathaus_Pankow_(2009).jpg
  40. http://de.wikipedia.org/wiki/Datei:Coat_of_arms_of_Berlin.svg
  41. http://de.wikipedia.org/wiki/Datei:Flag_of_Europe.svg
  42. http://de.wikipedia.org/wiki/Datei:Flag_of_Germany.svg
  43. http://de.wikipedia.org/wiki/Datei:Flag_of_Berlin.svg
  44. http://de.wikipedia.org/wiki/Datei:TLF_24-40_Berliner_Feuerwehr.jpg
  45. http://de.wikipedia.org/wiki/Datei:Berlin_Adlershof_Wista_Bessy.jpg
  46. http://de.wikipedia.org/wiki/Datei:Berlin_night.jpg
  47. http://de.wikipedia.org/wiki/Datei:BerlinerGründer.jpg
  48. http://de.wikipedia.org/wiki/Datei:Potsdamer_Platz,_Berlin,_160606,_ako_(1).jpg
  49. http://de.wikipedia.org/wiki/Datei:2015-03-22_D-ABKT_at_Berlin-Tegel_TXL_by_sebaso.jpg
  50. http://de.wikipedia.org/wiki/Datei:Bikinihaus_Berlin-1210760.jpg
  51. http://de.wikipedia.org/wiki/Datei:Messe_Berlin_mit_Funkturm_2.jpg
  52. http://de.wikipedia.org/wiki/Datei:Berlin_Schering_Building.jpg
  53. http://de.wikipedia.org/wiki/Datei:Berlin_osthafen_eierkuehlhaus_20050203_p1000092.jpg
  54. http://de.wikipedia.org/wiki/Datei:Berlin,_Kreuzberg,_Rudi-Dutschke-Strasse,_Axel-Springer-Hochhaus.jpg
  55. http://de.wikipedia.org/wiki/Datei:Hauptbahnhof_Berlin.jpg
  56. http://de.wikipedia.org/wiki/Datei:Oberbaumbrücke_mit_U-Bahn.jpg
  57. http://de.wikipedia.org/wiki/Datei:Karte_Berlin_U-Bahn_S-Bahn_Sansculotte.jpg
  58. http://de.wikipedia.org/wiki/Datei:Berliner_U-Bahn_nach_Kaulsdorf-Nord_(Baureihe_F74).jpg
  59. http://de.wikipedia.org/wiki/Datei:Berlin-_Bahnhof_Westkreuz-_Richtung_Nord-_S-Bahn_Berlin_DBAG-Baureihe_481_10.8.2009.jpg
  60. http://de.wikipedia.org/wiki/Datei:Berlin_Straßenverkehr_Übersichtskarte.png
  61. http://de.wikipedia.org/wiki/Datei:Glienicker_Brücke.JPG
  62. http://de.wikipedia.org/wiki/Datei:BikeGirlBerlin.jpg
  63. http://de.wikipedia.org/wiki/Datei:Lage_der_Berliner_Flughäfen.svg
  64. http://de.wikipedia.org/wiki/Datei:Westhafen_(Berlin)_Administration_Building.jpg
  65. http://de.wikipedia.org/wiki/Datei:Karte_der_Berliner_Wasserstraßen.png
  66. http://de.wikipedia.org/wiki/Datei:Kraftwerk_wilmersdorf_klein.jpg
  67. http://de.wikipedia.org/wiki/Datei:L'université_Humboldt_(Berlin)_(9634657735).jpg
  68. http://de.wikipedia.org/wiki/Datei:State_Council_building_in_Berlin.jpg
  69. http://de.wikipedia.org/wiki/Datei:Einstein_1921_portrait2.jpg
  70. http://de.wikipedia.org/wiki/Datei:2016_Charite_Hospital.jpg
  71. http://de.wikipedia.org/wiki/Datei:2011FUBerlin.jpg
  72. http://de.wikipedia.org/wiki/Datei:Berlin_Charlottenburg_TU_ZEMS.jpg
  73. http://de.wikipedia.org/wiki/Datei:Dahlem_Fritz-Haber-Institut-2.JPG
  74. http://de.wikipedia.org/wiki/Datei:Stein-gymn-spandau.jpg
  75. http://de.wikipedia.org/wiki/Datei:Staatsbibliothek_zu_Berlin_Lesesaal_lowres.jpg
  76. http://de.wikipedia.org/wiki/Datei:Berlin_Dance_Performance_2010.jpg
  77. http://de.wikipedia.org/wiki/Datei:PhoenixinBerlin.jpg
  78. http://de.wikipedia.org/wiki/Datei:Philharmonie_1a.jpg
  79. http://de.wikipedia.org/wiki/Datei:Kar_Kult_2006_1.jpg
  80. http://de.wikipedia.org/wiki/Datei:20150208_-_Berlinale_Palast_and_Red_Carpet.JPG
  81. http://de.wikipedia.org/wiki/Datei:Berlin-Charlottenburg_Schaubuehne_05-2014.jpg
  82. http://de.wikipedia.org/wiki/Datei:Berlin_Museumsinsel_Fernsehturm.jpg
  83. http://de.wikipedia.org/wiki/Datei:Neue_Nationalgalerie_Berlin.jpg
  84. http://de.wikipedia.org/wiki/Datei:Nefertiti_30-01-2006.jpg
  85. http://de.wikipedia.org/wiki/Datei:Brandenburger_Tor-Berlin.jpg
  86. http://de.wikipedia.org/wiki/Datei:Über_den_Dächern_von_Berlin.jpg
  87. http://de.wikipedia.org/wiki/Datei:Franzoesischer_Dom_-_Festival_of_Lights_2011.jpg
  88. http://de.wikipedia.org/wiki/Datei:Fernsehturm_Weltzeituhr_Berlin.jpg
  89. http://de.wikipedia.org/wiki/Datei:Tegel_Am_Borsigturm-005.JPG
  90. http://de.wikipedia.org/wiki/Datei:Strandbar_Berlin.jpg
  91. http://de.wikipedia.org/wiki/Datei:Olympiastadion_Berlin_2015.jpg
  92. http://de.wikipedia.org/wiki/Datei:AlbaMavericks.jpg
  93. http://de.wikipedia.org/wiki/Datei:Street_Food_Berlin.jpg
  94. http://de.wikipedia.org/wiki/Datei:Sunrise_Berlin_2014.jpg
  95. http://de.wikipedia.org/wiki/Datei:BerlinBabylon.jpg
  96. http://de.wikipedia.org/wiki/Datei:Marlene_Dietrich_(26).jpg
  97. http://de.wikipedia.org/wiki/Datei:FrenchCathedral_Mrz13_View04.jpg
VladimirAlexiev commented 7 years ago

You've done a lot more than just images from infoboxes!

Termilion commented 7 years ago

@VladimirAlexiev Is it only supposed to get images from the infoboxes? That would be quite a big misunderstanding on my part, but would explain some strange design choices in the old code.

The ImageExtractor is an old Extractor that works on the Article dumps. What I called "page tree" is the extractors internal representation of a WikiPage: A so-called PageNode with children that can be Text-/Link-/Table-/... nodes which may have children on their own. Images are afaik only in link or text nodes, for every other type of node I call the method again to check their children for these node types, that's the recursion I was talking about. (This way I'll i.e. get every Image that might be contained in a Table or something like that) I just improved the way the ImageExtractor uses this structure and finds images, I didn't want to change the base concept of it too dramatically.

The Images only found with the recursion:

  1. http://commons.wikimedia.org/wiki/Special:FilePath/Flag_of_Berlin.svg
  2. http://commons.wikimedia.org/wiki/Special:FilePath/Locator_map_Berlin_in_Germany.svg
  3. http://commons.wikimedia.org/wiki/Special:FilePath/Siegessaeule_Aussicht_10-13_img4_Tiergarten.jpg
  4. http://commons.wikimedia.org/wiki/Special:FilePath/Berlin,_administrative_divisions_(+districts_-boroughs_-pop)_-_de_-_colored.svg
  5. http://commons.wikimedia.org/wiki/Special:FilePath/Panthera_tigris_corbetti_(Tierpark_Berlin)_841-723-(118).jpg
  6. http://commons.wikimedia.org/wiki/Special:FilePath/Giraffe-berlin-zoo.jpg
  7. http://commons.wikimedia.org/wiki/Special:FilePath/Berlin_Unter_den_Linden_Victoria_Hotel_um_1900.jpg
  8. http://commons.wikimedia.org/wiki/Special:FilePath/Population_pyramid_of_Berlin_(DE-2010-12-31).svg
  9. http://commons.wikimedia.org/wiki/Special:FilePath/Metropolregion-BerlinBrandenburg-Infrastruktur.svg
  10. http://commons.wikimedia.org/wiki/Special:FilePath/Flag_of_Europe.svg
  11. http://commons.wikimedia.org/wiki/Special:FilePath/Flag_of_Germany.svg
  12. http://commons.wikimedia.org/wiki/Special:FilePath/Karte_Berlin_U-Bahn_S-Bahn_Sansculotte.jpg
  13. http://commons.wikimedia.org/wiki/Special:FilePath/Berliner_U-Bahn_nach_Kaulsdorf-Nord_(Baureihe_F74).jpg
  14. http://commons.wikimedia.org/wiki/Special:FilePath/Berlin-_Bahnhof_Westkreuz-_Richtung_Nord-_S-Bahn_Berlin_DBAG-Baureihe_481_10.8.2009.jpg
  15. http://commons.wikimedia.org/wiki/Special:FilePath/Berlin_Dance_Performance_2010.jpg
  16. http://commons.wikimedia.org/wiki/Special:FilePath/PhoenixinBerlin.jpg

EDIT 1: I ran a test on Barack Obama. Everything seems to be working fine for EN.

  1. http://commons.wikimedia.org/wiki/Special:FilePath/President_Barack_Obama.jpg
  2. http://commons.wikimedia.org/wiki/Special:FilePath/Barack_Obama_signature.svg
  3. http://commons.wikimedia.org/wiki/Special:FilePath/Obama_family_portrait_in_the_Green_Room.jpg
  4. http://commons.wikimedia.org/wiki/Special:FilePath/BlackhawksWhiteHouse2010.jpg
  5. http://commons.wikimedia.org/wiki/Special:FilePath/Barack_Obama_playing_basketball_with_members_of_Congress_and_Cabinet_secretaries_2.jpg
  6. http://commons.wikimedia.org/wiki/Special:FilePath/DIG13623-230.jpg
  7. http://commons.wikimedia.org/wiki/Special:FilePath/Obamas_at_church_on_Inauguration_Day_2013.jpg
  8. http://commons.wikimedia.org/wiki/Special:FilePath/Obamamiltondavis1.jpg
  9. http://commons.wikimedia.org/wiki/Special:FilePath/2004_Illinois_Senate_results.svg
  10. http://commons.wikimedia.org/wiki/Special:FilePath/BarackObamaportrait.jpg
  11. http://commons.wikimedia.org/wiki/Special:FilePath/Lugar-Obama.jpg
  12. http://commons.wikimedia.org/wiki/Special:FilePath/Barack_Obama_Iraq_2006.jpg
  13. http://commons.wikimedia.org/wiki/Special:FilePath/Flickr_Obama_Springfield_01.jpg
  14. http://commons.wikimedia.org/wiki/Special:FilePath/President_George_W._Bush_and_Barack_Obama_meet_in_Oval_Office.jpg
  15. http://commons.wikimedia.org/wiki/Special:FilePath/ElectoralCollege2008.svg
  16. http://commons.wikimedia.org/wiki/Special:FilePath/P112912PS-0444_-_President_Barack_Obama_and_Mitt_Romney_in_the_Oval_Office_-_crop.jpg
  17. http://commons.wikimedia.org/wiki/Special:FilePath/ElectoralCollege2012.svg
  18. http://commons.wikimedia.org/wiki/Special:FilePath/US_President_Barack_Obama_taking_his_Oath_of_Office_-_2009Jan20.jpg
  19. http://commons.wikimedia.org/wiki/Special:FilePath/Barack_Obama_addresses_joint_session_of_Congress_2009-02-24.jpg
  20. http://commons.wikimedia.org/wiki/Special:FilePath/Obama_cabinet_meeting_2009-11.jpg
  21. http://commons.wikimedia.org/wiki/Special:FilePath/White_House_rainbow_colors_to_celebrate_June_2015_SCOTUS_same-sex_marriage_ruling.jpeg
  22. http://commons.wikimedia.org/wiki/Special:FilePath/U.S._Total_Deficits_vs._National_Debt_Increases_2001-2010.png
  23. http://commons.wikimedia.org/wiki/Special:FilePath/US_Employment_Statistics.svg
  24. http://commons.wikimedia.org/wiki/Special:FilePath/Obama-venice-la.jpg
  25. http://commons.wikimedia.org/wiki/Special:FilePath/Obama_signs_health_care-20100323.jpg
  26. http://commons.wikimedia.org/wiki/Special:FilePath/PPACA_Premium_Chart.jpg
  27. http://commons.wikimedia.org/wiki/Special:FilePath/Percentage_of_Individuals_in_the_United_States_Without_Health_Insurance,_1963-2015.png
  28. http://commons.wikimedia.org/wiki/Special:FilePath/Barack_Obama_visiting_victims_of_2012_Aurora_shooting.jpg
  29. http://commons.wikimedia.org/wiki/Special:FilePath/Barack_Obama_at_Cairo_University_cropped.jpg
  30. http://commons.wikimedia.org/wiki/Special:FilePath/Barack_Obama_foreign_trips.svg
  31. http://commons.wikimedia.org/wiki/Special:FilePath/Barack_Obama_and_Matteo_Renzi_October_2016,_1.jpg
  32. http://commons.wikimedia.org/wiki/Special:FilePath/David_Cameron_and_Barack_Obama_at_the_G20_Summit_in_Toronto.jpg
  33. http://commons.wikimedia.org/wiki/Special:FilePath/Barack_Obama_welcomes_Shimon_Peres_in_the_Oval_Office.jpg
  34. http://commons.wikimedia.org/wiki/Special:FilePath/Vladimir_Putin_and_Barack_Obama_(2015-09-29)_04.jpg
  35. http://commons.wikimedia.org/wiki/Special:FilePath/Obama_and_Biden_await_updates_on_bin_Laden.jpg
  36. http://commons.wikimedia.org/wiki/Special:FilePath/Barack_Obama_talks_with_Benjamin_Netanyahu_(8637772147).jpg
  37. http://commons.wikimedia.org/wiki/Special:FilePath/Handshake_between_the_President_and_Cuban_President_Raúl_Castro.jpg
  38. http://commons.wikimedia.org/wiki/Special:FilePath/Obama_meeting_with_Trump_2_(cropped).jpg
  39. http://commons.wikimedia.org/wiki/Special:FilePath/Official_portrait_of_Barack_Obama.jpg
  40. http://commons.wikimedia.org/wiki/Special:FilePath/Gallup_Poll-Approval_Rating-Barack_Obama.svg
  41. http://commons.wikimedia.org/wiki/Special:FilePath/G8_leaders_watching_football.jpg
  42. http://commons.wikimedia.org/wiki/Special:FilePath/Barack_Obama_at_Trump_inauguration.jpg
  43. http://commons.wikimedia.org/wiki/Special:FilePath/Job_Growth_by_U.S._President_-_v1.png
VladimirAlexiev commented 7 years ago
Termilion commented 7 years ago
VladimirAlexiev commented 7 years ago

Excellent work @Termilion and worth to present at Semantics 2017 DBpedia day, if you're going there.

I wonder how this harvest from the page compares to Commons lists:

This is extracted as RDF:

Do we exclude special images from the normal image list?

I'd say keep them.


@chile12 and @jimkont, how to approach https://github.com/dbpedia/ontology-tracker/issues/19? Maybe you can add it as an item for the meeting? (I won't be there).

Termilion commented 7 years ago

Thanks @VladimirAlexiev, but sadly I won't be able to go to the Semantics this year.

This should now be ready to be merged after the properties are updated.

m1ci commented 4 years ago

@VladimirAlexiev recently we have introduced a testing methodology, see our submission for semantics https://svn.aksw.org/papers/2020/semantics_marvin/public.pdf

So most of the issues can be captured there. My question is: is there smth from this thread that we can define as test? \cc @Vehnem