SlideShare a Scribd company logo
1 of 19
Wikipedia解析
Wikipediaとは

     誰もが無料で自由に編集に参加できるインターネット百科事典



     コンテンツはXMLファイルとしても提供されている

      http://dumps.wikimedia.org/




Uzabase                              22
Wikipediaダンプの配信仕方

     下記のウェブサイトからダウンロード可能

      http://dumps.wikimedia.org/

     各ダンプは月に1~3回生成される

     すべてのダンプはXML形式




Uzabase                              33
記事の例

   <page>
       <title>ピザ</title>
        <id>28082</id>
       <revision>
          <id>46484702</id>
          <parentid>46484672</parentid>
          <timestamp>2013-03-03T20:53:16Z</timestamp>
          <contributor>
            <username>Nipisiquit</username>
            <id>62077</id>
          </contributor>
             <text xml:space="preserve">
                 [[ファイル:Supreme pizza.jpg|thumb|250px|
                 アメリカ風ピザ]]
                 '''ピザ'''(イタリア語の pizza ({{IPA-
   it|ˈpiʦ:a}})
                 に由来する「'''ピッツァ'''」の表記も用いられる)は、
   [[小麦
                 粉]]、水、塩、イースト、砂糖、少量の[[オリーブ油]]
   をこねた後
Uzabase          に発酵させて作った生地を丸く薄くのばし、その上に具               44
Wikipediaダンプの種類


    記事、テンプレート、メタページの最新版のみ

     jawiki-20130307-pages-articles.xml.bz2           1.7GB

     enwiki-20130304-pages-articles1-27.xml.bz2       9.2GB

    全ページの最新版のみ

     jawiki-20130307-pages-meta-current.xml.bz2       2.0GB

     enwiki-20130304-pages-meta-current1-27.xml.bz2   17.9GB

    全ページの全ての版
     jawiki-20130307-pages-meta-history.xml.bz2       31.0GB

     enwiki-20130304-pages-meta-current1-27.xml.bz2   500GB


Uzabase                                                        55
Wikipediaダンプの特徴

    コンテンツ(データ量)が多い

    非構造化と構造化テキストデータが両方入っている

    自由に使える




Uzabase                        66
Wikipediaダンプはなぜ必要?

    コーパス(⇒大量のテキストデータ)が必要な技術はたくさんある

      音声認識、自動翻訳、解体素解析、日本語入力システム、
      検索エンジン、など



    有名なコーパス

      日本語

      –   毎日新聞、日経新聞、京都大学テキストコーパス、BCCWJ

      英語

      –   British National Corpus、Brown Corpus、
          Google Web N-Gram Corpus


Uzabase                                           77
Wikipediaダンプの解析

     非構造化データ

      記事の本文やタイトルなどの抽出、プレーンテキストへの変換
      、など

       –   gwtwiki

       –   WikipedaExtractor


     構造化データ

      DBpedia




Uzabase                               88
gwtwiki

     Javaライブラリ

     wikitextをHTMLやプレーンテキストなどに変換できる

     Wikipediaダンプを簡単に解析できる

  IArticleFilter handler = new ArticleFilter();
  WikiXMLParser wxp = new WikiXMLParser(
          “/path/to/dump.xml.bz2”, handler);
  wxp.parse();

  public class ArticleFilter implements IArticleFilter {

      public void process(WikiArticle page, Siteinfo siteinfo) {
         String title = page.getTitle();
         String bodyText = page.getText();
         ...
      }
  }
Uzabase                                                            99
gwtwiki

    Javaライブラリ

    wikitextをHTMLやプレーンテキストなどに変換できる

    Wikipediaダンプを簡単に解析できる



  WikiModel wikiModel = new
            WikiModel("http://www.mywiki.com/wiki/${image}",
                      "http://www.mywiki.com/wiki/${title}");

  String plainStr = wikiModel.render(
            new PlainTextConverter(),
            bodyText);




Uzabase                                                         10
                                                                 10
WikipediaExtractor

     http://medialab.di.unipi.it/wiki/Wikipedia_Extractor

     Wikipediaダンプをプレーンテキストに変換するPythonスクリプト
       <text xml:space="preserve">
             [[ファイル:Supreme pizza.jpg|thumb|250px|
              アメリカ風ピザ]]
              '''ピザ'''(イタリア語の pizza ({{IPA-it|ˈ    piʦ:a}})
              に由来する「'''ピッツァ'''」の表記も用いられる)は、[[小
       麦
              粉]]、水、塩、イースト、砂糖、少量の[[オリーブ油]]をこね
       た後
              に発酵させて作った生地を丸く薄くのばし、その上に具を乗せ、
              [[オーブン]]や専用の[[竃]]などで焼いた食品である。
              ...


    ピザ(イタリア語の pizza (イタリア語発音: [ˈpiʦ:a])に由来する
    「ピッツァ」の表記も用いられる)は、小麦粉、水、塩、イースト、砂
    糖、少量のオリーブ油をこねた後に発酵させて作った生地を丸く薄くの
