# Path: wapiti.py
# def get_url(url, params=None, raise_exc=True):
#     resp = FakeResponse()
#     try:
#         resp = fake_requests(url, params)
#     except Exception as e:
#         if raise_exc:
#             raise
#         else:
#             resp.error = e
#     return resp


from base import Input
from wapiti import get_url
from pyquery import PyQuery
from stats import dist_stats
import wapiti
            return 0
        else:
            roottree = get_root(f)
            return len(roottree.xpath(u'//{e}[contains(., "{s}")]'.format(e=elem, s=search)))
    return xpath_search


def per_word(feature, f):
        words = float(len(f('p').text().split()))
        if words > 0:
            return len(f(feature)) / words
        else:
            return 0


class DOM(Input):
    prefix = 'd'

    def api_fetch(self):
        """
        Deprecated fetch() that gets parsed content from the API.
        The API doesn't cache parsed wikitext, and can be up to 10x slower
        depending on page complexity.
        """
        page = wapiti.get_articles(self.page_id)[0]
        pq = PyQuery(page.rev_text)
        return pq

    def fetch(self):
        # avg process time: 0.14827052116394043 seconds

# Path: wapiti.py
# def get_url(url, params=None, raise_exc=True):
#     resp = FakeResponse()
#     try:
#         resp = fake_requests(url, params)
#     except Exception as e:
#         if raise_exc:
#             raise
#         else:
#             resp.error = e
#     return resp


# Path: inputs/dom.py
from base import Input
from wapiti import get_url
from pyquery import PyQuery
from stats import dist_stats
import wapiti

            return 0
        else:
            roottree = get_root(f)
            return len(roottree.xpath(u'//{e}[contains(., "{s}")]'.format(e=elem, s=search)))
    return xpath_search


def per_word(feature, f):
        words = float(len(f('p').text().split()))
        if words > 0:
            return len(f(feature)) / words
        else:
            return 0


class DOM(Input):
    prefix = 'd'

    def api_fetch(self):
        """
        Deprecated fetch() that gets parsed content from the API.
        The API doesn't cache parsed wikitext, and can be up to 10x slower
        depending on page complexity.
        """
        page = wapiti.get_articles(self.page_id)[0]
        pq = PyQuery(page.rev_text)
        return pq

    def fetch(self):
        # avg process time: 0.14827052116394043 seconds

        ret = get_url('http://en.wikipedia.org/wiki/' + self.page_title.replace(' ', '_'))