<commit_before>Wikiwhat
========

A Ruby gem for extracting specific content from a [Wikipedia](http://wikipedia.com) article.


## Table of Contents

1. Installation
2. Usage
3. Examples
4. Contribute
5. Team

## Installation

Add this line to your application's Gemfile:

    gem 'wikiwhat'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install wikiwhat

## Usage

This gem makes use of [Wikipedia](http://wikipedia.com), which is a Creative Commons resource. Please check out the [Wikipedia Copyright](http://en.wikipedia.org/wiki/Wikipedia:Copyrights) page for licensing information.

######To create a new Wikiwhat::Page object:

Each article to be queried should be set up as a new Wikiwhat::Page object. Queries are made via the API, which has limited redirect capabilities. Misspelled  or ambiguious titles may return unexpected results.
	
	page = Wikiwhat::Page.new("<WIKIPEDIA ARTICLE TITLE>")
	
Example:

	pigeon = Wikiwhat::Page.new("<NAME>")
	albert = Wikiwhat::Page.new("<NAME>")

######Types of infomation available:

* Paragraph(s) in an article
* All paragraphs under a specific header
* A list of all image titles and corrisponding URIs found in an article
* The sidebar image
* A list of all references found in an article

These methods must be done consecutively. We currently do not support setting multiple options at once in a single new Wikiwhat object. However, the indivudual methods can all be called on the same instance of Wikiwhat::Page.

######To get the first several paragraphs in an article:

```ruby
page = Wikiwhat::Page.new("<WIKIPEDIA ARTICLE TITLE>", :paragraphs => NUMBER)
```

You can also call .paragraphs directly on your Wikiwhat::Page object.

```ruby
page.paragraphs(2)
```

If no number is specified, `.paragraphs` defaults to `1` ie: the first paragraph on the page.

The paragraphs will be returned in an array with each paragraph as a String item in that array. The paragraphs are stored under the instance variable `@paragraphs`. Currently, the text will contain the HTML markup from the page. If more paragraphs than exist are requested, all paragraphs found on the page will be returned without errors.

Example 1:

```ruby
pigeon = Wikiwhat::Page.new("Columba livia", :paragraphs => 2)

=> ["<p>The <b>Rock Dove</b> (<i>Columba livia</i>) or <b>Rock Pigeon</b> is a member of the bird family Columbidae (doves and pigeons). In common usage, this bird is often simply referred to as the \"pigeon\".</p>",
	"\n<p>The species includes the domestic pigeon (including the fancy pigeon), and escaped domestic pigeons have given rise to feral populations around the world.</p>"]
```

Example 2:

```ruby
pigeon = Wikiwhat::Page.new("Columba livia")<commit_msg>Proofreading edits to README.<commit_after>Wikiwhat
========

A Ruby gem for extracting specific content from a [Wikipedia](http://wikipedia.com) article.


## Table of Contents

1. Installation
2. Usage
3. Examples
4. Contribute
5. Team

## Installation

Add this line to your application's Gemfile:

    gem 'wikiwhat'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install wikiwhat

## Usage

This gem makes use of [Wikipedia](http://wikipedia.com), which is a Creative Commons resource. Please check out the [Wikipedia Copyright](http://en.wikipedia.org/wiki/Wikipedia:Copyrights) page for licensing information.

######To create a new Wikiwhat::Page object:

Each article to be queried should be set up as a new Wikiwhat::Page object. Queries are made via the Wikipedia API, which has limited redirect capabilities. Misspelled  or ambiguious titles may return unexpected results.

```ruby
	page = Wikiwhat::Page.new("<WIKIPEDIA ARTICLE TITLE>")
```

Example:

```ruby
	pigeon = Wikiwhat::Page.new("Columba livia")
	albert = Wikiwhat::Page.new("<NAME>")
```

######Types of infomation available:

* Paragraph(s) in an article
* All paragraphs under a specific header
* A list of all image titles and corresponding URLs found in an article
* The sidebar image
* A list of all references found in an article

These methods must be done independently. We currently do not support setting multiple options at once in a single new Wikiwhat object. However, the indivudual methods can all be called on the same instance of Wikiwhat::Page.

######To get the first several paragraphs in an article:

```ruby
page = Wikiwhat::Page.new("<WIKIPEDIA ARTICLE TITLE>", :paragraphs => NUMBER)
```

You can also call .paragraphs directly on your Wikiwhat::Page object.

```ruby
page.paragraphs(2)
```

If no number is specified, `.paragraphs` defaults to `1` ie: the first paragraph on the page.

The paragraphs will be returned in an array with each paragraph as a String item in that array. The paragraphs are stored under the instance variable `@paragraphs`. Currently, the text will contain the HTML markup from the page. If more paragraphs than exist are requested, all paragraphs found on the page will be returned without errors.

Example 1:

```ruby
pigeon = Wikiwhat::Page.new("Columba livia", :paragraphs => 2)

=> ["<p>The <b>Rock Dove</b> (<i>Columba livia</i>) or <b>Rock Pigeon</b> is a member of the bird family Columbidae (doves and pigeons). In common usage, this bird is often simply referred to as the \"pigeon\".</p>",
	"\n<p>The species includes the domestic pigeon (including the fancy pigeon), and escaped domestic pigeons have given rise to feral populations around the world.</p>"]
```

Example 2:

```ruby
pigeon = Wikiwhat::Page.new("Columba livia")
{'fraction_non_alphanumeric': 0.09831613253666485, 'fraction_numerical': 0.003621220351258374, 'mean_word_length': 4.619532044760936, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2779906', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1531, 'n_words': 730}