# Path: pyminer/extract.py
# def extract(path):
#     '''
#     Extract full text from pdf's
# 
#     :param path: [String] Path to a pdf file downloaded via {fetch}, or another way.
# 
#     :return: [str] a string of text
# 
#     Usage::
# 
#         from pyminer import miner
# 
#         # a pdf
#         url = "http://www.banglajol.info/index.php/AJMBR/article/viewFile/25509/17126"
#         out = miner.fetch(url)
#         out.parse()
# 
#         # search first, then pass links to fetch
#         res = miner.search(filter = {'has_full_text': True, 'license_url': "http://creativecommons.org/licenses/by/4.0"})
#         # url = res.links_pdf()[0]
#         url = 'http://www.nepjol.info/index.php/JSAN/article/viewFile/13527/10928'
#         x = miner.fetch(url)
#         miner.extract(x.path)
#     '''
#     try:
#         with open(path, "rb") as f:
#             pdf = pdftotext.PDF(f)
#         txt = "\n\n".join(pdf)
#     except Exception as e:
#         raise e
#     return txt


from ..fetcher_utils import *
from ..extract import extract
    parse plain text

    :param path: [String] Path to a plain text file
    :return: a string

    Usage::

        from pyminer import fetch
        from pyminer import parsers
        url = "xx"
        out = fetch(url)
        parsers.parse_plain(out.path)
    '''
    return read_disk(x)

def parse_pdf(x):
    '''
    parse pdf

    :param path: [String] Path to a pdf file
    :return: a string

    Usage::

        from pyminer import fetch
        from pyminer import parsers
        url = "http://www.banglajol.info/index.php/AJMBR/article/viewFile/25509/17126"
        out = fetch(url)
        parsers.parse_pdf(out.path)
    '''

# Path: pyminer/extract.py
# def extract(path):
#     '''
#     Extract full text from pdf's
# 
#     :param path: [String] Path to a pdf file downloaded via {fetch}, or another way.
# 
#     :return: [str] a string of text
# 
#     Usage::
# 
#         from pyminer import miner
# 
#         # a pdf
#         url = "http://www.banglajol.info/index.php/AJMBR/article/viewFile/25509/17126"
#         out = miner.fetch(url)
#         out.parse()
# 
#         # search first, then pass links to fetch
#         res = miner.search(filter = {'has_full_text': True, 'license_url': "http://creativecommons.org/licenses/by/4.0"})
#         # url = res.links_pdf()[0]
#         url = 'http://www.nepjol.info/index.php/JSAN/article/viewFile/13527/10928'
#         x = miner.fetch(url)
#         miner.extract(x.path)
#     '''
#     try:
#         with open(path, "rb") as f:
#             pdf = pdftotext.PDF(f)
#         txt = "\n\n".join(pdf)
#     except Exception as e:
#         raise e
#     return txt


# Path: pyminer/parsers/parsers.py
from ..fetcher_utils import *
from ..extract import extract

    parse plain text

    :param path: [String] Path to a plain text file
    :return: a string

    Usage::

        from pyminer import fetch
        from pyminer import parsers
        url = "xx"
        out = fetch(url)
        parsers.parse_plain(out.path)
    '''
    return read_disk(x)

def parse_pdf(x):
    '''
    parse pdf

    :param path: [String] Path to a pdf file
    :return: a string

    Usage::

        from pyminer import fetch
        from pyminer import parsers
        url = "http://www.banglajol.info/index.php/AJMBR/article/viewFile/25509/17126"
        out = fetch(url)
        parsers.parse_pdf(out.path)
    '''

    return extract(x)