from typing import List
import jsonpath_rw
import spacy
from etk.tokenizer import Tokenizer
from etk.document import Document


class ETK(object):

    def __init__(self):
        self.parser = jsonpath_rw.parse
        self.default_tokenizer = Tokenizer(nlp=spacy.load('en_core_web_sm'))

    def create_document(self, doc: dict) -> Document:
        """
        Factory method to wrap input JSON docs in an ETK Document object.

        Args:
            doc (dict): a JSON object containing a document in CDR format.

        Returns: wrapped Document

        """
        return Document(self, doc)

    def load_glossary(self, file_path) -> List[str]:
        """
        A glossary is a text file, one entry per line.

        Args:
            file_path (str): path to a text file containing a glossary.

        Returns: List of the strings in the glossary.
        """
        #to-do: this should be a list, not a dict
        res = dict()
        with open(file_path) as fp:
            line = fp.readline().rstrip('\n')
            while line:
                res[line] = line
                line = fp.readline().rstrip('\n')
        return res


@@ -318,20 +318,73 @@
 f, doc: 
-dict
+object, mime_type: str=None, url: str=%22http://ex.com/123%22
 ) -%3E Doc
@@ -565,16 +565,173 @@
  format.
+%0A            mime_type (str): if doc is a tring, the mime_type tells what it is%0A            url (str): if the doc came from the web, specifies the URL for it
 %0A%0A      
@@ -807,16 +807,16 @@
 , doc)%0A%0A
-
     def 
@@ -844,16 +844,21 @@
 ile_path
+: str
 ) -%3E Lis

extend definition of create_document to support HTML