Uzabase
    ばし、その上に具を乗せ、オーブンや専用の竃などで焼いた食品である。11      11
WikipediaExtractor

    http://medialab.di.unipi.it/wiki/Wikipedia_Extractor

    Wikipediaダンプをプレーンテキストに変換するPythonスクリプト


 WikiExtractor.py [options]

 -c, --compress : compress output files using bzip
 -b, --bytes= n[KM] : put specified bytes per output file (default 500K)
 -B, --base= URL : base URL for the Wikipedia pages
 -o, --output= dir : place output files in specified directory (default current)
 -l, --link : preserve links
 --help : display this help and exit


 > bzcat jawiki-latest-pages-articles.xml.bz2 | WikiExtractor.py -o extracted




Uzabase                                                                            12
                                                                                    12
構造化データ

    Infobox




Uzabase        13
                13
構造化データ

    Infobox




Uzabase        14
                14
構造化データ

    Infobox




Uzabase        15
                15
構造化データ

    Infobox




Uzabase        16
                16
DBpedia

    http://dbpedia.org/

    Wikipediaから構造化データを抽出するプロジェクト

    100以上の言語が対応されている

      しかし、カバー率はそれぞれ違う

    N-Triples形式で配信される




Uzabase                             17
                                     17
DBpediaの例

  <http://dbpedia.org/resource/Toyota>
      <http://dbpedia.org/property/companyType>
      "Public" .

  <http://dbpedia.org/resource/Toyota>
      <http://dbpedia.org/property/industry>
      <http://dbpedia.org/resource/Automotive_industry> .

  <http://dbpedia.org/resource/Toyota>
      <http://dbpedia.org/ontology/foundingDate>
      "1937-08-28" .

  <http://dbpedia.org/resource/Toyota>
      <http://dbpedia.org/ontology/foundedBy>
      <http://dbpedia.org/resource/Kiichiro_Toyoda> .




Uzabase                                                     18
                                                             18
DBpediaへのクエリ

    SPARQLでクエリすることができる

        http://dbpedia.org/snorql/

    例

      1900年以前にベルリンで生まれた人

         PREFIX dbo: <http://dbpedia.org/ontology/>

         SELECT ?name ?birth ?death ?person WHERE {
              ?person dbo:birthPlace :Berlin .
              ?person dbo:birthDate ?birth .
              ?person foaf:name ?name .
              ?person dbo:deathDate ?death .
              FILTER (?birth < "1900-01-01"^^xsd:date) .
         }
         ORDER BY ?name


Uzabase                                                    19
                                                            19

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Wikipedia解析

  • 2. Wikipediaとは  誰もが無料で自由に編集に参加できるインターネット百科事典  コンテンツはXMLファイルとしても提供されている  http://dumps.wikimedia.org/ Uzabase 22
  • 3. Wikipediaダンプの配信仕方  下記のウェブサイトからダウンロード可能  http://dumps.wikimedia.org/  各ダンプは月に1~3回生成される  すべてのダンプはXML形式 Uzabase 33
  • 4. 記事の例 <page> <title>ピザ</title> <id>28082</id> <revision> <id>46484702</id> <parentid>46484672</parentid> <timestamp>2013-03-03T20:53:16Z</timestamp> <contributor> <username>Nipisiquit</username> <id>62077</id> </contributor> <text xml:space="preserve"> [[ファイル:Supreme pizza.jpg|thumb|250px| アメリカ風ピザ]] '''ピザ'''(イタリア語の pizza ({{IPA- it|ˈpiʦ:a}}) に由来する「'''ピッツァ'''」の表記も用いられる)は、 [[小麦 粉]]、水、塩、イースト、砂糖、少量の[[オリーブ油]] をこねた後 Uzabase に発酵させて作った生地を丸く薄くのばし、その上に具 44
  • 5. Wikipediaダンプの種類  記事、テンプレート、メタページの最新版のみ jawiki-20130307-pages-articles.xml.bz2 1.7GB enwiki-20130304-pages-articles1-27.xml.bz2 9.2GB  全ページの最新版のみ jawiki-20130307-pages-meta-current.xml.bz2 2.0GB enwiki-20130304-pages-meta-current1-27.xml.bz2 17.9GB  全ページの全ての版 jawiki-20130307-pages-meta-history.xml.bz2 31.0GB enwiki-20130304-pages-meta-current1-27.xml.bz2 500GB Uzabase 55
  • 6. Wikipediaダンプの特徴  コンテンツ(データ量)が多い  非構造化と構造化テキストデータが両方入っている  自由に使える Uzabase 66
  • 7. Wikipediaダンプはなぜ必要?  コーパス(⇒大量のテキストデータ)が必要な技術はたくさんある  音声認識、自動翻訳、解体素解析、日本語入力システム、 検索エンジン、など  有名なコーパス  日本語 – 毎日新聞、日経新聞、京都大学テキストコーパス、BCCWJ  英語 – British National Corpus、Brown Corpus、 Google Web N-Gram Corpus Uzabase 77
  • 8. Wikipediaダンプの解析  非構造化データ  記事の本文やタイトルなどの抽出、プレーンテキストへの変換 、など – gwtwiki – WikipedaExtractor  構造化データ  DBpedia Uzabase 88
  • 9. gwtwiki  Javaライブラリ  wikitextをHTMLやプレーンテキストなどに変換できる  Wikipediaダンプを簡単に解析できる IArticleFilter handler = new ArticleFilter(); WikiXMLParser wxp = new WikiXMLParser( “/path/to/dump.xml.bz2”, handler); wxp.parse(); public class ArticleFilter implements IArticleFilter { public void process(WikiArticle page, Siteinfo siteinfo) { String title = page.getTitle(); String bodyText = page.getText(); ... } } Uzabase 99
  • 10. gwtwiki  Javaライブラリ  wikitextをHTMLやプレーンテキストなどに変換できる  Wikipediaダンプを簡単に解析できる WikiModel wikiModel = new WikiModel("http://www.mywiki.com/wiki/${image}", "http://www.mywiki.com/wiki/${title}"); String plainStr = wikiModel.render( new PlainTextConverter(), bodyText); Uzabase 10 10
  • 11. WikipediaExtractor  http://medialab.di.unipi.it/wiki/Wikipedia_Extractor  Wikipediaダンプをプレーンテキストに変換するPythonスクリプト <text xml:space="preserve"> [[ファイル:Supreme pizza.jpg|thumb|250px| アメリカ風ピザ]] '''ピザ'''(イタリア語の pizza ({{IPA-it|ˈ piʦ:a}}) に由来する「'''ピッツァ'''」の表記も用いられる)は、[[小 麦 粉]]、水、塩、イースト、砂糖、少量の[[オリーブ油]]をこね た後 に発酵させて作った生地を丸く薄くのばし、その上に具を乗せ、 [[オーブン]]や専用の[[竃]]などで焼いた食品である。 ... ピザ(イタリア語の pizza (イタリア語発音: [ˈpiʦ:a])に由来する 「ピッツァ」の表記も用いられる)は、小麦粉、水、塩、イースト、砂 糖、少量のオリーブ油をこねた後に発酵させて作った生地を丸く薄くの Uzabase ばし、その上に具を乗せ、オーブンや専用の竃などで焼いた食品である。11 11
  • 12. WikipediaExtractor  http://medialab.di.unipi.it/wiki/Wikipedia_Extractor  Wikipediaダンプをプレーンテキストに変換するPythonスクリプト WikiExtractor.py [options] -c, --compress : compress output files using bzip -b, --bytes= n[KM] : put specified bytes per output file (default 500K) -B, --base= URL : base URL for the Wikipedia pages -o, --output= dir : place output files in specified directory (default current) -l, --link : preserve links --help : display this help and exit > bzcat jawiki-latest-pages-articles.xml.bz2 | WikiExtractor.py -o extracted Uzabase 12 12
  • 13. 構造化データ  Infobox Uzabase 13 13
  • 14. 構造化データ  Infobox Uzabase 14 14
  • 15. 構造化データ  Infobox Uzabase 15 15
  • 16. 構造化データ  Infobox Uzabase 16 16
  • 17. DBpedia  http://dbpedia.org/  Wikipediaから構造化データを抽出するプロジェクト  100以上の言語が対応されている  しかし、カバー率はそれぞれ違う  N-Triples形式で配信される Uzabase 17 17
  • 18. DBpediaの例 <http://dbpedia.org/resource/Toyota> <http://dbpedia.org/property/companyType> "Public" . <http://dbpedia.org/resource/Toyota> <http://dbpedia.org/property/industry> <http://dbpedia.org/resource/Automotive_industry> . <http://dbpedia.org/resource/Toyota> <http://dbpedia.org/ontology/foundingDate> "1937-08-28" . <http://dbpedia.org/resource/Toyota> <http://dbpedia.org/ontology/foundedBy> <http://dbpedia.org/resource/Kiichiro_Toyoda> . Uzabase 18 18
  • 19. DBpediaへのクエリ  SPARQLでクエリすることができる  http://dbpedia.org/snorql/  例  1900年以前にベルリンで生まれた人 PREFIX dbo: <http://dbpedia.org/ontology/> SELECT ?name ?birth ?death ?person WHERE { ?person dbo:birthPlace :Berlin . ?person dbo:birthDate ?birth . ?person foaf:name ?name . ?person dbo:deathDate ?death . FILTER (?birth < "1900-01-01"^^xsd:date) . } ORDER BY ?name Uzabase 19 19