import re
import boto3
import collections
import urllib.parse as ps
from typing import Callable, List, Optional, Tuple
from requests_aws4auth import AWS4Auth
from elasticsearch import Elasticsearch, RequestsHttpConnection

from chirpy.annotators.sentseg import NLTKSentenceSegmenter
from chirpy.core.offensive_classifier.offensive_classifier import contains_offensive
from chirpy.core.util import get_ngrams, get_elasticsearch
from chirpy.core.latency import measure
import chirpy.core.blacklists.blacklists as blacklists
from functools import lru_cache
from dataclasses import dataclass, field
from chirpy.core.util import filter_and_log, contains_phrase
import logging
from copy import deepcopy
from difflib import SequenceMatcher
import editdistance

import requests
import random
import math


lucene_stopwords = {'a', 'an', 'and', 'are', 'as', 'at', 'be', 'but', 'by', 'for', 'if', 'in', 'into', 'is', 'it',
 'no', 'not', 'of', 'on', 'or', 'such', 'that', 'the', 'their', 'then', 'there', 'these', 'they', 'this', 'to', 'was',
 'will', 'with'}

SUB_SEC_TOKEN = ' [SUB-SEC] '
YEAR_RE = r'\([0-9]+\)'

logger = logging.getLogger('chirpylogger')

es = get_elasticsearch()

@dataclass
class WikiSection:
    wiki_id: int
    page_title: str
    es_id: int
    es_score: float
    title: str
    section_text: str
    ancestor_titles: List[str]
    section_links: List[str]
    highlight: Optional[str] = None

    def __hash__(self):
        return hash(self.es_id)

    def __str__(self):
        return '>'.join(self.ancestor_titles + [self.title])

    def __eq__(self, other):
        """Overrides the default implementation"""
        if isinstance(other, WikiSection):
            return self.es_id == other.es_id
        return False

    def level(self):
        return len(self.ancestor_titles)+1

    def is_descendant_of(self, other):
        a, b = zip(*zip(self.ancestor_titles+[self.title], other.ancestor_titles+[other.title]))
        return other.ancestor_titles < self.ancestor_titles and a == b

    def purge_section_text(self):
        # Section text is huge and shouldn't need to be saved, this function purges it
        #self.section_text = get_summary(self.section_text, lambda text: text.split('.'), 200, 10)
        new_section = deepcopy(self)
        new_section.section_text = ''
        new_section.section_links = []
        return new_section

    def summarize(self, state_manager=None, max_words=50, max_sents=2):
        local_sentseg_fn = lambda text: re.split('[.\n]', text)
        sentseg_fn = NLTKSentenceSegmenter(state_manager).execute if state_manager else local_sentseg_fn
        # print(clean_wiki_text(get_summary(text=self.section_text, sentseg_fn=sentseg_fn, max_words=max_words, max_sents=max_sents)))
        return clean_wiki_text(get_summary(text=self.section_text, sentseg_fn=sentseg_fn, max_words=max_words, max_sents=max_sents))

IRRELEVANT_SECTIONS = {'External links', 'References', 'See also', 'Notes', 'Further reading', 'Footnotes',
                       'Bibliography', 'Discography', 'Filmography', 'Tours', 'Statistics', 'Board of directors',
                       'Subsidiaries', 'Release', 'Collected editions', 'In other media', 'In popular culture',
                       'Personnel', 'Sources', 'Route description', 'Format', 'Distribution', 'Honours',
                       'Soundtrack', 'Schedule', 'Death', 'Administration', 'Facilities', 'Track listing',
                       'Awards', 'Works', 'Club', 'Taxonomy', 'Discography', 'Publications', 'Structure', 'Facilities',
                       'Athletics', '2010 census', 'International', 'Features', '2000 census', 'Services',
                       'Final', 'Teams', 'Singles', 'Content', 'Chart performance'
                       }
@dataclass
class WikiPage:
    wiki_id: Optional[int]
    title: str
    sections: List[WikiSection] = field(default_factory=list)

@measure
@lru_cache(maxsize=128)
def get_wiki_sections(title=str) -> List[WikiSection]:
    """
    Args:
        title (str): Title of wikipedia article
    Returns:
        List[WikiSection]: Sections of the wikipedia page
    """

    query = {'query': {'bool': {'filter': [
            {'term': {'doc_title': title}}]}}}
    sections = es.search(index='enwiki-20201201-sections', body=query, size=100)
    filtered_sections = filter_sections(title, sections)
    return filtered_sections


def filter_highlight_sections(title, es_sections):
    wiki_sections = []

    for section in es_sections['hits']['hits']:
        source = section['_source']

        wiki_section = WikiSection(
            wiki_id=source['doc_id'],
            es_id=section['_id'],
            es_score=section['_score'],
            title=source['title'],
            section_text=source['text'],
            ancestor_titles=source['title_stack'][:-1],
            section_links=source['wiki_links'],
            page_title=title
        )
        if 'highlight' in section and 'text' in section['highlight']:
            #Elastic search highlight field is guaranteed to contain at least one entry becuase
            # we set the no_match_size to 300 in search_wiki_sections function
            wiki_section.highlight = section['highlight']['text'][0]
        wiki_sections.append(wiki_section)
    filtered_sections = wiki_sections

    # Filter sections and log why the  were filtered
    filtered_sections = filter_and_log(lambda section: not contains_offensive(section.title), filtered_sections,
                                       'Wiki Highlights', reason_for_filtering='section title contains offensive phrases')
    filtered_sections = filter_and_log(lambda section: not (set([section.title] + section.ancestor_titles) & IRRELEVANT_SECTIONS),
                                       filtered_sections, 'Wiki Highlights', reason_for_filtering='sections were irrelevant')
    filtered_sections = filter_and_log(lambda section: len(section.section_text.split(' ')) > 5, filtered_sections,
                                       'Wiki Highlights', reason_for_filtering='section text is less than 5 words')
    filtered_sections = filter_and_log(lambda section: len(re.findall(YEAR_RE, section.highlight)) <= 3,
                                       filtered_sections, 'Wiki Sections',
                                       reason_for_filtering='Found more than 3 mentions of 4 digit numbers')
    filtered_sections = filter_and_log(lambda section: section.section_text[0] not in {'†', '+', '*'}, filtered_sections,
                                       'Wiki Highlights', reason_for_filtering="Section begins with '†', '+', which tends to be followed by tables")
    # ADD FILTER: that that removes sesctions with [] and |
    filtered_sections = filter_and_log(lambda section: sum(1 if x in section.section_text else 0 for x in {'|', '[', ']'})==0, filtered_sections,
                                       'Wiki Highlights', reason_for_filtering="Section contains | and [ ], which indicates bad inputs")

    # If the same word has multiple capital letters along with small case letters, it is likely a section with tables.
    # For example - +YearAward ShowCategoryResultRef2017Shorty AwardsVlogger
    # Seems that this has been fixed in the dump, so removing this filter
    # Was getting rid of almost all sections from Barack Obama's article which mentioned McCain many times
    #filtered_sections = filter_and_log(lambda section: sum(1 for w in  section.highlight.split() if len(re.findall(r'[A-Z]',w))>=2 and len(re.findall(r'[A-Z]',w))<len(w)) <= 1,
    #                                   filtered_sections, 'Wiki Highlights',
    #                                   reason_for_filtering='Section highlight contains many words with multiple capital letters and small case letters. Likely a section with tables. ')

    filtered_sections = filter_and_log(lambda section: not contains_offensive(section.highlight), filtered_sections,
                                       'Wiki Highlights', reason_for_filtering='section highlight contains offensive phrases')

    return filtered_sections
def filter_sections(title, es_sections):
    wiki_sections = []
    for section in es_sections['hits']['hits']:
        source = section['_source']

        wiki_section = WikiSection(
            wiki_id=source['doc_id'],
            es_id=section['_id'],
            es_score=section['_score'],
            title=source['title'],
            section_text=source['text'],
            ancestor_titles=source['title_stack'][:-1],
            section_links=source['wiki_links'],
            page_title=title
        )
        if 'highlight' in section and 'text' in section['highlight']:
            #Elastic search highlight field is guaranteed to contain at least one entry becuase
            # we set the no_match_size to 300 in search_wiki_sections function
            wiki_section.highlight = section['highlight']['text'][0]
        wiki_sections.append(wiki_section)
    filtered_sections = wiki_sections

    # Filter sections and log why the  were filtered
    filtered_sections = filter_and_log(lambda section: not contains_offensive(section.title), filtered_sections,
                                       'Wiki sections', reason_for_filtering='section title contains offensive phrases')
    filtered_sections = filter_and_log(lambda section: section.title != '', filtered_sections,
                                       'Wiki Sections', reason_for_filtering='section doesn\'t have a title')
    filtered_sections = filter_and_log(lambda section: not (set([section.title] + section.ancestor_titles) & IRRELEVANT_SECTIONS),
                                       filtered_sections, 'Wiki Sections', reason_for_filtering='sections were irrelevant')
    filtered_sections = filter_and_log(lambda section: len(section.section_text.split(' ')) > 5, filtered_sections,
                                       'Wiki Sections', reason_for_filtering='section text is less than 5 words')
    filtered_sections = filter_and_log(lambda section: len(re.findall(YEAR_RE, section.section_text)) <= 3,
                                       filtered_sections, 'Wiki Sections',
                                       reason_for_filtering='Found more than 3 mentions of 4 digit numbers')
    filtered_sections = filter_and_log(lambda section: section.section_text[0] not in {'†', '+', '*'}, filtered_sections,
                                       'Wiki Sections', reason_for_filtering="Section begins with '†', '+', which tends to be followed by tables")
    filtered_sections = filter_and_log(lambda section: sum(1 if x in section.section_text else 0 for x in {'|', '[', ']'})==0, filtered_sections,
                                       'Wiki Highlights', reason_for_filtering="Section contains | and [ ], which indicates bad inputs")

    # If the same word has multiple capital letters along with small case letters, it is likely a section with tables.
    # For example - +YearAward ShowCategoryResultRef2017Shorty AwardsVlogger
    # Seems that this has been fixed in the dump, so removing this filter
    # Was getting rid of almost all sections from Barack Obama's article which mentioned McCain many times
    #filtered_sections = filter_and_log(lambda section: sum(1 for w in  section.section_text.split() if len(re.findall(r'[A-Z]',w))>=2 and len(re.findall(r'[A-Z]',w))<len(w)) <= 1,
                                       #filtered_sections, 'Wiki Sections',
                                       #reason_for_filtering='Section contains many words with multiple capital letters and small case letters. Likely a section with tables. ')

    # Simplifying assumption - only bother with sections that are a total of 2 levels deep and ensure no 0 level sections
    filtered_sections = filter_and_log(lambda section: section.level() <= 2 and section.level() >= 1,
                                       filtered_sections, 'Wiki Sections',
                                       reason_for_filtering='sections were more than 2 levels deep')
    filtered_sections = filter_and_log(lambda section: not contains_offensive(section.summarize()), filtered_sections,
                                       'Wiki sections', reason_for_filtering='section body contains offensive phrases')

    filtered_sections = list(set(filtered_sections))
    return filtered_sections


@measure
@lru_cache(maxsize=128)
def search_wiki_sections(doc_title: str, phrases: tuple, wiki_links:tuple) -> List[WikiSection]:
    """This function gets all the sections matching a list of phrases.
    Right now it is also a slow 2 step process. Will make it faster
    with a better parse of Wiki when we have more time

    :param doc_title: the title of the document
    :type doc_title: str
    :param phrases: the list of phrases to match
    :type phrases: list
    :return: a list of WikiSections
    """
    # Remove stopwords from query before fuzzy matching
    phrases = [' '.join([tok for tok in phrase.split(' ') if tok not in lucene_stopwords]) for phrase in phrases]
    queries = [({"match": {"text": phrase}},
                {"match": {"title_stack": phrase}},
                {"match": {"title": {"query": phrase, "fuzziness": "AUTO"}}}) for phrase in phrases]
    entity_queries = [{"term": {"wiki_links": link}} for link in wiki_links]
    query = {"query": {"bool": {
        "must": {
            "dis_max": {
                "queries": [elem for tup in queries for elem in tup] + entity_queries,
                "tie_breaker": 0.7
            }
        },
        "filter": [
            {"term": {"doc_title": doc_title}}
        ]
    } } ,
        "highlight" : {
            "no_match_size": 300,
            "fragment_size": 300,
            "pre_tags": [""],
            "post_tags": [""],
            "order": "score",
            "fields" : {
                "text" : {}
            }
    }
    }
    sections = es.search(index='enwiki-20201201-sections', body=query)
    logger.debug(f"For phrases {phrases}, in wikipedia article {doc_title}, found following sections (unfiltered) {sections}")
    filtered_sections = filter_highlight_sections(doc_title, sections)
    return filtered_sections


def get_text_for_entity(entity):
    results = es.search(index='enwiki-20201201-sections', body={
    'query': {
      'bool': {
        'filter': [
          {'term': {'doc_title': entity}}
        ]
      }
    }
    })
    sections = results['hits']['hits']
    # print(sections)
    sections = [(section['_source']['title'], section['_source']['text']) for section in sections]
    logger.primary_info(f"Recovered: {[section[0] for section in sections]}")
    def replaceByLength(matchobj):
        # print("matchobj", matchobj.group(0))
        if len(matchobj.group(0).split(' ')) < 10: return matchobj.group(0)
        return ''
    sections = [(title, re.sub(r'"[^"]*"', replaceByLength, text)) for (title, text) in sections]
    sections = [(title, re.sub(r'^.*]]', '', text)) for (title, text) in sections]
    sections = sorted(sections, key=(lambda x: -len(x[1])))
    return sections

def check_section_summary(rg, section_summary, selected_section, allow_history_overlap=False):
    """
    Check that the section summary is present, non-offensive, and does not overlap with history.
    If it fails any of these conditions, return None. Otherwise, return the summary

    :param rg: response generator
    :param section_summary: section summary text
    :param selected_section: selected WikiSection
    :param allow_history_overlap: whether to allow the summary to overlap with previous utterances (set
     this is True to allow the generated summary to elaborate on the previous summary)
    :return:
    """
    if not section_summary:
        logger.primary_info(f"Received empty section summary for {selected_section.title}.")
        return None
    if contains_offensive(section_summary):
        logger.primary_info(f"The section summary {section_summary} contains some offensivephrase")
        return None
    if not allow_history_overlap and rg.has_overlap_with_history(section_summary, threshold=0.8):
        logger.primary_info(f"Section chosen using title overlap: {selected_section.title} has high overlap with a past utterance. "
                            f"Discarding it. ")
        return None
    return section_summary


def any_section_title_matches(utterance, entity) -> bool:
    sections: List[WikiSection] = get_wiki_sections(entity.name)
    titles = set([section.title.lower() for section in sections]+
                 [section.ancestor_titles[0].lower() for section in sections if len(section.ancestor_titles)>0])

    # Split titles containing the word and into separate titles for matching purposes
    extra_titles = []
    for t in titles:
        extra_titles.extend([st.strip() for st in t.split('and')])

    titles.update(extra_titles)
    logger.info(f"Matching utterance: {utterance} to section tiles: {titles} to check if any matches are found ")
    return any(all(any(editdistance.eval(u_token, eu_token) < 2 for u_token in utterance.split(' '))
                   for eu_token in title.split(' ')) for title in titles)

"""
Adapted from
https://github.com/williamscott701/Information-Retrieval/blob/master/2.%20TF-IDF%20Ranking%20-%20Cosine%20Similarity%2C%20Matching%20Score/TF-IDF.ipynb
"""

def word_tokenize(text):
    # We don't have spacy, so this is our substitute
    tokens = [x for x in text.split()]
    tokens = [x.replace('.', '').replace(',', '').replace('/', '') for x in tokens]
    return tokens

def remove_stop_words(text):
    words = word_tokenize(text)
    new_text = ""
    for w in words:
        if w not in lucene_stopwords and len(w) > 1:
            new_text = new_text + " " + w
    return new_text

def remove_punctuation(text):
    symbols = "!\"'#$%&()*+-.,/:;<=>?@[\]^_`{|}~\n"
    for s in symbols:
        text = text.replace(s, ' ')
        text = text.replace('  ', ' ')
    return text

# Don't have access to Spacy
def stemming(text):
    # stemmer = PorterStemmer()
    tokens = word_tokenize(text)
    return ' '.join(tokens)
    # return ' '.join([stemmer.stem(t) for t in tokens])

def preprocess(text):
    text = text.lower()
    text = remove_punctuation(text)
    text = remove_stop_words(text)
    text = stemming(text)
    return text

def get_doc_freq(texts):
    doc_terms = []
    for terms in [list(set(text.split(' '))) for text in texts]:
        doc_terms += terms
    freqs = collections.Counter(doc_terms)
    vocab = list(freqs.keys())
    return {term: math.log(len(texts)/freq) for term, freq in freqs.items()}, vocab

def get_tfidf(text, idfs, vocab):
    freqs = collections.Counter(text.split(' '))
    N = len(text.split(' '))
    out = [idfs[v] * freqs[v] / N for v in vocab]
    return out

def cosine_similarity(v1, v2):
    # Adapted from https://stackoverflow.com/questions/18424228/cosine-similarity-between-2-number-lists
    sumxx, sumxy, sumyy = 0, 0, 0
    for x, y in zip(v1, v2):
        sumxx += x * x
        sumyy += y * y
        sumxy += x * y
    if sumxx * sumyy == 0:
        return 0
    return sumxy / math.sqrt(sumxx * sumyy)

def tfidf_scores(docs, utterance):
    docs = [utterance] + docs
    docs = [preprocess(d) for d in docs]
    idfs, vocab = get_doc_freq(docs)
    tfidfs = [get_tfidf(d, idfs, vocab) for d in docs]
    utterance_vec = tfidfs[0]
    scores = [cosine_similarity(utterance_vec, v) for v in tfidfs[1:]]
    return scores

def get_sentences(sections, state_manager):
    """

    :param sections: either a list or a string
    :param state_manager:
    :return:
    """
    text = sections if isinstance(sections, str) else '\n\n'.join(sections)
    sentseg = NLTKSentenceSegmenter(state_manager)
    sentences = list(sentseg.execute(text))
    filtered_sentences = []
    for sentence in sentences:
        if len(sentence) < 5: continue
        if any(symbol in sentence for symbol in '\{\}=|'): continue
        filtered_sentences.append(sentence)
    return filtered_sentences


GOOD_SECTIONS = ['culture', 'cuisine']

def get_sentences_from_sections_tfidf(sections, state_manager, strategy="all", num_sections=3, first_turn=False):
    sections = [(title, text) for (title, text) in sections if len(text) > 500]
    sections = dict(sections)
    selected_titles = set()
    # Add intro section if it's retrieved
    if '' in sections: selected_titles.add('')
    # Only return intro section for first turn
    if first_turn and len(selected_titles):
        sentences = get_sentences([sections[title] for title in selected_titles], state_manager)
        if len(sentences) > 10: return sentences
    # Otherwise find more sections
    # logger.primary_info(f"Selected titles: {selected_titles}")
    for keyword in GOOD_SECTIONS:
        good_titles = [title for title in sections.keys() if keyword in title.lower()]
        if len(good_titles) > 0: selected_titles.add(good_titles[0])
    # logger.primary_info(f"Selected titles: {selected_titles}")
    # If we need more sections, use TF-IDF
    if len(selected_titles) < num_sections:
        utterance = state_manager.current_state.text
        logger.primary_info(f"Pulling more text, {utterance}")
        if len(utterance.split(' ')) < 6:
            utterance += ' ' + state_manager.current_state.history[-1]
            logger.primary_info(f"Short user utterance, expanding utterance to: {utterance}")
        remaining_titles = list(set(sections.keys()) - selected_titles)
        logger.primary_info(f"Remaining titles are: {remaining_titles}")
        tfidfs = tfidf_scores([sections[title] for title in remaining_titles], utterance)
        logger.primary_info(f"Finished executing tf_idf with output {tfidfs}")
        top_n = sorted(list(zip(remaining_titles, tfidfs)), key=lambda x: -x[1])[:num_sections-len(selected_titles)]
        top_n = [title for (title, score) in top_n]
        selected_titles |= set(top_n)
    logger.primary_info(f"Selected titles are {selected_titles}")
    return get_sentences([sections[title] for title in selected_titles], state_manager)

def get_sentences_from_sections(sections, state_manager, strategy="all", num_sections=3):
    """Takes in a list of (title, text) sections and returns a set of sentences we care about."""
    sections = [(title, text) for (title, text) in sections if len(text) > 500]
    sections = dict(sections)
    logger.primary_info(f"Sections: {sections.keys()}")
    with open('sections.txt', 'w') as f:
        for section_title, section_text in sections.items():
            f.write('-' * 20 + '\n')
            f.write(f"{section_title}\n")
            f.write('-' * 20 + '\n')
            f.write(section_text)
            f.write('\n\n')
    chosen_titles = set()
    for keyword in GOOD_SECTIONS:
        good_titles = [title for (title, content) in sections.items() if keyword in title.lower()]
        if len(good_titles) > 0: chosen_titles.add(good_titles[0])
    remaining_section_titles = set(sections.keys()) - chosen_titles
    logger.primary_info(f"Chose: {chosen_titles}. Now considering sections: {remaining_section_titles}")
    chosen_titles |= set(random.sample(remaining_section_titles, k=num_sections-len(chosen_titles)))
    logger.primary_info(f"Chose: {chosen_titles}.")
    text = '\n\n'.join([sections[title] for title in chosen_titles])
    sentseg = NLTKSentenceSegmenter(state_manager)
    sentences = list(sentseg.execute(text))
    # logger.primary_info(f"Sentences: {sentences}")
    return sentences
    # if strategy == "one":
    #     section_title, section_text = random.choice(sections)
    #     contents = section_text
    #     print(f"Working with section: {section_title}")
    #     return contents
    # else:
    #     possible_sections = [section[1][:2000] for section in sections if len(section[1]) > 500][:3]
    #     section_text = '\n\n'.join(possible_sections)
    #     with open('s_text.txt', 'w') as f: f.write(section_text)
    #     contents = section_text
    #     return contents



def ngram_recall(generations: List[str], original:str, n:int):
    original = original.lower()
    original_ngrams = set(get_ngrams(original, n))
    generated_ngrams = set(ngm for g in generations for ngm in get_ngrams(g, n))
    return len(generated_ngrams & original_ngrams)/len(original_ngrams)


def get_sentseg_fn(rg):
    def seg(text):
        return NLTKSentenceSegmenter(rg.state_manager).execute(text)
    return seg


@measure
def overview_entity(entity: str, sentseg_fn: Callable[[str], list], max_words: int = 50, max_sents: int = 2) -> Optional[str]:

    """Given a LINKED!!! entity, return the first sentence which should be an overview of the entity.
    If no overview section exist, return empty string

    :param sentseg_fn: a sentence segmenter module that contains a execute(input_data) function
    :type sentseg_fn: a function that takes in a string and returns a list
    :param max_words: the maximum number of words we are allowed, defaults to 80
    :type max_words: int, optional
    :param max_sents: the maximum number of sentences we are allowed, defaults to 3
    :type max_sents: int, optional
    :param entity: a LINKED entity
    :type entity: str
    :return: a string which is the first sentence of an overview section.
    :rtype: str

    >>> overview_entity('Taylor Swift', lambda s: [s[:50]])
    'Taylor Alison Swift (born December 13, 1989) is an.'
    """
    if entity == 'Taylor Swift': # For testing we would like to not use AWS
        section = next(section for section in TAYLOR_SWIFT_SECTIONS if section['title_keyword'] == '')
    elif entity == 'Amazon (company)':
        section = next(section for section in AMAZON_SECTIONS if section['title_keyword'] == '')
    elif entity == 'Dolphin':
        return ''
    elif entity == 'Ronan (song)':
        section = next(section for section in RONAN_SECTIONS if section['title_keyword'] == '')
    else:
        query = {
            "query": {"bool" : {"filter" : [
                {'term': {'doc_title' : entity}},
                {"script" : {
                    "script" : {
                        "source": "doc['title_keyword'].value == ''",
                        "lang": "painless"
                        }
                }}]}
            }
        }
        result = es.search(index='enwiki-20201201-sections', body=query, size=1) # pylint: disable=e1123
        if not result or result['hits']['total']['value'] == 0:
            logger.warning(f"Could not find overview for {entity}. Indicative of mismatch between entity linker and wiki corpus")
            return None
        section = convert_to_dict(result['hits']['hits'][0])
    # summary = get_infilled_prompt(section['text'])
    summary = get_summary(section['text'], sentseg_fn, max_words, max_sents)
    logger.primary_info(f"Summary is: {summary}")
    summary = clean_wiki_text(summary)
    logger.primary_info(f"Summary after clean is: {summary}")
    if contains_offensive(summary):
        logger.primary_info(f"Found {entity}'s overview: {summary} to be offensive, discarding it")
        return None
    return summary

def get_summary(text: str, sentseg_fn : Callable[[str], list], max_words: int = 50, max_sents: int = 2,
                phrases_to_keep: List[str] = []) -> str:
    """This function basically returns a summary of the text. Right now it
    just does a LEAD-2

    :param text: THE TEXT
    :type text: str
    :param max_words: the maximum number of words we allow, defaults to 50
    :type max_words: int, optional
    :param max_sents: the maximum number of sentences we allow, defaults to 2
    :type max_sents: int, optional
    :return: the summarized text.
    :rtype: str
    """
    logger.debug(f'Summarizing text: {text}')
    sentences = sentseg_fn(text)
    if phrases_to_keep:
        contains_phrases = [any(p in s for p in phrases_to_keep) for s in sentences]
    else:
        contains_phrases = [True]*len(sentences)
    summary = ''
    num_sentences = 0
    begin = False

    for sentence, contains_phrase in zip(sentences, contains_phrases):
        if sentence == '':
            continue
        if "|" in sentence or "[" in sentence or "]" in sentence or "{" in sentence or "}" in sentence:
            continue
        if contains_phrase:
            begin=True
        if begin and len(summary.split(' ')) < max_words and num_sentences < max_sents:
            summary += sentence + ('. ' if sentence[-1] not in {'.', '!', '?'} else ' ')
            num_sentences += 1
    return summary

url_regex = r"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)"
def clean_wiki_text(text: str)-> str:
    text = text.strip()
    text = re.sub('\(.*?\)\s*', '', text)
    #Remove things like - thumb|upright|alt=|Felix Mendelssohn aged 12 by Carl Joseph Begas.
    text = re.sub('.*\|.*?\.+\s+', '', text)
    text = re.sub('&amp;', '&', text)
    text = re.sub(url_regex, '', text)
    return text

@measure
def get_section_by_id(section_id : str) -> Optional[dict] :
    """This function retrieves a specific section by its section id. This function is purely
    there to increase speed of retrieval of a specific section

    :param section_id: the id of the section to retrieve
    :type section_id: string
    :return: a dict of format {'title': title, 'text': text, 'score': score, 'section_id': section_id}
    :rtype: dict

    >>> get_section_by_id('H2nbxm4BGLbh6XePmxkI')['title']
    ''
    >>> get_section_by_id('H2nbxm4BGLbh6XePmxkI')['doc_title']
    'Taylor Swift'
    >>> get_section_by_id('JGnbxm4BGLbh6XePmxkI')['title_stack']
    ['Life and career', "2010–2014: ''Speak Now'' and ''Red''"]
    """
    query = {"query": {"ids": {"values": [section_id]}}}
    result = es.search(index='enwiki-20201201-sections', body=query, size=1) # pylint: disable=e1123
    if not result or result['hits']['total']['value'] == 0:
        return None
    return convert_to_dict(result['hits']['hits'][0])


BAD_TIL_PHRASES = ['today']

@measure
@lru_cache(maxsize=128)
def get_til_title(doc_title : str) -> List[Tuple[str, str, str]]:
    """This method gets a TIL for a specific entity

    :param doc_title: the document title (or an WIKI entity)
    :type doc_title: str
    :return: the TIL in readable form, as well as the WIKI document and section it belongs to
    :rtype: List[Tuple[str, str, str]]

    >>> get_til_title('Potato')
    [(' humans can theoretically survive on a diet entirely composed of nothing but potatoes and butter.', 'Potato', 'Nutrition'), ('The Average Potato Has Lost 100% of its Vitamin A Since 1951', 'Potato', 'Nutrition')]
    """
    # We have some hardcoded content for content invariant testing
    if doc_title == 'Taylor Swift':
        return TAYLOR_SWIFT_TILS
    if doc_title == 'Stanford':
        return STANFORD_TILS
    if doc_title in ['Dolphin', 'Amazon (company)', 'Beach']: # blacklist
        return []
    query = {"query": {"bool": {"filter": {"term": {"doc_title": doc_title}}}}}
    tils_on_doc = es.search(index='til', body=query)
    query = {"query": {"bool": {"must": {"match_phrase": {"til": doc_title}}}}}
    tils_mentioning_entity = es.search(index='til', body=query)

    all_tils = tils_on_doc['hits']['hits'] + tils_mentioning_entity['hits']['hits']
    tils = filter(lambda til: doc_title.lower() in til['_source']['til'].lower() or doc_title == til['_source']['doc_title'], all_tils)
    tils = filter(lambda til: not contains_offensive(til['_source']['til']), tils)
    tils = filter(lambda til: not contains_phrase(til['_source']['til'], set(BAD_TIL_PHRASES)), tils)
    #til_texts = filter(lambda text: not (text.split(' ')[0] == 'of'), til_texts) Wanted to filter tils starting with of
    til_texts = map(lambda til: til['_source']['til'], tils)
    til_texts = map(lambda text: re.sub(r'TIL\s*(that)*', '', text), til_texts)
    til_texts = map(lambda text: re.sub(r'[Tt]oday\s[Ii]\s[Ll]earned\s*(that)*', '', text), til_texts)
    til_texts = map(lambda text: re.sub(r'(\(x-post.*)', '', text), til_texts)
    til_doc_titles = map(lambda til: ps.unquote(til['_source']['doc_title']), tils)
    til_section_titles = map(lambda til: ps.unquote(til['_source']['doc_title']), tils)
    return list(zip(til_texts, til_doc_titles, til_section_titles))


def convert_to_dict(result):
    section = result['_source']
    section['title_stack'] = section['title_stack']
    section['wiki_links'] = section['wiki_links'] if 'wiki_links' in section else []
    section['section_id'] = result['_id']
    section['score'] = result['_score']
    return section

def get_item(s : str) -> list:
    """This method will simply get an item from the wiki-entities table with the alias being s.
    It then parses the data into a list of tuples containing the entity and associated page views

    :param s: the alias to an entity, i.e. amazon
    :type s: str
    :return: a list of possible reference to this alias with their (number of references, views), i.e. [("Amazon (company)", (1, 19292)), ...]
    :rtype: list
    """
    if not s:
        return []
    response = table.get_item(Key={'alias':s})
    if 'Item' not in response:
        return [] # no response
    wikipages = [(key, list(map(int, val))) for key, val in response['Item']['wiki-entities'].items()]
    return wikipages


def token_overlap(current_utterance: str, prev_utterance: str):
    current_tokens = set(current_utterance.split(' '))
    prev_tokens = set(prev_utterance.split(' '))
    percentage_overlap = len(current_tokens & prev_tokens) / len(current_tokens)
    return percentage_overlap


TAYLOR_SWIFT_TILS = [(' after Taylor Swift found a blog a mother kept about her 4 year old son\'s battle with cancer, she wrote a song titled his name, "Ronan," and donated all proceeds to cancer research (Performance in comments)', 'Ronan (song)', 'Background')]
STANFORD_TILS = [('in 1905, Jane Stanford, the co-founder of Stanford University, died as a result of intentional poisoning. Her murder was covered up until the 1980s.', 'Jane Stanford', ''), ('Elon Musk moved to California to begin a PhD in Applied Physics at Stanford but left the program after just two days to pursue his entrepreneurial aspirations', 'Elon Musk', 'Early life and education'), ('When asked, after 50 years of research, what he knew about the reason people sleep, William Dement, founder of Stanford University\'s Sleep Research Center, answered, "As far as I know, the only reason we need to sleep that is really, really solid is because we get sleepy."', 'William C. Dement', '')]
RONAN_SECTIONS = [{'offensive': 'false', 'doc_id': '36951105', 'title_keyword': '', 'text': '"Ronan" is a charity single released on September 8, 2012, by American singer-songwriter Taylor Swift to the iTunes Store. Swift\'s lyrics are based on a blog by Maya Thompson about her four-year-old boy Ronan, who died from neuroblastoma in 2011. Swift wrote and produced the song by putting together quotes from the blog, crediting Maya Thompson as co-writer. Swift first performed the song live for Stand Up to Cancer in September 2012, and  has only performed it publicly one other time, when Maya Thompson attended the Glendale, Arizona stop of The 1989 World Tour on August 17, 2015. All proceeds from sales of the single go to help fight cancer.', 'title': '', 'title_stack': [''], 'wiki_links': ['Taylor Swift', 'Music download', 'Soft rock', 'Big Machine Records', 'Taylor Swift', 'We Are Never Ever Getting Back Together', 'Begin Again (Taylor Swift song)', 'Charity record', 'Taylor Swift', 'iTunes Store', 'blog', 'neuroblastoma', 'Stand Up to Cancer', 'New York Daily News', 'Glendale, Arizona', 'The 1989 World Tour', 'Entertainment Weekly'], 'doc_title': 'Ronan (song)', 'section_id': 'qTVq-G8BtLQBgyHGqwuU', 'score': 0.0}, {'offensive': 'false', 'doc_id': '36951105', 'title_keyword': 'Background', 'text': 'Swift wrote the song after reading Maya Thompson\'s blog. Thompson is the mother of four-year-old Ronan Thompson, who died in 2011 of neuroblastoma. He had been treated at Barrow Neurological Institute at Phoenix Children\'s Hospital. Maya began writing in August 2010 when Ronan was diagnosed and she continued penning her entries in the blog Rockstar Ronan during the nine months that Ronan suffered from the illness before dying in May 2011, just three days before his fourth birthday. Maya worked through her grief by continuing the blog, writing heartbreaking letters to her late son whilst raising money and awareness for childhood cancer causes.\n\nThe pair met in October 2011, when Swift invited Maya to her concert at the Jobing.com Arena in Glendale, Arizona. She wrote about her reaction when Taylor told her that she\'d penned the song inspired by her blog entries, "My calmness soon turned to complete and utter frozen shock when these words came out of her mouth. \'I wrote a song for Ronan.\'" Thompson added, addressing her late son, "\'The tears started pouring down my cheeks as soon as I heard her say those words. But her words didn\'t stop there. Not only did she write a song for you, but she wanted to know if it would be alright to perform it on the nationally televised show." Swift credits Thompson as the co-writer of the song. It was released to the US iTunes Store shortly after the Stand Up to Cancer telethon ended, and all proceeds of the single go towards cancer charities.', 'title': 'Background', 'title_stack': ['Background'], 'wiki_links': ["Barrow Neurological Institute at Phoenix Children's", 'Jobing.com Arena', 'iTunes Store', 'telethon', 'MSN', 'Microsoft'], 'doc_title': 'Ronan (song)', 'section_id': 'qjVq-G8BtLQBgyHGqwuU', 'score': 0.0}, {'offensive': 'false', 'doc_id': '36951105', 'title_keyword': 'Critical reception', 'text': '"Ronan" received universal acclaim from critics. Rolling Stone called the song "heartbreaking". Bill Dukes of Taste of Country wrote: "It was clear [Swift] was just the voice for Maya Thompson..." Ed Masley of The Arizona Republic said that "\'Ronan\' may very well be [Swift\'s] finest hour as an artist."', 'title': 'Critical reception', 'title_stack': ['Critical reception'], 'wiki_links': ['Rolling Stone', 'Rolling Stone', 'The Arizona Republic'], 'doc_title': 'Ronan (song)', 'section_id': 'rDVq-G8BtLQBgyHGqwuU', 'score': 0.0}]
TAYLOR_SWIFT_SECTIONS = [{'offensive': 'true', 'doc_id': '5422144', 'title_keyword': '2008–2010: Fearless and acting', 'text': 'Swift\'s second studio album, Fearless, was released on November 11, 2008. The lead single, "Love Story", was released in September 2008. It peaked at number four on the Billboard Hot 100 and number one in Australia. Four more singles were released throughout 2008 and 2009: "White Horse", "You Belong with Me", "Fifteen" and "Fearless". "You Belong with Me" was the album\'s highest-charting single on the Billboard Hot 100, peaking at number two. The album debuted at number one on the Billboard 200 and was the top-selling album of 2009 in the United States. Swift\'s first concert tour, the Fearless Tour, promoted the album; it grossed over $63\xa0million. Taylor Swift: Journey to Fearless, a concert film, was aired on television and later released on DVD and Blu-ray. Swift also performed as a supporting act for Keith Urban\'s Escape Together World Tour.\n\nIn 2009, the music video for "You Belong with Me" was named MTV Video Music Award for Best Female Video. Her acceptance speech was interrupted by rapper Kanye West. The incident was the subject of controversy and widespread media attention, resulting in many Internet memes. James Montgomery of MTV argued the incident and subsequent media attention turned Swift into "a bona-fide mainstream celebrity". That year she won five American Music Awards, including Artist of the Year and Favorite Country Album. Billboard named her 2009\'s Artist of the Year. The album ranked number 99 on NPR\'s 2017 list of the 150 Greatest Albums Made By Women.\n\nAt the 52nd Annual Grammy Awards, Fearless was named Album of the Year and Best Country Album, and "White Horse" was named Best Country Song and Best Female Country Vocal Performance. Swift was the youngest artist to win Album of the Year. During the ceremony, Swift sang "You Belong with Me" and "Rhiannon" with Stevie Nicks. Her performance received negative reviews and caused a media backlash. Jon Caramanica of The New York Times found it "refreshing to see someone so gifted make the occasional flub" and described Swift as "the most important new pop star of the past few years". Swift became the youngest artist to be named Entertainer of the Year by the Country Music Association. Fearless also won the Association\'s Album of the Year award.\n\nSwift contributed backing vocals to John Mayer\'s "Half of My Heart", a single featured on his fourth album, Battle Studies (2009). She co-wrote and recorded "Best Days of Your Life" with Kellie Pickler, and co-wrote two songs for the Hannah Montana: The Movie soundtrack—"You\'ll Always Find Your Way Back Home" and "Crazier". Swift also provided vocals for Boys Like Girls\' "Two Is Better Than One". She contributed two songs to the Valentine\'s Day soundtrack, including "Today Was a Fairytale", which became her first number one on the Canadian Hot 100 chart. While filming her cinematic debut Valentine\'s Day in October 2009, Swift began a romantic relationship with co-star Taylor Lautner; they broke up later that year. The romantic comedy, released the following year, saw her play the ditzy girlfriend of a high school jock, a role which the Los Angeles Times felt showed Swift had "serious comedic potential". In a scathing review, a critic for Variety deemed her "entirely undirected", arguing "she needs to find a skilled director to tamp her down and channel her obviously abundant energy".\n\nSwift made her TV acting debut in a 2009 episode of CBS\'s CSI: Crime Scene Investigation, playing a rebellious teenager. The New York Times noted the character allowed Swift to be "a little bit naughty, and credibly so". Later that year, Swift both hosted and performed as the musical guest on an episode of Saturday Night Live. Entertainment Weekly described her as "this season\'s best Saturday Night Live host so far", noting she "was always up for the challenge, seemed to be having fun, and helped the rest of the cast nail the punchlines".', 'title': '2008–2010: Fearless and acting', 'title_stack': ['Life and career', '2008–2010: Fearless and acting'], 'wiki_links': ['Fearless (Taylor Swift album)', 'Love Story (Taylor Swift song)', 'ARIA Charts', 'White Horse (Taylor Swift song)', 'You Belong with Me', 'Fifteen (song)', 'Fearless (Taylor Swift song)', 'Billboard (magazine)', 'Yahoo! Music', 'Fearless Tour', 'Rolling Stone', 'Billboard (magazine)', 'Taylor Swift: Journey to Fearless', 'American Songwriter', 'Keith Urban', 'Great American Country', 'MTV Video Music Award for Best Female Video', 'Kanye West MTV Video Music Awards controversy', 'Kanye West', 'Rolling Stone', 'Internet meme', 'MTV', 'MTV', 'MTV', 'American Music Award for Artist of the Year', 'MTV', 'Billboard Music Award#Artist of the Year awards', 'Billboard (magazine)', 'NPR', 'NPR', '52nd Annual Grammy Awards', 'Grammy Award for Album of the Year', 'Grammy Award for Best Country Album', 'Grammy Award for Best Country Song', 'Grammy Award for Best Female Country Vocal Performance', 'Rolling Stone', 'Rhiannon (song)', 'Stevie Nicks', 'Rolling Stone', 'The New York Times', 'MTV News', 'Big Machine Records', 'PR Newswire', 'John Mayer', 'Half of My Heart', 'Battle Studies (album)', 'MTV', 'Best Days of Your Life', 'Kellie Pickler', 'MTV', 'Hannah Montana: The Movie (soundtrack)', "You'll Always Find Your Way Back Home", 'Crazier (Taylor Swift song)', 'iTunes Store', 'Boys Like Girls', 'Two Is Better Than One', 'Seventeen (American magazine)', "Valentine's Day (soundtrack)", 'Today Was a Fairytale', 'Canadian Hot 100', 'MTV', 'Billboard (magazine)', "Valentine's Day (2010 film)", 'Taylor Lautner', 'People (magazine)', 'Billboard (magazine)', 'Los Angeles Times', 'Los Angeles Times', 'Variety (magazine)', 'Variety (magazine)', 'CBS', 'CSI: Crime Scene Investigation', 'The New York Times', 'Saturday Night Live', 'Billboard (magazine)', 'Entertainment Weekly', 'Entertainment Weekly'], 'doc_title': 'Taylor Swift', 'section_id': 'o5Sc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'true', 'doc_id': '5422144', 'title_keyword': '2014–2017: 1989', 'text': 'In March 2014, Swift relocated to New York City. Around this time, she was working on her fifth studio album, 1989, with co-writers Antonoff, Max Martin, Shellback, Imogen Heap, Ryan Tedder, and Ali Payami. She promoted the album through various campaigns, including inviting fans to secret album-listening sessions. Credited as her "first documented, official pop album", it marked a departure from her country albums. The album was released on October 27, 2014, to positive reviews.\n\n1989 sold 1.28\xa0million copies in the U.S. during the first week of its release and debuted atop the Billboard 200. This made Swift the first act to have three albums sell more than one million copies in their opening release week, for which she earned another Guinness World Record. As of June 2017, 1989 had sold over 10 million copies worldwide. The lead single, "Shake It Off", was released in August 2014 and debuted at number one on the Billboard Hot 100. The album generated two additional number-one singles—"Blank Space" and "Bad Blood" (featuring Kendrick Lamar)—as well as the top-ten entries "Style" and "Wildest Dreams", and other singles "Out of the Woods" and "New Romantics". "Shake It Off", "Blank Space", and "Bad Blood" also topped the charts in Australia and Canada. After "Blank Space" reached number one in the U.S. following "Shake It Off", Swift became the first woman in the Hot 100\'s history to "succeed herself at the top spot". The music video for "Blank Space" was briefly the fastest video to reach one billion views on Vevo. The videos for "Blank Space" and "Bad Blood" earned four nominations at the 2015 MTV Video Music Awards. "Bad Blood" won Video of the Year and Best Collaboration. Swift\'s headlining tour, the 1989 World Tour, running from May to December 2015, grossed over $250\xa0million, and was highest-grossing tour of the year.\n\nSwift was named Billboards Woman of the Year in 2014—the first artist to win the award twice. That year she also received the Dick Clark Award for Excellence at the American Music Awards. In 2015, "Shake It Off" was nominated for three Grammy Awards, including Record of the Year and Song of the Year; Swift won the Brit Award for International Female Solo Artist. Swift was one of eight artists to receive a 50th Anniversary Milestone Award at the 2015 Academy of Country Music Awards. In 2016, she won three Grammy Awards for 1989—Album of the Year, Best Pop Vocal Album, and Best Music Video for "Bad Blood". She became the first woman, and the fifth act, to win the first of these twice.\n\nPrior to 1989s release, Swift stressed the importance of albums to artists and fans. In November 2014, she removed her entire catalog from the streaming service Spotify, arguing that its ad-supported free service undermined the premium service, which provides higher royalties for songwriters. In a June 2015 open letter, Swift criticized Apple Music for not offering royalties to artists during their free three-month trial period and said she would pull 1989 from the catalog. The following day, Apple announced it would pay artists during the free trial period, and Swift agreed to stream 1989 on their streaming service. Swift\'s intellectual property rights management and holding company, TAS Rights Management, filed for 73 trademarks related to Swift and the 1989 era memes. She re-released her entire catalog plus 1989 to Spotify, Amazon Music and Google Play and other digital streaming platforms in June 2017.\n\nIn 2015, Swift performed "I Saw Her Standing There" and "Shake It Off" with Paul McCartney at the Saturday Night Live 40th Anniversary Special after-party. She joined Kenny Chesney to sing "Big Star" on the opening night of his Big Revival Tour in Nashville. In March 2015, Swift started dating Scottish DJ and record producer Calvin Harris. By June 2015, the duo were ranked as the highest-paid celebrity couple over the past year by Forbes with combined earnings of over $146\xa0million. Before Swift and Harris announced the end of their relationship in June 2016, they co-wrote his song "This Is What You Came For" (featuring Rihanna), for which she was initially credited under the pseudonym Nils Sjöberg. The same month Swift began dating English actor Tom Hiddleston; the relationship ended several months later. In August, Swift addressed her mother\'s cancer diagnosis and encouraged others to get a medical checkup. In September 2016, Swift began dating British actor Joe Alwyn. In October, Little Big Town released "Better Man", written solely by Swift, for their seventh album, The Breaker. She had emailed them the song and offered it to them, having their vocal harmonies in mind. The song earned Swift an award for Song of the Year at the 51st CMA Awards. Two months later, Swift and British singer Zayn Malik released a single together called "I Don\'t Wanna Live Forever", for the soundtrack of the film Fifty Shades Darker (2017). The song reached number one in Sweden and peaked at number two in the United States. At the 2017 MTV Video Music Awards, the duo won the award for Best Collaboration for the song\'s music video.', 'title': '2014–2017: 1989', 'title_stack': ['Life and career', '2014–2017: 1989'], 'wiki_links': ['The Atlantic', '1989 (Taylor Swift album)', 'Max Martin', 'Shellback (record producer)', 'Imogen Heap', 'Ryan Tedder', 'Ali Payami', 'Compact disc', 'liner notes', 'Big Machine Records', 'Billboard (magazine)', 'USA Today', 'Metacritic', 'Billboard (magazine)', 'Guinness World Records', 'International Federation of the Phonographic Industry', 'Shake It Off', 'Billboard (magazine)', 'Blank Space', 'Bad Blood (Taylor Swift song)', 'Kendrick Lamar', 'Style (Taylor Swift song)', 'Wildest Dreams (Taylor Swift song)', 'Out of the Woods (song)', 'New Romantics (song)', 'Billboard (magazine)', 'Billboard (magazine)', 'Vevo', 'Billboard (magazine)', '2015 MTV Video Music Awards', 'MTV Video Music Award for Video of the Year', 'MTV Video Music Award for Best Collaboration', 'Billboard (magazine)', 'the 1989 World Tour', 'Billboard (magazine)', 'Billboard (magazine)', 'Dick Clark', 'American Music Awards of 2014', 'Billboard (magazine)', 'Brit Award for International Female Solo Artist', 'Billboard (magazine)', 'The Guardian', 'Rolling Stone', 'Grammy Award for Best Pop Vocal Album', 'Grammy Award for Best Music Video', 'Billboard (magazine)', 'Slate (magazine)', 'Streaming media', 'Spotify', 'Rolling Stone', 'Apple Music', 'Billboard (magazine)', 'Apple Inc.', 'Billboard (magazine)', 'Entertainment Weekly', 'intellectual property', 'trademark', 'The National Law Review', 'Amazon Music', 'Google Play', 'BBC News', 'I Saw Her Standing There', 'Paul McCartney', 'Saturday Night Live 40th Anniversary Special', 'Entertainment Weekly', 'Kenny Chesney', 'Big Star (Kenny Chesney song)', 'The Big Revival Tour', 'The Tennessean', 'Calvin Harris', 'People (magazine)', 'Forbes', 'Time (magazine)', 'People (magazine)', 'This Is What You Came For', 'Rihanna', 'pseudonym', 'Rolling Stone', 'Tom Hiddleston', 'Cosmopolitan (magazine)', 'cancer', 'general medical examination', 'Entertainment Tonight', 'Joe Alwyn', 'Cosmopolitan (magazine)', 'Elle (magazine)', 'Little Big Town', 'Better Man (Little Big Town song)', 'The Breaker (album)', 'Elle (magazine)', 'Hits Daily Double', '51st Annual Country Music Association Awards', 'USA Today', 'Zayn Malik', "I Don't Wanna Live Forever", 'Fifty Shades Darker: Original Motion Picture Soundtrack', 'Fifty Shades Darker (film)', 'Billboard (magazine)', '2017 MTV Video Music Awards', 'CNN'], 'doc_title': 'Taylor Swift', 'section_id': 'pZSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'false', 'doc_id': '5422144', 'title_keyword': '2019: Lover', 'text': 'Swift released "Me!", featuring Brendon Urie of Panic! at the Disco on April 26, 2019, as the lead single from her seventh studio album, Lover. The song debuted at number 100 on the Billboard Hot 100 three days after its release, and jumped to number two the following week—the biggest single-week jump in the Hot 100\'s history. The music video for "Me!" broke a Vevo record by amassing 65.2\xa0million views within its first day of release. On June 14, she released the second single "You Need to Calm Down", which debuted and peaked at number two on the Billboard Hot 100, and gave a surprise performance at the Stonewall Inn in Greenwich Village, Manhattan, to commemorate Stonewall 50 – WorldPride NYC 2019. On July 23, she released a promotional single from the album, "The Archer". The title track was released as the third single on August 16.\n\nLover was released on August 23 to positive reviews, and debuted atop the Billboard 200 with first-week sales of 679,000 copies. Upon the album\'s release, all of its 18 songs entered the Billboard Hot 100, setting the record for the most simultaneous chart entries for a female artist. At the 2019 MTV Video Music Awards, the videos for "Me!" and "You Need to Calm Down" received twelve nominations. "Me!" won Best Visual Effects, and "You Need to Calm Down" won Video of the Year and Video for Good.\n\nIn June, Big Machine, Swift\'s former record label, was purchased by music manager Scooter Braun, including the masters for her first six albums. Swift voiced her displeasure in a Tumblr post, saying she had been trying to buy the masters for years and describing Braun as an "incessant, manipulative bully". In August, Swift announced plans to rerecord the albums in November 2020. Swift was cast as Bombalurina in the movie adaptation of Andrew Lloyd Webber\'s musical Cats, which will be released on December 20, 2019.', 'title': '2019: Lover', 'title_stack': ['Life and career', '2019: Lover'], 'wiki_links': ['Me!', 'Brendon Urie', 'Panic! at the Disco', 'Lover (album)', 'The New York Times', 'NPR', 'Billboard (magazine)', 'Vevo record', 'Forbes', 'You Need to Calm Down', 'Billboard (magazine)', 'Billboard (magazine)', 'Stonewall Inn', 'Greenwich Village', 'Stonewall 50 – WorldPride NYC 2019', 'CNN', 'The Archer (song)', 'Rolling Stone', 'Lover (Taylor Swift song)', 'Billboard (magazine)', 'Metacritic', 'Billboard (magazine)', '2019 MTV Video Music Awards', 'MTV Video Music Award for Best Visual Effects', 'MTV Video Music Award for Best Video with a Social Message', 'Pitchfork (website)', 'Scooter Braun', 'Mastering (audio)', 'Tumblr', 'BBC News', 'Bombalurina (cat)', 'Cats (2019 film)', 'Andrew Lloyd Webber', 'Cats (musical)'], 'doc_title': 'Taylor Swift', 'section_id': 'p5Sc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'false', 'doc_id': '5422144', 'title_keyword': 'Musical style', 'text': 'Swift\'s music contains elements of pop, pop rock, country and country pop. She described herself as a country artist until the 2014 release of 1989, which she characterized as a "sonically cohesive pop album". Rolling Stone wrote: "[Swift] might get played on the country station, but she\'s one of the few genuine rock stars we\'ve got these days." According to The New York Times, "There isn\'t much in Ms. Swift\'s music to indicate country—a few banjo strums, a pair of cowboy boots worn onstage, a bedazzled guitar—but there\'s something in her winsome, vulnerable delivery that\'s unique to Nashville." The Guardian wrote that Swift "cranks melodies out with the pitiless efficiency of a Scandinavian pop factory."\n\nSwift\'s vocals were described by Sophie Schillaci of The Hollywood Reporter as "sweet, but soft". The Los Angeles Times identified Swift\'s "defining" vocal gesture in studio recordings as "the line that slides down like a contented sigh or up like a raised eyebrow, giving her beloved girl-time hits their air of easy intimacy". Rolling Stone, in a Speak Now review, wrote: "Swift\'s voice is unaffected enough to mask how masterful she has become as a singer; she lowers her voice for the payoff lines in the classic mode of a shy girl trying to talk tough." In another review of Speak Now, The Village Voice wrote that her phrasing was previously "bland and muddled, but that\'s changed. She can still sound strained and thin, and often strays into a pitch that drives some people crazy; but she\'s learned how to make words sound like what they mean." The Hollywood Reporter wrote that her live vocals are "fine", but they do not match those of her peers. In 2009, Ken Tucker\xa0of Entertainment Weekly described Swift\'s vocals as "flat, thin, and sometimes as wobbly as a newborn colt". However, Swift has been praised for refusing to correct her pitch with Auto-Tune.\n\nIn an interview with The New Yorker, Swift characterized herself primarily as a songwriter: "I write songs, and my voice is just a way to get those lyrics across." A writer for The Tennessean conceded in 2010 that Swift is "not the best technical singer", but described her as the "best communicator that we\'ve got". Swift\'s vocal presence is something that concerns her and she has "put a lot of work" into improving it. It was reported in 2010 that she continues to take vocal lessons. She has said that she only feels nervous performing "if I\'m not sure what the audience thinks of me, like at award shows".', 'title': 'Musical style', 'title_stack': ['Artistry', 'Musical style'], 'wiki_links': ['Pop music', 'pop rock', 'Country music', 'Rolling Stone', 'country pop', 'The Daily Telegraph', 'The Tennessean', 'Rolling Stone', 'The New York Times', 'The Guardian', 'The Guardian', 'The Hollywood Reporter', 'The Hollywood Reporter', 'Los Angeles Times', 'Rolling Stone', 'The Village Voice', 'The Village Voice', 'Reuters', 'Auto-Tune', 'Boston Globe', 'The New Yorker', 'The Tennessean', 'The Tennessean', 'Billboard (magazine)', 'The New York Times', 'Teen Vogue'], 'doc_title': 'Taylor Swift', 'section_id': 'qZSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'true', 'doc_id': '5422144', 'title_keyword': 'Philanthropy', 'text': 'Swift\'s philanthropic efforts have been recognized by the Do Something Awards and the Tennessee Disaster Services. She has also received The Big Help Award for her "dedication to helping others" and "inspiring others through action", and the Ripple of Hope Award for her "dedication to advocacy at such a young age". As she presented the award to Swift, RFK Center President Kerry Kennedy said: "Taylor is just the kind of woman we want our daughters to be: authentic and mighty. Willing to take a risk and strong enough to walk away." In 2008, she donated $100,000 to the Red Cross to help the victims of the flood in Iowa that year. Swift has performed at charity relief events including Sydney\'s Sound Relief concert. She also recorded a song for the Hope for Haiti Now album. In response to the May 2010 Tennessee floods, Swift donated $500,000 during a telethon hosted by WSMV. In 2011, Swift used a dress rehearsal of her Speak Now tour as a benefit concert for victims of recent tornadoes in the United States, raising more than $750,000. In 2012, Swift supported Architecture for Humanity\'s Restore the Shore MTV telethon in the aftermath of Hurricane Sandy. In 2016, she made a $1,000,000 donation to Louisiana flood relief efforts and donated to the Dolly Parton Fire Fund. In 2017, Swift made a donation to the Houston Food Bank after Hurricane Harvey struck the city.\n\nSwift is a supporter of the arts and donated $75,000 to Nashville\'s Hendersonville High School in 2010 to help refurbish the school auditorium. In 2012, she pledged $4\xa0million to fund the building of a new education center at the Country Music Hall of Fame and Museum in Nashville. Also, in 2012 Swift partnered with textbook rental company Chegg to donate $60,000 to the music departments of six U.S. colleges. Swift also promotes children\'s literacy. In 2009, she donated $250,000 to various schools around the country to improve education. Her other endeavors to promote literacy included donating 6,000 Scholastic books to the Reading Public Library in Pennsylvania; 14,000 books to the Nashville Public Library in Tennessee; 2,000 Scholastic books to the Reading Hospital Child Health Center\'s early literacy program; and 25,000 books to New York City schools in 2015. The same year, Swift donated all proceeds from the sale of the promotional single "Welcome to New York", at the time $50,000, to the New York City Department of Education. In 2019, Swift sampled a song by the Toronto-based Regent Park School of Music in her album Lover, thus enabling the school to earn royalties from her album; she also made a personal donation.\n\nIn 2007, she launched a campaign to protect children from online predators, in partnership with the Tennessee Association of Chiefs of Police. In 2009, Swift recorded a Sound Matters public service announcement (PSA) to make listeners aware of the importance of listening "responsibly" to prevent hearing impairment. Swift has donated items to several charities for auction, including: the Elton John AIDS Foundation, the UNICEF Tap Project, MusiCares, and Feeding America. As a recipient of the Academy of Country Music\'s Entertainer of the Year in 2011, Swift donated $25,000 to St. Jude Children\'s Research Hospital, Tennessee. In 2012, Swift participated in the Stand Up to Cancer telethon, performing "Ronan", a song she wrote in memory of a four-year-old boy who died of neuroblastoma. The song was made available for digital download with all proceeds donated to cancer-related charities. In 2014, she donated $100,000 to the V Foundation for Cancer Research, and $50,000 to the Children\'s Hospital of Philadelphia. She has made private visits to hospitals to meet with sick patients and support them. Swift has encouraged young people to volunteer in their local communities as part of Global Youth Service Day.\n\nIn 2018, Swift collaborated with 300 women in Hollywood to set up the Time\'s Up initiative to protect women from harassment and discrimination, and donated $100,000 to its legal defense fund. In March 2018, she donated to March for Our Lives. In April 2018, Swift donated to the Rape, Abuse & Incest National Network in support of Sexual Assault Awareness Month. On May 7, 2018, the day before her Reputation Stadium Tour kicked off, Swift invited 2,000 foster and adopted children to a dress rehearsal at Glendale, Arizona. Later that year, Swift made a surprise appearance at a benefit concert in New York City raising money for LGBT equality. In April 2019, Swift donated $113,000 to the LGBT organization Tennessee Equality Project. Swift donated an undisclosed sum to the media advocacy organization GLAAD in support of Pride Month in June 2019.', 'title': 'Philanthropy', 'title_stack': ['Other ventures', 'Philanthropy'], 'wiki_links': ['Do Something Awards', 'HuffPost', 'Taste of Country', 'Taste of Country', 'Kerry Kennedy', 'PR Newswire', 'Iowa flood of 2008', 'People (magazine)', 'Sound Relief', 'The Daily Telegraph (Sydney)', 'MTV', 'May 2010 Tennessee floods', 'WSMV-TV', 'CNS News', 'April 25–28, 2011 tornado outbreak', 'Los Angeles Times', 'Architecture for Humanity', 'Hurricane Sandy', 'Taste of Country', '2016 Louisiana floods', 'The Guardian', 'Entertainment Tonight', 'Hurricane Harvey', 'Elle (magazine)', 'The Tennessean', 'Country Music Hall of Fame and Museum', 'The New York Times', 'Chegg', 'VH1', 'literacy', 'People (magazine)', 'Scholastic Corporation', 'Reading Public Library', 'Reading Eagle', 'Nashville Public Library', 'Taste of Country', 'Reading Hospital', 'Entertainment Weekly', 'Welcome to New York (song)', 'New York City Department of Education', 'Billboard (magazine)', 'Regent Park', 'Lover (album)', 'The Globe and Mail', 'Nash Country Weekly', 'public service announcement', 'hearing impairment', 'Elton John AIDS Foundation', 'UNICEF Tap Project', 'MusiCares', 'Feeding America', 'PR Newswire', 'Taste of Country', 'RTTNews', "St. Jude Children's Research Hospital", 'The Tennessean', 'Stand Up to Cancer', 'Ronan (song)', 'neuroblastoma', 'music download', 'Rolling Stone', 'Dick Vitale', 'Tampa Bay Times', "Children's Hospital of Philadelphia", 'The Business Journals', 'The Patriot-News', 'Politico', 'The Tennessean', 'Global Youth Service Day', 'CMT (U.S. TV channel)', "Time's Up (movement)", 'Variety (magazine)', 'People (magazine)', 'March for Our Lives', 'Rolling Stone', 'Rape, Abuse & Incest National Network', 'Sexual Assault Awareness Month', 'Billboard (magazine)', 'Glendale, Arizona', 'Teen Vogue', 'Pitchfork (website)', 'Tennessee Equality Project', 'Billboard (magazine)', 'GLAAD', 'Pride Month', 'GLAAD'], 'doc_title': 'Taylor Swift', 'section_id': 'rZSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'false', 'doc_id': '5422144', 'title_keyword': 'Product endorsements', 'text': "While promoting her debut album, Swift appeared as the face of Verizon Wireless' Mobile Music campaign. In the Fearless era, she launched a l.e.i. sundress range at Wal-Mart, and designed American Greetings cards and Jakks Pacific dolls. She became a spokesperson for the National Hockey League's (NHL) Nashville Predators and Sony Cyber-shot digital cameras. In the Speak Now era, she released a special edition of her album through Target. Swift became a CoverGirl spokesmodel, and launched two Elizabeth Arden fragrances—Wonderstruck and Wonderstruck Enchanted.\n\nWhile promoting her fourth album, Red, Swift offered exclusive album promotions through Target, Papa John's Pizza, and Walgreens. She became a spokesmodel for Diet Coke, and Keds sneakers, released her third Elizabeth Arden fragrance named Taylor by Taylor Swift, and continued her partnerships with Sony Electronics and American Greetings. Swift also partnered with the companies AirAsia and Qantas during the Red Tour. These acted as the official airlines for the Australian and Asian legs; Cornetto sponsored the Asian leg of the tour. While promoting 1989, Swift had tie-ins with Subway, Keds, Target and Diet Coke. In 2014, Swift released her fourth fragrance, Incredible Things.\n\nSwift signed a multi-year deal with AT&T in 2016. She later headlined DirecTV's Super Saturday Night, the night prior to the 2017 Super Bowl. While promoting Reputation, Swift released a series of behind-the-scenes videos showing the album recording process through DirecTV. In 2018, Swift released two commercials for AT&T. The same year, Swift partnered with Fujifilm on a special-edition autographed Instax camera, which includes a selfie-mode and double exposure. In 2019, Swift signed a multi-year partnership with Capital One.", 'title': 'Product endorsements', 'title_stack': ['Other ventures', 'Product endorsements'], 'wiki_links': ['Verizon Wireless', 'Great American Country', 'l.e.i.', 'Wal-Mart', "Women's Wear Daily", 'American Greetings', 'Jakks Pacific', 'E!', 'National Hockey League', 'Nashville Predators', 'Cyber-shot', 'AOL', 'Sony', 'Target Corporation', 'The Business Journals', 'CoverGirl', 'Newsday', 'Elizabeth Arden#Elizabeth Arden today', 'Wonderstruck (fragrance)', 'Rolling Stone', 'E!', "Papa John's Pizza", 'PR Newswire', 'Walgreens', 'Billboard (magazine)', 'Diet Coke', 'Keds (shoes)', 'Advertising Age', 'Billboard (magazine)', 'Taste of Country', 'PR Newswire', 'AirAsia', 'Qantas', 'Qantas', 'Cornetto (ice cream)', 'Subway (restaurant)', 'Billboard (magazine)', 'InStyle', 'AT&T', 'DirecTV', 'Super Bowl', 'Fortune (magazine)', 'Rolling Stone', 'Billboard (magazine)', 'Fujifilm', 'Instax', 'double exposure', 'Billboard (magazine)', 'CNET', 'Capital One', 'Cision'], 'doc_title': 'Taylor Swift', 'section_id': 'r5Sc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'true', 'doc_id': '5422144', 'title_keyword': '2017–2019: Reputation', 'text': 'In August 2017, Swift successfully sued David Mueller, a former morning show personality for Denver\'s KYGO-FM. Four years earlier, Swift had informed Mueller\'s bosses that he had sexually assaulted her by groping her at an event. After being fired, Mueller accused Swift of lying and sued her for damages from his loss of employment. Shortly after, Swift counter-sued for sexual assault. The jury rejected Mueller\'s claims and ruled in favor of Swift. Swift thereafter cleared her social media accounts and then released "Look What You Made Me Do" as the lead single from her sixth album, Reputation. The song topped the charts in Australia, Ireland, New Zealand, the United Kingdom, and the United States.Peak positions: Its music video had over 43.2\xa0million views during its first day on YouTube, breaking the site\'s record for the most-viewed music video in 24 hours. In October, Swift released the album\'s second single "...Ready for It?", which charted at number three in Australia and at number four in the United States.\n\nTwo promotional singles were released from Reputation, "Gorgeous" and "Call It What You Want". "Gorgeous" later became the album\'s fifth single but was released as such only in Europe. The album was released on November 10. It sold 1.216\xa0million copies in the United States becoming 2017\'s the country\'s top-selling album (pure sales only). First-week worldwide sales amounted to two million copies. With this achievement, she became the first act to have four albums sell one million copies within one week in the U.S. The album topped the charts in several countries, including the U.S., the UK, Australia, and Canada. Later that month, Swift performed "...Ready for It?" and "Call It What You Want" on Saturday Night Live. "End Game", featuring Ed Sheeran and rapper Future, followed in November as the third single; it peaked at number 18 in the U.S. Other singles from the album include "New Year\'s Day" released exclusively to country radio, and "Delicate".\n\nIn April 2018, Swift featured on Sugarland\'s "Babe" from their album Bigger. In support of Reputation, Swift embarked on her Reputation Stadium Tour from May to November 2018. The tour broke multiple venue attendance and gross earnings records in the United States, taking in $266.1\xa0million—selling more than two million tickets. Swift broke her own record for the highest-grossing domestic tour by a woman and surpassed The Rolling Stones\' $245\xa0million-grossing A Bigger Bang Tour (2005–2007). Worldwide, the tour grossed $345.7\xa0million, making it the second highest-grossing concert tour of the year. At the American Music Awards of 2018, Swift won Tour of the Year award, Artist of the Year, Favorite Pop/Rock Female Artist, and Favorite Pop/Rock Album for Reputation. With a total of 23 awards, she became the most awarded female winner in AMA history, a record previously held by Whitney Houston. Reputation was nominated for a Grammy Award in the Best Pop Vocal Album category.\n\nReputation was Swift\'s last album under her 12-year contract with Big Machine Records. In November 2018, Swift signed a new multi-album deal with Big Machine\'s distributor Universal Music Group; in the United States, her future releases will be promoted under the Republic Records imprint. Swift said the contract included a provision for her to maintain ownership of her master recordings. In addition, in the event that Universal sells any part of its stake in Spotify, Spotify agreed to distribute a non-recoupable portion of the proceeds among their artists. In late November, Big Machine Records released a Reputation Stadium Tour playlist for streaming services. The playlist includes every song performed on B-stages during the Reputation Stadium Tour. On December 31, Reputation Stadium Tour, a concert film, was released on Netflix.', 'title': '2017–2019: Reputation', 'title_stack': ['Life and career', '2017–2019: Reputation'], 'wiki_links': ['Denver', 'KYGO-FM', 'CNN', 'The Daily Telegraph', 'Look What You Made Me Do', 'Reputation (Taylor Swift album)', 'Variety (magazine)', 'Irish Recorded Music Association', 'Recorded Music NZ', 'Official Charts Company', 'Billboard (magazine)', 'Los Angeles Times', '...Ready for It?', 'Australian Recording Industry Association', 'Gorgeous (Taylor Swift song)', 'Call It What You Want (Taylor Swift song)', 'Billboard (magazine)', 'Billboard (magazine)', 'BBC Radio 1', 'Billboard (magazine)', 'Lists of fastest-selling albums', 'Billboard (magazine)', 'Billboard (magazine)', 'Variety (magazine)', 'End Game (song)', 'Ed Sheeran', 'Future (rapper)', 'Billboard (magazine)', "New Year's Day (Taylor Swift song)", 'Delicate (Taylor Swift song)', 'Billboard (magazine)', 'Billboard (magazine)', 'Sugarland', 'Babe (Sugarland song)', 'Bigger (album)', 'Pat Monahan', 'Train (band)', 'Red (Taylor Swift album)', 'Rolling Stone', "Taylor Swift's Reputation Stadium Tour", 'Billboard (magazine)', 'The 1989 World Tour', 'Billboard (magazine)', 'A Bigger Bang Tour', 'Billboard (magazine)', 'Forbes', 'American Music Awards of 2018', 'American Music Award for Tour of the Year', 'American Music Award for Favorite Pop/Rock Female Artist', 'American Music Award for Favorite Pop/Rock Album', 'Whitney Houston', 'Billboard (magazine)', 'Rolling Stone', 'Universal Music Group', 'Republic Records', 'master recording', 'Rolling Stone', 'Variety (magazine)', 'Variety (magazine)', 'Billboard (magazine)', 'Netflix', 'Billboard (magazine)'], 'doc_title': 'Taylor Swift', 'section_id': 'ppSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'false', 'doc_id': '5422144', 'title_keyword': 'Influences', 'text': 'One of Swift\'s earliest musical memories is listening to her maternal grandmother, Marjorie Finlay, sing in church. As a child, she enjoyed Disney film soundtracks: "My parents noticed that, once I had run out of words, I would just make up my own". Swift has said she owes her confidence to her mother, who helped her prepare for class presentations as a child. She also attributes her "fascination with writing and storytelling" to her mother. Swift was drawn to the storytelling aspect of country music, and was introduced to the genre listening to "the great female country artists of the \'90s"—Shania Twain, Faith Hill, and the Dixie Chicks. Twain, both as a songwriter and performer, was her biggest musical influence. Hill was Swift\'s childhood role model: "Everything she said, did, wore, I tried to copy it". She admired the Dixie Chicks\' defiant attitude and their ability to play their own instruments. The band\'s "Cowboy Take Me Away" was the first song Swift learned to play on the guitar. Swift also explored the music of older country stars, including Patsy Cline, Loretta Lynn, Dolly Parton, and Tammy Wynette. She believes Parton is "an amazing example to every female songwriter out there". Alt-country artists like Ryan Adams, Patty Griffin and Lori McKenna have also inspired Swift.\n\nSwift lists Paul McCartney, The Rolling Stones, Bruce Springsteen, Emmylou Harris, Kris Kristofferson, and Carly Simon as her career role models: "They\'ve taken chances, but they\'ve also been the same artist for their entire careers". McCartney, both as a Beatle and a solo artist, makes Swift feel "as if I\'ve been let into his heart and his mind\xa0... He\'s out there continuing to make his fans so happy. Any musician could only dream of a legacy like that." She admires Springsteen for being "so musically relevant after such a long period of time". She aspires to be like Harris as she grows older: "It\'s not about fame for her, it\'s about music". "[Kristofferson] shines in songwriting\xa0... He\'s just one of those people who has been in this business for years but you can tell it hasn\'t chewed him up and spat him out", Swift says. She admires Simon\'s "songwriting and honesty\xa0... She\'s known as an emotional person but a strong person".\n\nSwift has been influenced by other non-country artists. As a pre-teen, she enjoyed bubblegum pop acts including Hanson and Britney Spears, for whom Swift has said she has an "unwavering devotion". In her high school years, Swift listened to rock bands like Dashboard Confessional, Fall Out Boy, and Jimmy Eat World. She has also spoken fondly of singers and songwriters like Michelle Branch, Alanis Morissette, Ashlee Simpson, Fefe Dobson, Colbie Caillat, Beyoncé, and Justin Timberlake; and the 1960s acts The Shirelles, Doris Troy, and The Beach Boys. Swift\'s fifth album, the pop-focused 1989, was influenced by some of her favorite 1980s pop acts, including Annie Lennox, Phil Collins and "Like a Prayer-era Madonna". Discussing Madonna, Swift said: "One element of Madonna\'s career that really takes center stage is how many times she\'s reinvented herself. It\'s easier to stay in one look, one comfort zone, one musical style. It\'s inspiring to see someone whose only predictable quality is being unpredictable."', 'title': 'Influences', 'title_stack': ['Artistry', 'Influences'], 'wiki_links': ['Shania Twain', 'Stevie Nicks', 'The Walt Disney Company', 'The Australian', 'Star Tribune', 'Country Standard Time', 'Country Music Television', 'USA Weekend', 'Time (magazine)', 'HuffPost', 'InStyle UK', 'Cowboy Take Me Away', 'CMT (U.S. TV channel)', 'Patsy Cline', 'Loretta Lynn', 'Tammy Wynette', 'Billboard (magazine)', 'Alt-country', 'Ryan Adams', 'Entertainment Weekly', 'Patty Griffin', 'The Oprah Winfrey Show', 'Lori McKenna', 'Bruce Springsteen', 'Emmylou Harris', 'Kris Kristofferson', 'Carly Simon', 'USA Today', 'The Beatles', 'People (magazine)', 'Entertainment Weekly', 'Vogue (magazine)', 'News.com.au', 'bubblegum pop', 'Hanson (band)', 'Britney Spears', 'MTV', 'Dashboard Confessional', 'Taste of Country', 'Fall Out Boy', 'CMT (U.S. TV channel)', 'Jimmy Eat World', 'Michelle Branch', 'Alanis Morissette', 'Chicago Tribune', 'Ashlee Simpson', 'US Weekly', 'Fefe Dobson', 'Colbie Caillat', 'Big Machine Records', 'Beyoncé', 'Elle (magazine)', 'Justin Timberlake', 'Billboard (magazine)', 'The Shirelles', 'Doris Troy', 'The Beach Boys', 'Rolling Stone', 'Annie Lennox', 'Phil Collins', 'Like a Prayer (song)', 'Madonna (entertainer)', 'Rolling Stone', 'Billboard (magazine)'], 'doc_title': 'Taylor Swift', 'section_id': 'qJSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'false', 'doc_id': '5422144', 'title_keyword': 'Music videos', 'text': 'Swift has collaborated with many different directors to produce her music videos, and over time she has become more involved with writing and directing. She has her own production house, Taylor Swift Productions, Inc., which is credited with producing the music video for "Me!". In 2010, Swift co-directed the music video for "Mine" with Roman White. In 2011, she continued to collaborate with White on the music videos for "Mean" and "Ours". Swift developed the concept and treatment for "Mean". In an interview, White elaborated that Swift "was keenly involved in writing the treatment, casting and wardrobe. And she stayed for both the 15-hour shooting days, even when she wasn\'t in the scenes." Swift wrote the concept for the "Ours" music video and then brought in White to direct, describing her vision of both videos as being "storylines".\n\nFrom 2014 to 2018, Swift collaborated with director Joseph Kahn on eight music videos—four each from her albums 1989 and Reputation. Kahn has praised Swift\'s involvement in the craft. In 2016, Swift worked with American Express for her "Blank Space" music video (which Kahn directed), and released the interactive app AMEX Unstaged: Taylor Swift Experience. Swift received starring and executive producer credit, and in 2015 won a Primetime Emmy Award in the Outstanding Interactive Program category for the app.\n\nIn 2018, Swift developed the concept and then wrote the treatment for the music video for the Sugarland song "Babe". She co-starred in the video with the two members of Sugarland Jennifer Nettles and Kristian Bush, directed by Anthony Mandler. Nettles described it as "cinematic" and "a period piece", while Bush referenced its Mad Men influences. Nettles also said, "I have a feeling we\'ll see her directing at some point soon, because she was really good at it." In 2019, Swift co-directed the music videos for "Me!" with Dave Meyer and "You Need to Calm Down" with Drew Kirsch. She also co-executive produced the latter with Todrick Hall. In August 2019, she revealed in an interview that she wrote the treatments for the two music videos as well. Swift also co-directed her 2019 "Lover" music video with Kirsch. At the 2019 VMAs she won Video of the Year for "You Need to Calm Down", becoming the second artist to win the award for a video that they co-directed.', 'title': 'Music videos', 'title_stack': ['Artistry', 'Music videos'], 'wiki_links': ['The New York Times', 'Roman White', 'MTV News', 'Ours (song)', 'Film treatment', 'CMT (U.S. TV channel)', 'CMT (U.S. TV channel)', 'Taste of Country', 'Joseph Kahn', 'American Express', 'Primetime Emmy Award', 'Primetime Emmy Award for Outstanding Interactive Program', 'The Hollywood Reporter', 'People (magazine)', 'Jennifer Nettles', 'Kristian Bush', 'Anthony Mandler', 'Mad Men', 'ET Online', 'Bustle (magazine)', 'Dave Meyers (director)', 'Todrick Hall', 'Rolling Stone', 'Rolling Stone', 'NME'], 'doc_title': 'Taylor Swift', 'section_id': 'q5Sc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'false', 'doc_id': '5422144', 'title_keyword': 'Awards and achievements', 'text': "Swift has received many awards and honors, including 10 Grammy Awards, 23 American Music Awards (most wins by a female artist), 23 Billboard Music Awards (most wins by a female artist), 12 Country Music Association Awards, eight Academy of Country Music Awards, one Brit Award, and one Emmy Award. As a songwriter, she has been honored by the Nashville Songwriters Association and the Songwriters Hall of Fame, and was listed on Rolling Stone 2015 list of the 100 Greatest Songwriters of All Time.\n\nSwift has sold more than 50 million albums—including 32.7\xa0million in the U.S.—150\xa0million single downloads, and was one of the top five music artists with the highest worldwide digital sales. Swift's studio albums Taylor Swift, Fearless, Speak Now, Red, and 1989 have all sold over four million copies in the U.S. She is the third best-selling digital singles artist in the U.S. with a total of 120 million equivalent units certified according to the Recording Industry Association of America.", 'title': 'Awards and achievements', 'title_stack': ['Awards and achievements'], 'wiki_links': ['Grammy Award', 'The Recording Academy', 'Billboard Music Award', 'Billboard (magazine)', 'Country Music Association Awards', 'Excite', 'Brit Award', 'Emmy Award', 'Variety (magazine)', 'Great American Country', 'CMT (U.S. TV channel)', 'Songwriters Hall of Fame', "Rolling Stone's 100 Greatest Songwriters of All Time", 'Songwriters Hall of Fame', 'Rolling Stone', 'Billboard (magazine)', 'India Today', 'Billboard (magazine)', 'Recording Industry Association of America'], 'doc_title': 'Taylor Swift', 'section_id': 'sJSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'true', 'doc_id': '5422144', 'title_keyword': '', 'text': 'Taylor Alison Swift (born December 13, 1989) is an American singer-songwriter. She is known for narrative songs about her personal life, which have received widespread media coverage. Born and raised in Reading, Pennsylvania, Swift moved to Nashville, Tennessee at the age of 14 to pursue a career in country music. She signed with label Big Machine Records and became the youngest artist signed by the Sony/ATV Music publishing house. Her 2006 eponymous debut album was the longest-charting album of the 2000s in the U.S., where it peaked at number five. The album\'s third single, "Our Song", made her the youngest person to single-handedly write and perform a number-one song on the Hot Country Songs chart. Swift\'s second album, Fearless, was released in 2008. Buoyed by the success of pop crossover singles "Love Story" and "You Belong with Me", Fearless became the best-selling album of 2009 in the U.S. The album won four Grammy Awards, and Swift became the youngest Album of the Year winner.\n\nSwift was the sole writer of her 2010 album Speak Now. It debuted at number one in the U.S., and the single "Mean" won two Grammy Awards. Her fourth album, Red (2012), yielded the successful singles "We Are Never Ever Getting Back Together" and "I Knew You Were Trouble". For her fifth album, the pop-focused 1989 (2014), she received three Grammys and became the first woman and fifth act overall to win Album of the Year twice. Its singles "Shake It Off", "Blank Space", and "Bad Blood" reached number one in the U.S., Australia, and Canada. The first two made Swift the first woman in the Billboard Hot 100\'s history to succeed herself at the top spot. Her sixth album, Reputation (2017), and its lead single, "Look What You Made Me Do", topped the UK and U.S. charts; with the release of Reputation, Swift became the first act to have four albums sell one million copies within one week in the U.S. Her seventh album, Lover (2019), spawned two U.S. number-two singles, "Me!" and "You Need to Calm Down".\n\nHaving sold more than 50 million albums—including 32\xa0million in the U.S.—and 150\xa0million singles, Swift is one of the best-selling music artists of all time. As a songwriter, she has received awards from the Nashville Songwriters Association and the Songwriters Hall of Fame, and was included in Rolling Stone 100 Greatest Songwriters of All Time in 2015. Her other accolades include 10 Grammy Awards, one Emmy, 23 Billboard Music Awards, six Guinness world records, and appearances in Time 100 most influential people in the world (2010, 2015, 2019). She also ranked first in the Forbes Celebrity 100 (2016 and 2019), and was the youngest to be featured in the magazine\'s listing of the 100 most powerful women (2015).', 'title': '', 'title_stack': [''], 'wiki_links': ['2019 iHeartRadio Music Awards', 'Reading, Pennsylvania', 'Austin Swift', 'List of awards and nominations received by Taylor Swift', 'Pop music', 'pop rock', 'country music', 'country pop', 'Ed Sheeran', 'Big Machine Records', 'Republic Records', 'Sentimental ballad', 'Reading, Pennsylvania', 'Nashville, Tennessee', 'country music', 'Big Machine Records', 'Sony/ATV Music Publishing', 'Taylor Swift (album)', 'Our Song (Taylor Swift song)', 'Hot Country Songs', 'Fearless (Taylor Swift album)', 'Love Story (Taylor Swift song)', 'You Belong with Me', 'Grammy Awards', 'Grammy Award for Album of the Year', 'Speak Now', 'Mean (song)', 'Red (Taylor Swift album)', 'We Are Never Ever Getting Back Together', 'I Knew You Were Trouble', '1989 (Taylor Swift album)', 'Shake It Off', 'Blank Space', 'Bad Blood (Taylor Swift song)', 'Reputation (Taylor Swift album)', 'Look What You Made Me Do', 'Lists of fastest-selling albums', 'Lover (album)', 'Me!', 'You Need to Calm Down', 'List of best-selling music artists', 'List of awards and nominations received by Taylor Swift', 'Nashville Songwriters Association International', 'Songwriters Hall of Fame', 'Rolling Stone', "Rolling Stone's 100 Greatest Songwriters of All Time", 'Creative Arts Emmy Award', 'Billboard Music Awards', 'Guinness world records', 'Time (magazine)', 'Time 100', 'Forbes Celebrity 100', "The World's 100 Most Powerful Women"], 'doc_title': 'Taylor Swift', 'section_id': 'oJSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'false', 'doc_id': '5422144', 'title_keyword': 'Songwriting', 'text': 'Swift uses her life experiences as an inspiration in her work. She often addresses the "anonymous crushes of her high school years" and celebrities in her early songs. Swift frequently criticizes ex-boyfriends, an aspect of her songwriting downplayed by The Village Voice: "Being told What Songs Mean is like having a really pushy professor. And it imperils a true appreciation of Swift\'s talent, which is not confessional, but dramatic." However, New York believes the media scrutiny over her decision to "mine her personal life for music\xa0... is sexist, inasmuch as it\'s not asked of her male peers". Swift said that not all of her songs are factual and they are sometimes based on observations. Aside from clues provided in her liner notes, Swift tries not to talk about song subjects specifically "because these are real people. You try to give insight as to where you were coming from as a writer without completely throwing somebody under the bus."\n\nThe Guardian has praised Swift for writing about teenage years "with a kind of wistful, sepia-toned nostalgia" over the course of her first two albums. New York has remarked that many singer-songwriters have made great records as teens, but "none made great records so explicitly about their teens". The magazine has also compared her work to Brian Wilson. In Fearless, Swift featured fairy tale imagery and explored the disconnect "between fairy tales and the reality of love". Her later albums address more adult relationships. In addition to romance and love, Swift\'s songs have discussed parent-child relationships, friendships, alienation, fame, and career ambitions. Swift frequently includes "a tossed-off phrase to suggest large and serious things that won\'t fit in the song, things that enhance or subvert the surface narrative".\n\nRolling Stone describes Swift as "a songwriting savant with an intuitive gift for verse-chorus-bridge architecture". According to The Village Voice, she often uses third-verse point of view reversals. In terms of imagery, repetition is evident in Swift\'s songwriting. In The Guardians words, "she spends so much time kissin\' in the rain that it seems a miracle she hasn\'t developed trenchfoot". Slant Magazine adds, "to Swift\'s credit, she explores new lyrical motifs over the course of [her fourth] album". Although reviews of Swift\'s work are "almost uniformly positive", The New Yorker has said she is generally portrayed "more as a skilled technician than as a Dylanesque visionary".', 'title': 'Songwriting', 'title_stack': ['Artistry', 'Songwriting'], 'wiki_links': ['The Wall Street Journal', 'The New York Times', 'Rolling Stone', 'The Village Voice', 'New York (magazine)', 'New York (magazine)', 'The Washington Post', 'The New York Times', 'Vanity Fair (magazine)', 'Brian Wilson', 'New York (magazine)', 'The Atlanta Journal-Constitution', 'Las Vegas Weekly', 'Reading Eagle', 'AOL', 'Rolling Stone', 'The Village Voice', 'trenchfoot', 'Slant Magazine', 'Slant Magazine', 'Bob Dylan'], 'doc_title': 'Taylor Swift', 'section_id': 'qpSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'true', 'doc_id': '5422144', 'title_keyword': 'Public image', 'text': 'Swift\'s personal life is the subject of constant media attention. In 2013, Abercrombie & Fitch marketed a slogan T-shirt with a "slut-shaming" remark directed toward her. The New York Times asserted in 2013 that her "dating history has begun to stir what feels like the beginning of a backlash". They questioned whether Swift was in the midst of a "quarter-life crisis". Swift has said she is unwilling to discuss her personal life in public; she believes that talking about it can be "a career weakness". In 2015, singer Ray Stevens released his album Here We Go Again which included the single "Taylor Swift is Stalking Me".\n\nRolling Stone remarks upon her polite manner: "If this is Swift\'s game face, it must be tattooed on because it never drops." The magazine also takes note of her "ease with glad-handing", and The Hollywood Reporter has credited her as "the Best People Person since Bill Clinton". While presenting Swift with an award for her humanitarian endeavors in 2012, Michelle Obama described her as a singer who "has rocketed to the top of the music industry but still keeps her feet on the ground, someone who has shattered every expectation of what a 22-year-old can accomplish". Swift considers Michelle Obama to be a role model. Swift is one of the most-followed people on social media, and is known for her friendly interactions with her fans. She has delivered holiday gifts to fans by mail and in person, dubbed "Swiftmas". She considers it her "responsibility" to be conscious of her influence on young fans, and has said they are "the longest and best relationship I have ever had".\n\nOften described by the media as "America\'s Sweetheart", Swift insists she does not "live by all these rigid, weird rules that make me feel all fenced in. I just like the way that I feel like, and that makes me feel very free". She refuses to take part in overly sexualized photo-shoots, although Bloomberg L.P. views her as a sex symbol. Vogue named Swift an Icon of American Style  in 2011. In 2014 she topped People annual best dressed list. In 2015, she was named Woman of the Year at the Elle Style Awards, and ranked first on Maxim Hot 100 list.\n\nSwift has also appeared in various power listings. Time included her on its annual list of the 100 most influential people in 2010, 2015, and 2019. From 2011 to 2015, she appeared in the top three on the Forbes Top-Earning Women in Music list with earnings of $45\xa0million, $57\xa0million, $55\xa0million, $64\xa0million, and $80\xa0million respectively. Swift again topped the list in 2016 with earnings of $170\xa0million, and placed in the top three in 2017 and 2018, earning $44\xa0million and $80\xa0million. Her 2016 earnings also topped Forbes annual list of the 100 highest-paid celebrities—a feat that was entered into the Guinness World Records. She topped the list in 2019 with $185\xa0million, and ranked among the top ten in 2011, 2013 and 2015. In 2015, Swift became the youngest woman ever to be included on Forbes list of the 100 most powerful women, ranked at number 64. She was one of the finalists for Time Person of the Year in 2014 and was awarded the honor in 2017 as one of the "Silence Breakers" who spoke up about sexual assault.  In June 2019, Forbes estimated Swift\'s net worth at $360\xa0million.', 'title': 'Public image', 'title_stack': ['Public image'], 'wiki_links': ['Cosmopolitan (magazine)', 'slut-shaming', 'New York (magazine)', 'The New York Times', 'Vogue (magazine)', 'Ray Stevens', 'Billboard (magazine)', 'Bill Clinton', 'The Hollywood Reporter', 'Michelle Obama', 'New York (magazine)', 'role model', 'Taste of Country', 'Forbes', 'Billboard (magazine)', 'Los Angeles Times', 'Metro (British newspaper)', 'Vanity Fair (magazine)', 'The Daily Telegraph', 'Bloomberg L.P.', 'sex symbol', 'Bloomberg L.P.', 'Vogue (magazine)', 'People (magazine)', 'Elle Style Awards', 'Elle (magazine)', 'Maxim (magazine)', 'Maxim (magazine)', 'Time 100', 'Time (magazine)', 'Billboard (magazine)', 'USA Today', 'Forbes', 'Forbes', 'Forbes', 'Forbes', 'Forbes', 'Forbes', 'Forbes', 'Forbes', 'Forbes Celebrity 100', 'Guinness World Records', 'Forbes', 'Forbes', 'International Business Times', 'Forbes', 'Forbes', "The World's 100 Most Powerful Women", 'Forbes', 'Time Person of the Year', 'Time (magazine)', 'Time (magazine)', 'Forbes'], 'doc_title': 'Taylor Swift', 'section_id': 'rJSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'false', 'doc_id': '5422144', 'title_keyword': 'Politics', 'text': 'During the 2008 presidential campaign, Swift promoted the Every Woman Counts campaign, aimed at engaging women in the political process. She was one of many country stars to record a PSA for the Vote (For Your) Country campaign. She said: "I don\'t think it\'s my job to try and influence people which way they should vote." Following Barack Obama\'s inauguration, she told Rolling Stone that she supported the president: "I\'ve never seen this country so happy about a political decision in my entire time of being alive. I\'m so glad this was my first election."\n\nIn a 2012 interview, Swift remarked that in spite of keeping herself "as educated and informed as possible", she does not discuss politics, fearing that might influence other people. Writing about media pressure on Swift to take public political stances, Politico called Swift "studiously apolitical". Swift is a feminist and pro-choice. She has spoken out against LGBT discrimination and white supremacy. Following the 2008 murder of Larry King, she recorded a GLSEN PSA aimed at combating hate crimes. On the first anniversary of King\'s death, Swift told Seventeen that her parents taught her "never to judge others based on whom they love, what color their skin is, or their religion". The music video for Swift\'s anti-bullying song "Mean" deals in part with homophobia in high schools; it was nominated for an MTV VMA social activism award in 2011. The New York Times believes she is part of "a new wave of young (and mostly straight) women who are providing the soundtrack for a generation of gay fans coming to terms with their identity in a time of turbulent and confusing cultural messages".\n\nPrior to the 2018 midterm elections, Swift endorsed candidates for public office for the first time, declaring her support for two Democratic candidates in an Instagram post: Congressman Jim Cooper for re-election to the House of Representatives, and former Tennessee governor Phil Bredesen for election to the Senate. She spoke out against Bredesen\'s opponent, Republican Congresswoman Marsha Blackburn, saying she was "appalled" and "terrified" by her voting record. She expressed her desire for LGBT rights and gender and racial equality, and condemned systemic racism. Vote.org reported that 65,000 people registered to vote in the 24 hours following Swift\'s post, an unprecedented surge even accounting for usual registration increases as deadlines approach. During Swift\'s acceptance speech for Artist of the Year at the American Music Awards of 2018, she encouraged her fans to vote in the 2018 midterm elections.\n\nIn June 2019, Swift published a letter addressed to Republican Senator Lamar Alexander, urging him to support the Equality Act, and created a petition on Change.org urging the Senate to do the same. It has attracted more than 500,000 signatures, including Democrats Cory Booker, Elizabeth Warren, Beto O\'Rourke, and Kirsten Gillibrand.', 'title': 'Politics', 'title_stack': ['Other ventures', 'Politics'], 'wiki_links': ['2008 United States presidential election', 'Lifetime (TV network)', 'First inauguration of Barack Obama', 'Time (magazine)', 'Politico', 'Politico', 'Feminism', 'The Guardian', 'pro-choice', 'The Guardian', 'LGBT', 'BBC News', 'white supremacy', 'Rolling Stone', 'murder of Larry King', 'Gay, Lesbian and Straight Education Network', 'hate crime', 'E!', 'Seventeen (American magazine)', 'Seventeen (American magazine)', 'homophobia', 'The New York Times', 'Reuters', 'United States elections, 2018', 'Democratic Party (United States)', 'The Daily Beast', 'The Guardian', 'Jim Cooper', '2018 United States House of Representatives elections in Tennessee#District 5', 'United States House of Representatives', 'Governor of Tennessee', 'Phil Bredesen', '2018 United States Senate election in Tennessee', 'United States Senate', 'Republican Party (United States)', 'Marsha Blackburn', 'USA Today', 'Vote.org', 'CNN', 'The New York Times', 'Lamar Alexander', 'Equality Act (United States)', 'The Hollywood Reporter', 'Change.org', 'Variety (magazine)', 'NME', 'Cory Booker', 'Elizabeth Warren', "Beto O'Rourke", 'Kirsten Gillibrand', 'Vogue (magazine)'], 'doc_title': 'Taylor Swift', 'section_id': 'rpSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'false', 'doc_id': '5422144', 'title_keyword': '1989–2003: Early life', 'text': 'Taylor Alison Swift was born on December 13, 1989 in Reading, Pennsylvania. Her father, Scott Kingsley Swift, was a stockbroker for Merrill Lynch; her mother, Andrea Gardner Swift (née Finlay), was a homemaker who had worked as a mutual fund marketing executive. Swift, who has said she has Scottish heritage was named after the singer-songwriter James Taylor. She has a younger brother named Austin, who is an actor. Swift spent her early years on a Christmas tree farm, which her father purchased from one of his clients. She attended preschool and kindergarten at the Alvernia Montessori School, run by Franciscan nuns, before transferring to The Wyndcroft School. The family moved to a rented house in the suburban town of Wyomissing, Pennsylvania, where she attended Wyomissing Area Junior/Senior High School.\n\nAt age nine, Swift became interested in musical theater and performed in four Berks Youth Theatre Academy productions. She also traveled regularly to New York City for vocal and acting lessons. Swift later shifted her focus toward country music inspired by Shania Twain\'s songs, which made her "want to just run around the block four times and daydream about everything". She spent her weekends performing at local festivals and events.Rolling Stone Interview: The Unabridged Taylor Swift, December 2, 2008 After watching a documentary about Faith Hill, Swift felt sure she needed to go to Nashville, Tennessee to pursue a music career. She traveled with her mother at age eleven to visit Nashville record labels and submitted a demo tape of Dolly Parton and Dixie Chicks karaoke covers. She was rejected, however, because "everyone in that town wanted to do what I wanted to do. So, I kept thinking to myself, I need to figure out a way to be different".\n\nWhen Swift was about 12 years old, computer repairman and local musician Ronnie Cremer taught her to play guitar. He helped with her first efforts as a songwriter, leading to her writing "Lucky You". In 2003, Swift and her parents started working with New York-based music manager Dan Dymtrow. With his help, Swift modeled for Abercrombie & Fitch as part of their "Rising Stars" campaign, had an original song included on a Maybelline compilation CD, and attended meetings with major record labels. After performing original songs at an RCA Records showcase, Swift was given an artist development deal and began making frequent trips to Nashville with her mother.\n\nTo help Swift break into country music, her father transferred to Merrill Lynch\'s Nashville office when she was 14, and the family relocated to a lakefront house in Hendersonville, Tennessee. Swift attended Hendersonville High School but after two years transferred to the Aaron Academy, which through homeschooling could accommodate her touring schedule; she graduated a year early.', 'title': '1989–2003: Early life', 'title_stack': ['Life and career', '1989–2003: Early life'], 'wiki_links': ['Reading, Pennsylvania', 'FYI (TV channel)', 'stockbroker', 'Merrill Lynch', 'mutual fund', 'Simon & Schuster', 'The Independent', 'James Taylor', 'Parade (magazine)', 'Austin Swift', 'MTV News', 'Esquire (magazine)', 'Montessori', 'Franciscans', 'Reading Eagle', 'The Wyndcroft School', 'Reading Eagle', 'Wyomissing, Pennsylvania', 'Philadelphia Daily News', 'Wyomissing Area Junior/Senior High School', 'WCAU', 'Berks County, Pennsylvania', 'Daily News (New York)', 'Taste of Country', 'Shania Twain', 'The Guardian', 'Rolling Stone', 'CMT (U.S. TV channel)', 'Faith Hill', 'Nashville, Tennessee', 'The Daily Telegraph', 'Dolly Parton', 'Dixie Chicks', 'CMT (U.S. TV channel)', 'American Songwriter', 'New York Daily News', 'Abercrombie & Fitch', 'Maybelline', 'RCA Records', 'MSNBC', 'Inc. (magazine)', 'Hendersonville, Tennessee', 'The New Yorker', 'Vanity Fair (magazine)', 'Hendersonville High School (Tennessee)', 'CMT (U.S. TV channel)', 'Rolling Stone'], 'doc_title': 'Taylor Swift', 'section_id': 'oZSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'false', 'doc_id': '5422144', 'title_keyword': '2004–2008: Career beginnings and Taylor Swift', 'text': 'In Nashville, Swift worked with experienced Music Row songwriters such as Troy Verges, Brett Beavers, Brett James, Mac McAnally, and the Warren Brothers, and formed a lasting working relationship with Liz Rose. They began meeting for two-hour writing sessions every Tuesday afternoon after school. Rose thought the sessions were "some of the easiest I\'ve ever done. Basically, I was just her editor. She\'d write about what happened in school that day. She had such a clear vision of what she was trying to say. And she\'d come in with the most incredible hooks." Swift was signed by the Sony/ATV Tree publishing house, but left RCA Records when she was 14. She later said: "I genuinely felt that I was running out of time. I wanted to capture these years of my life on an album while they still represented what I was going through".\n\nAt an industry showcase at Nashville\'s Bluebird Cafe in 2005, Swift caught the attention of Scott Borchetta, a DreamWorks Records executive who was preparing to form an independent record label, Big Machine Records. She first met Borchetta in 2004. Swift became one of Big Machine\'s first signings, and her father purchased a three-percent stake in the company for an estimated $120,000. She began working on her eponymous debut album shortly after. Swift persuaded Big Machine to hire her demo producer Nathan Chapman, with whom she felt she had the right "chemistry". She wrote three of the album\'s songs alone, and co-wrote the remaining eight with Rose, Robert Ellis Orrall, Brian Maher, and Angelo Petraglia. Taylor Swift was released on October 24, 2006. Jon Caramanica of The New York Times described it as "a small masterpiece of pop-minded country, both wide-eyed and cynical, held together by Ms. Swift\'s firm, pleading voice". Taylor Swift peaked at number five on the Billboard 200 albums chart in the United States, spending 157 weeks there—the longest stay on the chart by any release in the U.S. that decade. As of August 2016, the album had sold over 7.75\xa0million copies worldwide.\n\nBig Machine Records was still in its infancy during the June 2006 release of the lead single, "Tim McGraw". Swift and her mother helped "stuff the CD singles into envelopes to send to radio". She spent much of 2006 promoting Taylor Swift with a radio tour, television appearances, and opening for Rascal Flatts on select dates during their 2006 tour after they fired their previous opening act, Eric Church, for playing longer than his allotted time. Church jokingly told Swift she should give him her first gold record as thanks for getting fired. She sent him her first gold record with a note that said, "Thanks for playing too long and too loud on the Flatts tour. I sincerely appreciate it. Taylor."\n\nBorchetta said that record industry peers disapproved of his signing a 16-year-old singer-songwriter, but that Swift tapped into a previously unknown market—teenage girls who listen to country music. Following "Tim McGraw", four more singles were released throughout 2007 and 2008: "Teardrops on My Guitar", "Our Song", "Picture to Burn" and "Should\'ve Said No". All were successful on Billboards Hot Country Songs chart in the United States, with "Our Song", and "Should\'ve Said No" reaching number one. With "Our Song", Swift became the youngest person to single-handedly write and perform a number-one song on the chart. "Teardrops on My Guitar" reached number thirteen on the Billboard Hot 100 songs chart in the United States. Swift also released the holiday album Sounds of the Season: The Taylor Swift Holiday Collection in October 2007 and the EP Beautiful Eyes in July 2008. She promoted her debut album extensively as the opening act for other artists on their tours.\n\nSwift won accolades for Taylor Swift. She was one of the recipients of the Nashville Songwriters Association\'s Songwriter/Artist of the Year in 2007, becoming the youngest person to be honored with the title. She also won the Country Music Association\'s Horizon Award for Best New Artist, the Academy of Country Music Awards\' Top New Female Vocalist, and the American Music Awards\' Favorite Country Female Artist honor. She was also nominated for Best New Artist at the 2008 Grammy Awards. She opened for the Rascal Flatts on their 2008 summer and fall tour. In July of that year, Swift began a romance with singer Joe Jonas that ended three months later.', 'title': '2004–2008: Career beginnings and Taylor Swift', 'title_stack': ['Life and career', '2004–2008: Career beginnings and Taylor Swift'], 'wiki_links': ['Music Row', 'Troy Verges', 'Brett Beavers', 'Brett James', 'Mac McAnally', 'the Warren Brothers', 'American Songwriter', 'Broadcast Music, Inc.', 'Liz Rose', 'American Songwriter', 'Rolling Stone', 'Sony/ATV Music Publishing', 'The Daily Telegraph', 'Bluebird Cafe', 'Scott Borchetta', 'DreamWorks Records', 'Big Machine Records', 'Billboard (magazine)', 'Rolling Stone', 'Forbes', 'Taylor Swift (album)', 'Nathan Chapman (record producer)', 'Robert Ellis Orrall', 'Angelo Petraglia', 'Big Machine Records', 'International Business Times', 'The New York Times', 'The New York Times', 'Billboard 200', 'Billboard (magazine)', 'lead single', 'Tim McGraw (song)', 'Entertainment Weekly', 'Rascal Flatts', 'CMT (U.S. TV channel)', 'Eric Church', 'Gold Record', 'Teardrops on My Guitar', 'Our Song (Taylor Swift song)', 'Picture to Burn', "Should've Said No", 'Billboard (magazine)', 'Hot Country Songs', 'Great American Country', 'Billboard Hot 100', 'Billboard (magazine)', 'Sounds of the Season: The Taylor Swift Holiday Collection', 'Beautiful Eyes', 'Country Standard Time', 'Great American Country', 'VH1', 'Nashville Songwriters Association International', 'Country Music Association', 'CMT (U.S. TV channel)', 'Academy of Country Music Awards', 'CMT (U.S. TV channel)', 'American Music Awards', 'Grammy Award for Best New Artist', '2008 Grammy Awards', 'People (magazine)', 'CMT (U.S. TV channel)', 'Joe Jonas', 'People (magazine)', 'People (magazine)'], 'doc_title': 'Taylor Swift', 'section_id': 'opSc-G8BtLQBgyHGs3xq', 'score': 0.0}, {'offensive': 'false', 'doc_id': '5422144', 'title_keyword': '2010–2014: Speak Now and Red', 'text': 'In August 2010, Swift released "Mine", the lead single from her third studio album, Speak Now. It entered the U.S. charts at number three, making Swift the second female artist in the history of the Hot 100 (after Mariah Carey) to debut multiple tracks in the top five in one year; the other was "Today Was a Fairytale" at number two. Swift wrote the album alone and co-produced every track. Speak Now, released on October 25, 2010, was a commercial success, debuting at number one on the Billboard 200, and becoming the 16th album to achieve opening week sales of one million copies. It became the fastest-selling digital album by a female artist, with 278,000 downloads in a week, earning Swift an entry in the 2010 Guinness World Records. She earned a second entry after she became the first woman to achieve 10 track debuts on the Billboard Hot 100. Three of the album\'s singles, "Mine", "Back to December", and "Mean", peaked in the top ten in Canada. Later in 2010, she briefly dated actor Jake Gyllenhaal.\n\n"Mean" won Best Country Song and Best Country Solo Performance at the 54th Annual Grammy Awards. Swift performed it during the ceremony. Claire Suddath of Time felt she "delivered her comeback on-key and with a vengeance"; Jayme Deerwester of USA Today wrote that the criticism in 2010 seemed to have "made her a better songwriter and live performer". Swift won other awards for Speak Now, including Songwriter/Artist of the Year by the Nashville Songwriters Association (2010 and 2011), Woman of the Year by Billboard (2011), and Entertainer of the Year by the Academy of Country Music (2011 and 2012) and the Country Music Association in 2011. At the American Music Awards of 2011, Swift won Artist of the Year and Favorite Country Album. Rolling Stone placed Speak Now at number 45 in its 2012 list of the "50 Best Female Albums of All Time", writing: "She might get played on the country station, but she\'s one of the few genuine rock stars we\'ve got these days, with a flawless ear for what makes a song click."\n\nThe Speak Now World Tour ran from February 2011 to March 2012 and grossed over $123\xa0million. In November 2011, Swift released her first live album, Speak Now World Tour: Live. The following month, she contributed two original songs to The Hunger Games soundtrack album: "Safe & Sound", cowritten and recorded with the Civil Wars and T-Bone Burnett, and "Eyes Open". "Safe & Sound" won the Grammy Award for Best Song Written for Visual Media. Swift contributed vocals to rapper B.o.B\'s "Both of Us", released in May 2012. From July to September 2012, Swift dated political heir Conor Kennedy. In August, Swift released "We Are Never Ever Getting Back Together", the lead single from her fourth studio album, Red. It became her first number one in the U.S. and New Zealand and reached the top slot on iTunes\' digital song sales chart 50 minutes after its release, earning the Fastest Selling Single in Digital History Guinness World Record. Swift released the album\'s second single, "Begin Again", in October. It reached number seven on the Billboard Hot 100. Other singles released from the album include "I Knew You Were Trouble", "22", "Everything Has Changed", "The Last Time", and "Red". "I Knew You Were Trouble" was a major commercial success, peaking at number two in the United States.\n\nRed was released on October 22, 2012, incorporating new genres for Swift, such as heartland rock, dubstep and dance-pop. The album was a critical and commercial success, and debuted at number one on the Billboard 200 with first-week sales of 1.21\xa0million copies. This marked the highest opening sales in a decade in the United States, and made Swift the first female to have two million-selling album openings, a record recognized by the Guinness Book of World Records. The Red Tour ran from March 2013 to June 2014 and grossed over $150\xa0million; the tour broke the ticket sales record in China with all 18,000 tickets sold in 60 seconds. Red earned several accolades, including four nominations at the 56th Annual Grammy Awards. Its single "I Knew You Were Trouble" won Best Female Video at the 2013 MTV Video Music Awards. Swift was named Best Female Country Artist at the 2012 American Music Awards and Artist of the Year at the 2013 ceremony. She received the Nashville Songwriters Association\'s Songwriter/Artist Award for the fifth and sixth consecutive years in 2012 and 2013. Swift was also honored by the Association with a special Pinnacle Award, making her the second recipient of the accolade after Garth Brooks. During this time, she had a short-term relationship with British singer Harry Styles.\n\nIn 2013, Swift co-wrote and co-produced "Sweeter than Fiction" with Jack Antonoff for the One Chance soundtrack, and received a Best Original Song nomination at the 71st Golden Globe Awards. She provided guest vocals for Tim McGraw\'s song "Highway Don\'t Care", featuring guitar work by Keith Urban. Swift performed "As Tears Go By" with the Rolling Stones in Chicago, Illinois as part of their 50 & Counting tour, and said that the band was a major influence on her career outlook. She also joined Florida Georgia Line on stage during their set at the 2013 Country Radio Seminar to sing "Cruise". Swift voiced Audrey, a tree lover, in the animated film The Lorax (2012), made a cameo in the sitcom New Girl (2013), and had a supporting role in the film adaptation of The Giver (2014).', 'title': '2010–2014: Speak Now and Red', 'title_stack': ['Life and career', '2010–2014: Speak Now and Red'], 'wiki_links': ['Mine (Taylor Swift song)', 'Speak Now', 'Mariah Carey', 'Guinness World Records', 'Guinness World Records', 'Back to December', 'Mean (Taylor Swift song)', 'Jake Gyllenhaal', 'Grammy Award for Best Country Solo Performance', '54th Annual Grammy Awards', 'Time (magazine)', 'Time (magazine)', 'USA Today', 'USA Today', 'Academy of Country Music', 'American Music Awards of 2011', 'The Hollywood Reporter', 'Speak Now World Tour', 'Speak Now World Tour: Live', 'The Hunger Games: Songs from District 12 and Beyond', 'Safe & Sound (Taylor Swift song)', 'The Civil Wars', 'T-Bone Burnett', 'Eyes Open (song)', 'Grammy Award for Best Song Written for Visual Media', 'B.o.B', 'Both of Us', 'Kennedy family', 'We Are Never Ever Getting Back Together', 'Red (Taylor Swift album)', 'iTunes', 'Begin Again (Taylor Swift song)', 'I Knew You Were Trouble', '22 (Taylor Swift song)', 'Everything Has Changed', 'The Last Time (Taylor Swift song)', 'Red (Taylor Swift song)', 'KABC-TV', 'heartland rock', 'dubstep', 'dance-pop', 'The Red Tour', 'NME', '56th Annual Grammy Awards', '2013 MTV Video Music Awards', 'HuffPost', 'Nashville Songwriters Association International', 'Garth Brooks', 'Harry Styles', 'Sweeter than Fiction', 'Jack Antonoff', 'One Chance (film)', 'Golden Globe Award for Best Original Song', '71st Golden Globe Awards', "Highway Don't Care", 'As Tears Go By (song)', 'the Rolling Stones', '50 & Counting', 'Florida Georgia Line', 'Country Radio Seminar', 'Cruise (song)', 'The Lorax (film)', 'New Girl', 'The Giver (film)'], 'doc_title': 'Taylor Swift', 'section_id': 'pJSc-G8BtLQBgyHGs3xq', 'score': 0.0}]
AMAZON_SECTIONS = [{'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'History', 'text': 'In 1994, Jeff Bezos incorporated Amazon. He chose the location Seattle because of technical talent as Microsoft is located there. The David Rubenstein Show: Jeff Bezos, Bloomberg Markets and Finance, 2018-09-19 In May 1997, the organization went public. The company began selling music and videos in 1998, at which time it began operations internationally by acquiring online sellers of books in United Kingdom and Germany. The following year, the organization also sold video games, consumer electronics, home-improvement items, software, games, and toys in addition to other items.\n\nIn 2002, the corporation started Amazon Web Services (AWS), which provided data on Web site popularity, Internet traffic patterns and other statistics for marketers and developers. In 2006, the organization grew its AWS portfolio when Elastic Compute Cloud (EC2), which rents computer processing power as well as Simple Storage Service (S3), that rents data storage via the Internet, were made available. That same year, the company started Fulfillment by Amazon which managed the inventory of individuals and small companies selling their belongings through the company internet site. In 2012, Amazon bought Kiva Systems to automate its inventory-management business, purchasing Whole Foods Market supermarket chain five years later in 2017.', 'title': 'History', 'title_stack': ['History'], 'wiki_links': ['public company', 'United Kingdom', 'Germany', 'Amazon Web Services', 'Amazon Elastic Compute Cloud', 'Simple Storage Service', 'Amazon Robotics', 'Whole Foods Market'], 'doc_title': 'Amazon (company)', 'section_id': 'IChf-G8BOk9B9AIxhQVC', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Board of directors', 'text': ", the board of directors is:\n Jeff Bezos, President, CEO, and Chairman\n Tom Alberg, Managing partner, Madrona Venture Group\n Rosalind Brewer, Group President, and COO, Starbucks\n Jamie Gorelick, partner, Wilmer Cutler Pickering Hale, and Dorr\n Daniel P. Huttenlocher, Dean and Vice Provost, Cornell University\n Judy McGrath, former CEO, MTV Networks\n Indra Nooyi, former CEO, PepsiCo\n Jon Rubinstein, former Chairman, and CEO, Palm, Inc.\n Thomas O. Ryder, former Chairman, and CEO, Reader's Digest Association\n Patty Stonesifer, President, and CEO, Martha's Table\n Wendell P. Weeks, Chairman, President, and CEO, Corning Inc.", 'title': 'Board of directors', 'title_stack': ['Board of directors'], 'wiki_links': ['Jeff Bezos', 'Tom Alberg', 'Madrona Venture Group', 'Rosalind Brewer', 'Starbucks', 'Jamie Gorelick', 'Wilmer Cutler Pickering Hale and Dorr', 'Daniel P. Huttenlocher', 'Cornell University', 'Judy McGrath', 'MTV Networks', 'Indra Nooyi', 'PepsiCo', 'Jon Rubinstein', 'Palm, Inc.', 'Thomas O. Ryder', "Reader's Digest Association", 'Patty Stonesifer', "Martha's Table", 'Wendell P. Weeks', 'Corning Inc.'], 'doc_title': 'Amazon (company)', 'section_id': 'IShf-G8BOk9B9AIxhQVC', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Merchant partnerships', 'text': 'In 2000, U.S. toy retailer Toys "R" Us entered into a 10-year agreement with Amazon, valued at $50 million per year plus a cut of sales, under which Toys "R" Us would be the exclusive supplier of toys and baby products on the service, and the chain\'s website would redirect to Amazon\'s Toys & Games category. In 2004, Toys "R" Us sued Amazon, claiming that because of a perceived lack of variety in Toys "R" Us stock, Amazon had knowingly allowed third-party sellers to offer items on the service in categories that Toys "R" Us had been granted exclusivity. In 2006, a court ruled in favor of Toys "R" Us, giving it the right to unwind its agreement with Amazon and establish its own independent e-commerce website. The company was later awarded $51 million in damages.\n\nIn 2001, Amazon entered into a similar agreement with Borders Group, under which Amazon would co-manage Borders.com as a co-branded service, Borders pulled out of the arrangement in 2007, with plans to also launch its own online store.\n\nOn October 18, 2011, Amazon.com announced a partnership with DC Comics for the exclusive digital rights to many popular comics, including Superman, Batman, Green Lantern, The Sandman, and Watchmen. The partnership has caused well-known bookstores like Barnes & Noble to remove these titles from their shelves.\n\nIn November 2013, Amazon announced a partnership with the United States Postal Service to begin delivering orders on Sundays. The service, included in Amazon\'s standard shipping rates, initiated in metropolitan areas of Los Angeles and New York because of the high-volume and inability to deliver in a timely way, with plans to expand into Dallas, Houston, New Orleans and Phoenix by 2014.\n\nIn June 2017, Nike confirmed a "pilot" partnership with Amazon to sell goods directly on the platform.\n\n, AmazonFresh sold a range of Booths branded products for home delivery in selected areas.\n\nIn September 2017, Amazon ventured with one of its sellers JV Appario Retail owned by Patni Group which has recorded a total income of US$\u2009104.44\u2009million (₹\u2009759\u2009crore) in financial year 2017–18.\n\nIn November 2018, Amazon reached an agreement with Apple Inc. to sell selected products through the service, via the company and selected Apple Authorized Resellers. As a result of this partnership, only Apple Authorized Resellers may sell Apple products on Amazon effective January 4, 2019.', 'title': 'Merchant partnerships', 'title_stack': ['Merchant partnerships'], 'wiki_links': ['Toys "R" Us', 'BBC News', 'USA Today', 'Associated Press', 'Borders Group', 'DC Comics', 'Superman', 'Batman', 'Green Lantern', 'The Sandman (Vertigo)', 'Watchmen', 'United States Postal Service', 'Los Angeles', 'New York, New York', 'Dallas, Texas', 'Houston', 'New Orleans', 'Phoenix, Arizona', 'Nike, Inc.', 'AmazonFresh', 'Booths Supermarkets', 'Indian rupee', 'crore', 'Apple Inc.'], 'doc_title': 'Amazon (company)', 'section_id': 'Iihf-G8BOk9B9AIxhQVC', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Beijing Century Joyo Courier Services', 'text': 'Beijing Century Joyo Courier Services is a subsidiary of Amazon and it applied for a freight forwarding license with the US Maritime Commission. Amazon is also building out its logistics in trucking and air freight to potentially compete with UPS and FedEx.', 'title': 'Beijing Century Joyo Courier Services', 'title_stack': ['Subsidiaries', 'Beijing Century Joyo Courier Services'], 'wiki_links': ['Freight forwarder', 'Federal Maritime Commission', 'Trucking industry in the United States', 'air freight', 'United Parcel Service', 'FedEx'], 'doc_title': 'Amazon (company)', 'section_id': 'KChf-G8BOk9B9AIxhQVC', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Shelfari', 'text': 'Shelfari was a social cataloging website for books. Shelfari users built virtual bookshelves of the titles which they owned or had read and they could rate, review, tag and discuss their books. Users could also create groups that other members could join, create discussions and talk about books, or other topics. Recommendations could be sent to friends on the site for what books to read. Amazon bought the company in August 2008. Shelfari continued to function as an independent book social network within the Amazon until January 2016, when Amazon announced that it would be merging Shelfari with Goodreads and closing down Shelfari.', 'title': 'Shelfari', 'title_stack': ['Subsidiaries', 'Shelfari'], 'wiki_links': ['Shelfari', 'social cataloging', 'tag (metadata)'], 'doc_title': 'Amazon (company)', 'section_id': 'Ch1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Junglee', 'text': 'Junglee is a former online shopping service provided by Amazon that enabled customers to search for products from online and offline retailers in India. Junglee started off as a virtual database that was used to extract information off the internet and deliver it to enterprise applications. As it progressed, Junglee started to use its database technology to create a single window marketplace on the internet by making every item from every supplier available for purchase. Web shoppers could locate, compare and transact millions of products from across the Internet shopping mall through one window.\n\nAmazon acquired Junglee in 1998, and the website Junglee.com was launched in India in February 2012 as a comparison-shopping website. It curated and enabled searching for a diverse variety of products such as clothing, electronics, toys, jewelry and video games, among others, across thousands of online and offline sellers. Millions of products are browse-able, whereby the client selects a price, and then they are directed to a seller. In November 2017, Amazon closed down Junglee.com and the former domain currently redirects to Amazon India.', 'title': 'Junglee', 'title_stack': ['Subsidiaries', 'Junglee'], 'wiki_links': [], 'doc_title': 'Amazon (company)', 'section_id': 'Dh1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Supply chain', 'text': 'Amazon first launched its distribution network in 1997 with two fulfillment centers in Seattle and New Castle, Delaware. Amazon has several types of distribution facilities consisting of crossdock centers, fulfillment centers, sortation centers, delivery stations, Prime now hubs, and Prime air hubs. There are 75 fulfillment centers and 25 sortation centers with over 125,000 employees. Employees are responsible for five basic tasks: unpacking and inspecting incoming goods; placing goods in storage and recording their location; picking goods from their computer recorded locations to make up an individual shipment; sorting and packing orders; and shipping. A computer that records the location of goods and maps out routes for pickers plays a key role: employees carry hand-held computers which communicate with the central computer and monitor their rate of progress.', 'title': 'Supply chain', 'title_stack': ['Supply chain'], 'wiki_links': ['Seattle', 'New Castle, Delaware'], 'doc_title': 'Amazon (company)', 'section_id': 'Dx1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Website', 'text': "The domain amazon.com attracted at least 615 million visitors annually by 2008.SnapShot of amazon.com, amazonellers.com, walmart.com. Retrieved April 12, 2008. Amazon attracts over 130 million customers to its US website per month by the start of 2016. The company has also invested heavily on a massive amount of server capacity for its website, especially to handle the excessive traffic during the December Christmas holiday season.\n\nResults generated by Amazon's search engine are partly determined by promotional fees.\n\nAmazon's localized storefronts, which differ in selection and prices, are differentiated by top-level domain and country code:\n\n Region  Country  Domain nameSince Asia   amazon.cnSeptember 2004   amazon.inJune 2013   amazon.co.jpNovember 2000   amazon.com.sgJuly 2017   amazon.com.trSeptember 2018   amazon.aeMay 2019 Europe   amazon.frAugust 2000   amazon.deOctober 1998   amazon.itNovember 2010   amazon.nlNovember 2014   amazon.esSeptember 2011   amazon.co.ukOctober 1998 North America   amazon.caJune 2002   amazon.com.mxAugust 2013   amazon.comJuly 1995 Oceania    amazon.com.auNovember 2017 South America    amazon.com.brDecember 2012", 'title': 'Website', 'title_stack': ['Website'], 'wiki_links': ['E-commerce', 'C++', 'Java (programming language)', 'Alexa Internet', 'Christmas holiday season', 'The New Yorker', 'Internationalization and localization', 'top-level domain', 'country code', 'Domain name', '.cn', '.in', '.jp', '.sg', '.tr', '.ae', '.fr', '.de', '.it', '.nl', '.es', '.uk', '.ca', '.mx', '.com', '.au', '.br'], 'doc_title': 'Amazon (company)', 'section_id': 'EB1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Third-party sellers', 'text': 'Amazon derives many of its sales (around 40% in 2008) from third-party sellers who sell products on Amazon. Associates receive a commission for referring customers to Amazon by placing links to Amazon on their websites if the referral results in a sale. Worldwide, Amazon has "over 900,000 members" in its affiliate programs. In the middle of 2014, the Amazon Affiliate Program is used by 1.2% of all websites and it is the second most popular advertising network after Google Ads. It is frequently used by websites and non-profits to provide a way for supporters to earn them a commission. Amazon reported over 1.3 million sellers sold products through Amazon\'s websites in 2007. Unlike eBay, Amazon sellers do not have to maintain separate payment accounts; all payments are handled by Amazon.\n\nAssociates can access the Amazon catalog directly on their websites by using the Amazon Web Services (AWS) XML service. A new affiliate product, aStore, allows Associates to embed a subset of Amazon products within another website, or linked to another website. In June 2010, Amazon Seller Product Suggestions was launched (rumored to be internally called "Project Genesis") to provide more transparency to sellers by recommending specific products to third-party sellers to sell on Amazon. Products suggested are based on customers\' browsing history.', 'title': 'Third-party sellers', 'title_stack': ['Website', 'Third-party sellers'], 'wiki_links': ['eBay.com', 'Amazon Web Services', 'XML'], 'doc_title': 'Amazon (company)', 'section_id': 'Ex1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Income taxes', 'text': "Amazon paid no federal income taxes in the U.S. in 2017 and 2018, and actually received tax refunds worth millions of dollars, despite recording several billion dollars in profits each year. CNN reported that Amazon's tax bill was zero because they took advantage of provisions in years when they were losing money that allowed them to offset future taxes on profits, as well as various other tax credits. Amazon was criticized by political figures for not paying federal income taxes.Amazon riled up the left for not paying federal taxes — and it’s in a position to offset future profits, too (MarketWatch)", 'title': 'Income taxes', 'title_stack': ['Controversies', 'Income taxes'], 'wiki_links': ['Income tax in the United States', 'CNN'], 'doc_title': 'Amazon (company)', 'section_id': 'Gx1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Audible.com', 'text': "Audible.com is a seller and producer of spoken audio entertainment, information and educational programming on the Internet. Audible sells digital audiobooks, radio and TV programs and audio versions of magazines and newspapers. Through its production arm, Audible Studios, Audible has also become the world's largest producer of downloadable audiobooks. On January 31, 2008, Amazon announced it would buy Audible for about $300 million. The deal closed in March 2008 and Audible became a subsidiary of Amazon.", 'title': 'Audible.com', 'title_stack': ['Subsidiaries', 'Audible.com'], 'wiki_links': ['Audible.com', 'audiobooks'], 'doc_title': 'Amazon (company)', 'section_id': 'Jyhf-G8BOk9B9AIxhQVC', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'ComiXology', 'text': 'ComiXology is a cloud-based digital comics platform with over 200 million comic downloads . It offers a selection of more than 40,000 comic books and graphic novels across Android, iOS, Fire OS and Windows 8 devices and over a web browser. Amazon bought the company in April 2014.', 'title': 'ComiXology', 'title_stack': ['Subsidiaries', 'ComiXology'], 'wiki_links': ['ComiXology', 'Cloud computing'], 'doc_title': 'Amazon (company)', 'section_id': 'Ax1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Goodreads', 'text': 'Goodreads is a "social cataloging" website founded in December 2006 and launched in January 2007 by Otis Chandler, a software engineer, and entrepreneur, and Elizabeth Chandler. The website allows individuals to freely search Goodreads\' extensive user-populated database of books, annotations, and reviews. Users can sign up and register books to generate library catalogs and reading lists. They can also create their own groups of book suggestions and discussions. In December 2007, the site had over 650,000 members and over 10 million books had been added. Amazon bought the company in March 2013.', 'title': 'Goodreads', 'title_stack': ['Subsidiaries', 'Goodreads'], 'wiki_links': ['Goodreads', 'social cataloging'], 'doc_title': 'Amazon (company)', 'section_id': 'Bh1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Kuiper Systems', 'text': 'Amazon announced that they would fund and deploy a large broadband satellite internet constellation called "Project Kuiper" in April 2019. It is expected to take up to a decade to fully deploy all 3,236 satellites planned for the full constellation in order to provide internet to "tens of millions of people who lack basic access to broadband internet." Amazon has not announced if they intend to sell broadband service directly to consumers, but they will "offer broadband service through partnerships with other companies."\n\nThe satellites will use an orbit with a height between . Kuiper will work in concert with Amazon\'s previously announced large network of 12 satellite ground station facilities (the "AWS Ground Station unit") announced in November 2018. Amazon filed communications license documents with the U.S. regulatory authorities the FCC in July 2019, which included information that the wholly owned Amazon subsidiary that intended to deploy the satellite constellation was Kuiper Systems LLC, based in Seattle, Washington.  The Kuiper System will consist of 3,236 satellites operating in 98 orbital planes in three orbital shells, one each at , , and  orbital altitude.Amazon lays out constellation service goals, deployment and deorbit plans to FCC, Caleb Henry, SpaceNews, 8 July 2019, accessed 9 September 2019.  The Kuiper System includes high-performance satellites, terrestrial gateways, internetworking technologies, and a range of customer terminals."\n\nThe president of Kuiper Systems is Rajeev Badyal, a former vice president of SpaceX satellite internet constellation business unit.', 'title': 'Kuiper Systems', 'title_stack': ['Subsidiaries', 'Kuiper Systems'], 'wiki_links': ['broadband', 'satellite internet constellation', 'CNBC', 'SpaceNews', 'broadband', 'CNBC', 'regulatory authority', 'FCC', 'Orbital plane (astronomy)', 'Orbital shell (spaceflight)', 'orbital altitude', 'SpaceNews', 'Gateway (telecommunications)', 'FEDERAL COMMUNICATIONS COMMISSION', 'SpaceX'], 'doc_title': 'Amazon (company)', 'section_id': 'CB1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Content search', 'text': '"Search Inside the Book" is a feature which allows customers to search for keywords in the full text of many books in the catalog. The feature started with 120,000 titles (or 33 million pages of text) on October 23, 2003. There are about 300,000 books in the program. Amazon has cooperated with around 130 publishers to allow users to perform these searches.\n\nTo avoid copyright violations, Amazon does not return the computer-readable text of the book. Instead, it returns a picture of the matching page, instructs the web browser to disable printing and puts limits on the number of pages in a book a single user can access. Additionally, customers can purchase online access to some of the same books via the "Amazon Upgrade" program.', 'title': 'Content search', 'title_stack': ['Website', 'Content search'], 'wiki_links': ['publisher'], 'doc_title': 'Amazon (company)', 'section_id': 'Eh1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Multi-level sales strategy', 'text': "Amazon employs a multi-level e-commerce strategy. Amazon started by focusing on business-to-consumer relationships between itself and its customers and business-to-business relationships between itself and its suppliers and then moved to facilitate customer-to-customer with the Amazon marketplace which acts as an intermediary to facilitate transactions. The company lets anyone sell nearly anything using its platform. In addition to an affiliate program that lets anyone post-Amazon links and earn a commission on click-through sales, there is now a program which lets those affiliates build entire websites based on Amazon's platform.\n\nSome other large e-commerce sellers use Amazon to sell their products in addition to selling them through their own websites. The sales are processed through Amazon.com and end up at individual sellers for processing and order fulfillment and Amazon leases space for these retailers. Small sellers of used and new goods go to Amazon Marketplace to offer goods at a fixed price.\n\nAmazon also employs the use of drop shippers or meta sellers. These are members or entities that advertise goods on Amazon who order these goods direct from other competing websites but usually from other Amazon members. These meta sellers may have millions of products listed, have large transaction numbers and are grouped alongside other less prolific members giving them credibility as just someone who has been in business for a long time. Markup is anywhere from 50% to 100% and sometimes more, these sellers maintain that items are in stock when the opposite is true. As Amazon increases their dominance in the marketplace these drop shippers have become more and more commonplace in recent years.\n\nIn November 2015, Amazon opened a physical Amazon Books store in University Village in Seattle. The store is 5,500 square feet and prices for all products match those on its website. Amazon will open its tenth physical book store in 2017; media speculation suggests Amazon plans to eventually roll out 300 to 400 bookstores around the country.\n\nAmazon plans to open brick and mortar bookstores in Germany.", 'title': 'Multi-level sales strategy', 'title_stack': ['Multi-level sales strategy'], 'wiki_links': ['drop shipping', 'University Village, Seattle'], 'doc_title': 'Amazon (company)', 'section_id': 'FR1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Selling counterfeit items', 'text': 'On October 16, 2016, Apple filed a trademark infringement case against Mobile Star LLC for selling counterfeit Apple products to Amazon. In the suit, Apple provided evidence that Amazon was selling these counterfeit Apple products and advertising them as genuine. Through purchasing, Apple found that it was able to identify counterfeit products with a success rate of 90%. Amazon was sourcing and selling items without properly determining if they are genuine. Mobile Star LLC settled with Apple for an undisclosed amount on April 27, 2017.', 'title': 'Selling counterfeit items', 'title_stack': ['Controversies', 'Selling counterfeit items'], 'wiki_links': ['Apple Inc.'], 'doc_title': 'Amazon (company)', 'section_id': 'GR1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Seattle head tax and houselessness services', 'text': 'In May 2018, Amazon threatened the Seattle City Council over an employee head tax proposal that would have funded houselessness services and low-income housing. The tax would have cost Amazon about $800 per employee, or 0.7% of their average salary. In retaliation, Amazon paused construction on a new building, threatened to limit further investment in the city, and funded a repeal campaign. Although originally passed, the measure was soon repealed after an expensive repeal campaign spearheaded by Amazon.', 'title': 'Seattle head tax and houselessness services', 'title_stack': ['Controversies', 'Seattle head tax and houselessness services'], 'wiki_links': ['Seattle City Council', 'Seattle head tax'], 'doc_title': 'Amazon (company)', 'section_id': 'Hx1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': '', 'text': "Amazon.com, Inc. (), is an American multinational technology company based in Seattle, Washington, that focuses on e-commerce, cloud computing, digital streaming, and artificial intelligence. It is considered one of the Big Four technology companies along with Google, Apple, and Facebook.\n\nAmazon is known for its disruption of well-established industries through technological innovation and mass scale. It is the world's largest e-commerce marketplace, AI assistant provider, and cloud computing platform as measured by revenue and market capitalization. Amazon is the largest Internet company by revenue in the world. It is the second largest private employer in the United States and one of the world's most valuable companies. Amazon is the second largest technology company by revenue.\n\nAmazon was founded by Jeff Bezos on July 5, 1994, in Bellevue, Washington. The company initially started as an online marketplace for books but later expanded to sell electronics, software, video games, apparel, furniture, food, toys, and jewelry. In 2015, Amazon surpassed Walmart as the most valuable retailer in the United States by market capitalization.\nIn 2017, Amazon acquired Whole Foods Market for $13.4 billion, which vastly increased Amazon's presence as a brick-and-mortar retailer. In 2018, Bezos announced that its two-day delivery service, Amazon Prime, had surpassed 100 million subscribers worldwide.\n\nAmazon distributes downloads and streaming of video, music, audiobook through its Amazon Prime Video, Amazon Music, and Audible subsidiaries. Amazon also has a publishing arm, Amazon Publishing, a film and television studio, Amazon Studios, and a cloud computing subsidiary, Amazon Web Services. It produces consumer electronics including Kindle e-readers, Fire tablets, Fire TV, and Echo devices. In addition, Amazon subsidiaries include Ring, Twitch.tv, Whole Foods Market, and IMDb. Among various controversies, the company has been criticized for technological surveillance overreach, a hyper-competitive and demanding work culture, tax avoidance, and anti-competitive practices.", 'title': '', 'title_stack': [''], 'wiki_links': ['Amazon Spheres', 'Doppler (building)', 'Public company', 'NASDAQ-100', 'S&P 100', 'S&P 500', 'Cloud computing', 'E-commerce', 'Artificial intelligence', 'Consumer electronics', 'Digital distribution', 'Bellevue, Washington', 'United States', 'Jeff Bezos', 'Seattle', 'Washington (state)', 'Arlington County, Virginia', 'Virginia', 'United States', 'chairman', 'President (corporate title)', 'Chief executive officer', 'Werner Vogels', 'Chief technology officer', 'Amazon Echo', 'Amazon Fire tablet', 'Amazon Fire TV', 'Fire OS', 'Amazon Kindle', 'Amazon (company)#Website', 'Amazon Alexa', 'Amazon Appstore', 'Amazon Music', 'Amazon Prime', 'Amazon Prime Video', 'Amazon web services', 'A9.com', 'AbeBooks', 'Amazon Air', 'Alexa Internet', 'Amazon Books', 'Amazon Game Studios', 'Amazon Lab126', 'Amazon Publishing', 'Amazon Robotics', 'Amazon Studios', 'Audible Inc.', 'Body Labs', 'Amazon Web Services', 'Book Depository', 'ComiXology', 'Goodreads', 'Graphiq', 'IMDb', 'Ring (company)', 'Souq.com', 'Twitch.tv', 'Whole Foods Market', 'Woot', 'Zappos', 'NASDAQ', 'Seattle', 'e-commerce', 'cloud computing', 'digital streaming', 'artificial intelligence', 'Big Four tech companies', 'Google', 'Apple (company)', 'Facebook', 'Online marketplace', 'AI assistant', 'cloud computing', 'revenue', 'market capitalization', 'List of largest Internet companies', 'List of largest employers in the United States', 'List of public corporations by market capitalization', 'List of largest technology companies by revenue', 'Jeff Bezos', 'Bellevue, Washington', 'Walmart', 'market capitalization', 'Whole Foods Market', 'Amazon Prime', 'Amazon Video', 'Audible.com', 'Prime Video', 'Amazon Music', 'Audible (store)', 'Amazon Publishing', 'Amazon Studios', 'AWS', 'consumer electronics', 'Amazon Kindle', 'e-reader', 'Kindle Fire', 'tablet computer', 'Fire TV', 'Amazon Echo', 'Ring (company)', 'Twitch.tv', 'IMDb', 'Criticism of Amazon', 'tax avoidance', 'anti-competitive practices'], 'doc_title': 'Amazon (company)', 'section_id': 'Hyhf-G8BOk9B9AIxhQVC', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Brilliance Audio', 'text': 'Brilliance Audio is an audiobook publisher founded in 1984 by Michael Snodgrass in Grand Haven, Michigan. The company produced its first 8 audio titles in 1985. The company was purchased by Amazon in 2007 for an undisclosed amount. At the time of the acquisition, Brilliance was producing 12–15 new titles a month. It operates as an independent company within Amazon.\n\nIn 1984, Brilliance Audio invented a technique for recording twice as much on the same cassette. The technique involved recording on each of the two channels of each stereo track. It has been credited with revolutionizing the burgeoning audiobook market in the mid-1980s since it made unabridged books affordable.', 'title': 'Brilliance Audio', 'title_stack': ['Subsidiaries', 'Brilliance Audio'], 'wiki_links': ['Grand Haven, Michigan'], 'doc_title': 'Amazon (company)', 'section_id': 'Ah1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Souq', 'text': "Souq.com is the largest e-commerce platform in the Middle East based in Dubai, United Arab Emirates. On March 28, 2017, Amazon confirmed it would be acquiring Souq.com for $580 million. Souq.com is now a subsidiary of Amazon, and acts as Amazon's arm into the Middle East region.", 'title': 'Souq', 'title_stack': ['Subsidiaries', 'Souq'], 'wiki_links': ['Souq.com'], 'doc_title': 'Amazon (company)', 'section_id': 'Cx1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Amazon sales rank', 'text': 'The Amazon sales rank (ASR) provides an indication of the popularity of a product sold on any Amazon locale. It is a relative indicator of popularity that is updated hourly. Effectively, it is a "best sellers list" for the millions of products stocked by Amazon. While the ASR has no direct effect on the sales of a product, it is used by Amazon to determine which products to include in its bestsellers lists. Products that appear in these lists enjoy additional exposure on the Amazon website and this may lead to an increase in sales. In particular, products that experience large jumps (up or down) in their sales ranks may be included within Amazon\'s lists of "movers and shakers"; such a listing provides additional exposure that might lead to an increase in sales. For competitive reasons, Amazon does not release actual sales figures to the public. However, Amazon has now begun to release point of sale data via the Nielsen BookScan service to verified authors. While the ASR has been the source of much speculation by publishers, manufacturers, and marketers, Amazon itself does not release the details of its sales rank calculation algorithm. Some companies have analyzed Amazon sales data to generate sales estimates based on the ASR, though Amazon states:', 'title': 'Amazon sales rank', 'title_stack': ['Amazon sales rank'], 'wiki_links': ['point of sale', 'Nielsen BookScan'], 'doc_title': 'Amazon (company)', 'section_id': 'FB1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Environmental impact', 'text': 'In November 2018, a community action group opposed the construction permit delivered to Goodman Group for the construction of a  logisitics platform Amazon will operate at Lyon–Saint-Exupéry Airport. In February 2019, Étienne Tête filed a request on behalf of a second regional community action group asking the administrative court to decide whether the platform served a sufficiently important public interest to justify its environmental impact. Construction has been suspended while these matters are decided.', 'title': 'Environmental impact', 'title_stack': ['Controversies', 'Environmental impact'], 'wiki_links': ['Goodman Group', 'Lyon–Saint-Exupéry Airport', ':fr:Étienne Tête', 'Le Progrès'], 'doc_title': 'Amazon (company)', 'section_id': 'GB1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Sales and use taxes', 'text': "Amazon's state sales tax collection policy has changed over the years since it did not collect any sales taxes in its early years. In the U.S., state and local sales taxes are levied by state and local governments, not at the federal level. In most countries where Amazon operates, a sales tax or value added tax is uniform throughout the country, and Amazon is obliged to collect it from all customers. Proponents of forcing Amazon.com to collect sales tax—at least in states where it maintains a physical presence—argue the corporation wields an anti-competitive advantage over storefront businesses forced to collect sales tax.\n\nMany U.S. states in the 21st century have passed online shopping sales tax laws designed to compel Amazon.com and other e-commerce retailers to collect state and local sales taxes from its customers. Amazon.com originally collected sales tax only from five states , but , Amazon collects sales taxes from customers in all 45 states that have a state sales tax and in Washington, D.C.", 'title': 'Sales and use taxes', 'title_stack': ['Controversies', 'Sales and use taxes'], 'wiki_links': ['Sales taxes in the United States', 'value added tax', 'online shopping', 'e-commerce', 'Washington, D.C.'], 'doc_title': 'Amazon (company)', 'section_id': 'Gh1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Comments by Donald Trump and Bernie Sanders', 'text': 'In early 2018, President Donald Trump repeatedly criticized Amazon\'s use of the United States Postal Service and its prices for the delivery of packages, stating, "I am right about Amazon costing the United States Post Office massive amounts of money for being their Delivery Boy," Trump tweeted. "Amazon should pay these costs (plus) and not have them bourne [sic] by the American Taxpayer." Amazon\'s shares fell by 6 percent as a result of Trump\'s comments. Shepard Smith of Fox News disputed Trump\'s claims and pointed to evidence that the USPS was offering below-market prices to all customers with no advantage to Amazon. However, analyst Tom Forte pointed to the fact that Amazon\'s payments to the USPS are not made public and that their contract has a reputation for being "a sweetheart deal".\n\nThroughout the summer of 2018, Vermont Senator Bernie Sanders criticized Amazon\'s wages and working conditions in a series of YouTube videos and media appearances. He also pointed to the fact that Amazon had paid no federal income tax in the previous year. Sanders solicited stories from Amazon warehouse workers who felt exploited by the company. One such story, by James Bloodworth, described the environment as akin to "a low-security prison" and stated that the company\'s culture used an Orwellian newspeak. These reports cited a finding by New Food Economy that one third of fulfilment center workers in Arizona were on the Supplemental Nutrition Assistance Program (SNAP). Responses by Amazon included incentives for employees to tweet positive stories and a statement which called the salary figures used by Sanders "inaccurate and misleading". The statement also charged that it was inappropriate for him to refer to SNAP as "food stamps". On September 5, 2018, Sanders along with Ro Khanna introduced the Stop Bad Employers by Zeroing Out Subsidies (Stop BEZOS) Act aimed at Amazon and other alleged beneficiaries of corporate welfare such as Walmart, McDonald\'s and Uber. Among the bill\'s supporters were Tucker Carlson of Fox News and Matt Taibbi who criticized himself and other journalists for not covering Amazon\'s contribution to wealth inequality earlier.\n\nOn October 2, Amazon announced that its minimum wage for all American employees would be raised to $15 per hour. Sanders congratulated the company for making this decision.', 'title': 'Comments by Donald Trump and Bernie Sanders', 'title_stack': ['Controversies', 'Comments by Donald Trump and Bernie Sanders'], 'wiki_links': ['Donald Trump', 'United States Postal Service', 'Shepard Smith', 'Fox News', 'Bernie Sanders', 'YouTube', 'James Bloodworth (journalist)', 'newspeak', 'Supplemental Nutrition Assistance Program', 'Ro Khanna', 'Jeff Bezos', 'corporate welfare', 'Walmart', "McDonald's", 'Uber', 'Tucker Carlson', 'Fox News', 'Matt Taibbi'], 'doc_title': 'Amazon (company)', 'section_id': 'HB1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Nashville Operations Center of Excellence', 'text': 'The incentives given by the Metropolitan Council of Nashville and Davidson County to Amazon for their new Operations Center of Excellence in Nashville Yards, a site owned by developer Southwest Value Partners, have been controversial, including the decision by the Tennessee Department of Economic and Community Development to keep the full extent of the agreement secret. The incentives include "$102 million in combined grants and tax credits for a scaled-down Amazon office building" as well as "a $65 million cash grant for capital expenditures" in exchange for the creation of 5,000 jobs over seven years.\n\nThe Tennessee Coalition for Open Government called for more transparency. Another local organization known as the People\'s Alliance for Transit, Housing, and Employment (PATHE) suggested no public money should be given to Amazon; instead, it should be spent on building more public housing for the working poor and the homeless and investing in more public transportation for Nashvillians. Others suggested incentives to big corporations don\'t improve the local economy.\n\nIn November 2018, the proposal to give Amazon $15 million in incentives was criticized by the Nashville Firefighters Union and the Nashville chapter of the Fraternal Order of Police, who called it "corporate welfare." In February 2019, another $15.2 million in infrastructure was approved by the council, although it was voted down by three council members, including Councilwoman Angie Henderson who dismissed it as "cronyism".', 'title': 'Nashville Operations Center of Excellence', 'title_stack': ['Controversies', 'Nashville Operations Center of Excellence'], 'wiki_links': ['Metropolitan Council of Nashville and Davidson County', 'Nashville Yards', 'Southwest Value Partners', 'Fraternal Order of Police', 'corporate welfare', 'cronyism'], 'doc_title': 'Amazon (company)', 'section_id': 'IB1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Products and services', 'text': "Amazon.com's product lines available at its website include several media (books, DVDs, music CDs, videotapes and software), apparel, baby products, consumer electronics, beauty products, gourmet food, groceries, health and personal-care items, industrial & scientific supplies, kitchen items, jewelry, watches, lawn and garden items, musical instruments, sporting goods, tools, automotive items and toys & games. In August 2019, Amazon applied to have a liquor store in San Francisco, CA as a means to ship beer and alcohol within the city. Amazon has separate retail websites for some countries and also offers international shipping of some of its products to certain other countries.\n\nAmazon.com has a number of products and services available, including:\n\n AmazonFresh\n Amazon Prime\n Amazon Web Services\n Alexa\n Appstore\n Amazon Drive\n Echo\n Kindle\n Fire tablets\n Fire TV\n Video\n Kindle Store\n Music\n Music Unlimited\n Amazon Digital Game Store\n Amazon Studios\n AmazonWireless", 'title': 'Products and services', 'title_stack': ['Products and services'], 'wiki_links': ['book', 'VHS', 'consumer electronics', 'Cosmetics', 'jewelry', 'Sports equipment', 'AmazonFresh', 'Amazon Prime', 'Amazon Web Services', 'Amazon Alexa', 'Amazon Appstore', 'Amazon Drive', 'Amazon Echo', 'Amazon Kindle', 'Kindle Fire', 'Amazon Fire TV', 'Amazon Video', 'Kindle Store', 'Amazon Music', 'Amazon Music Unlimited', 'Amazon Digital Game Store', 'Amazon Studios', 'AmazonWireless'], 'doc_title': 'Amazon (company)', 'section_id': 'Iyhf-G8BOk9B9AIxhQVC', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Amazon Maritime', 'text': 'Amazon Maritime, Inc. holds a Federal Maritime Commission license to operate as a non-vessel-owning common carrier (NVOCC), which enables the company to manage its own shipments from China into the United States.Steele, B., Amazon is now managing its own ocean freight, engadget.com, January 27, 2017, accessed January 29, 2017', 'title': 'Amazon Maritime', 'title_stack': ['Subsidiaries', 'Amazon Maritime'], 'wiki_links': ['Federal Maritime Commission', 'NVOCC', 'engadget.com'], 'doc_title': 'Amazon (company)', 'section_id': 'Jihf-G8BOk9B9AIxhQVC', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Twitch', 'text': 'Twitch is a live streaming platform for video, primarily oriented towards video gaming content. The service was first established as a spin-off of a general-interest streaming service known as Justin.tv. Its prominence was eclipsed by that of Twitch, and Justin.tv was eventually shut down by its parent company in August 2014 in order to focus exclusively on Twitch. Later that month, Twitch was acquired by Amazon for $970 million. Through Twitch, Amazon also owns Curse, Inc., an operator of video gaming communities and a provider of VoIP services for gaming. Since the acquisition, Twitch began to sell games directly through the platform, and began offering special features for Amazon Prime subscribers.\n\nThe site\'s rapid growth had been boosted primarily by the prominence of major esports competitions on the service, leading GameSpot senior esports editor Rod Breslau to have described the service as "the ESPN of esports". , the service had over 1.5 million broadcasters and 100 million monthly viewers.', 'title': 'Twitch', 'title_stack': ['Subsidiaries', 'Twitch'], 'wiki_links': ['Twitch.tv', 'live streaming', 'Justin.tv', 'Curse, Inc.', 'VoIP', 'esports', 'GameSpot', 'ESPN'], 'doc_title': 'Amazon (company)', 'section_id': 'DB1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Whole Foods Market', 'text': 'Whole Foods Market is an American supermarket chain exclusively featuring foods without artificial preservatives, colors, flavors, sweeteners, and hydrogenated fats.\n\nOn August 23, 2017, it was reported that the Federal Trade Commission approved the merger between Amazon.com and Whole Foods Market. The following day it was announced that the deal would be closed on August 28, 2017.', 'title': 'Whole Foods Market', 'title_stack': ['Subsidiaries', 'Whole Foods Market'], 'wiki_links': ['Whole Foods Market', 'supermarket', 'chain store', 'Federal Trade Commission'], 'doc_title': 'Amazon (company)', 'section_id': 'DR1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Finances', 'text': "Amazon.com is primarily a retail site with a sales revenue model; Amazon takes a small percentage of the sale price of each item that is sold through its website while also allowing companies to advertise their products by paying to be listed as featured products. , Amazon.com is ranked 8th on the Fortune 500 rankings of the largest United States corporations by total revenue.\n\nFor the fiscal year 2018, Amazon reported earnings of US$10.07 billion, with an annual revenue of US$232.887 billion, an increase of 30.9% over the previous fiscal cycle. Since 2007 sales increased from 14.835 billion to 232.887 billion, thanks to continued business expansion. Amazon's market capitalization was valued at over US$803 billion in early November 2018.\nYearRevenuein mil. USD$Net incomein mil. USD$Total Assetsin mil. USD$Employees200714,8354766,48517,000200819,1666458,31420,700200924,50990213,81324,300201034,2041,15218,79733,700201148,07763125,27856,200201261,093−3932,55588,400201374,45227440,159117,300201488,988−24154,505154,1002015107,00659664,747230,8002016135,9872,37183,402341,4002017177,8663,033131,310566,0002018232,88710,073162,648647,500", 'title': 'Finances', 'title_stack': ['Finances'], 'wiki_links': ['Fortune 500', 'The Guardian'], 'doc_title': 'Amazon (company)', 'section_id': 'Fh1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Conflict of interest with the CIA and DOD', 'text': 'In 2013, Amazon secured a  contract with the CIA, which poses a potential conflict of interest involving the Bezos-owned The Washington Post and his newspaper\'s coverage of the CIA."The CIA, Amazon, Bezos and the Washington Post : An Exchange with Executive Editor Martin Baron". The Huffington Post. January 8, 2014. Kate Martin, director of the Center for National Security Studies, said, "It\'s a serious potential conflict of interest for a major newspaper like The Washington Post to have a contractual relationship with the government and the most secret part of the government." This was later followed by a  contract with the Department of Defence.', 'title': 'Conflict of interest with the CIA and DOD', 'title_stack': ['Controversies', 'Conflict of interest with the CIA and DOD'], 'wiki_links': ['CIA', 'conflict of interest', 'The Washington Post'], 'doc_title': 'Amazon (company)', 'section_id': 'Hh1f-G8BtLQBgyHGiGGf', 'score': 0.0}, {'offensive': 'false', 'doc_id': '90451', 'title_keyword': 'Lobbying', 'text': "Amazon lobbies the United States federal government and state governments on issues such as the enforcement of sales taxes on online sales, transportation safety, privacy and data protection and intellectual property. According to regulatory filings, Amazon.com focuses its lobbying on the United States Congress, the Federal Communications Commission and the Federal Reserve. Amazon.com spent roughly $3.5 million, $5 million and $9.5 million on lobbying, in 2013, 2014 and 2015, respectively.\n\nAmazon.com was a corporate member of the American Legislative Exchange Council (ALEC) until it dropped membership following protests at its shareholders' meeting on May 24, 2012.\n\nIn 2014, Amazon expanded its lobbying practices as it prepared to lobby the Federal Aviation Administration to approve its drone delivery program, hiring the Akin Gump Strauss Hauer & Feld lobbying firm in June. Amazon and its lobbyists have visited with Federal Aviation Administration officials and aviation committees in Washington, D.C. to explain its plans to deliver packages.", 'title': 'Lobbying', 'title_stack': ['Lobbying'], 'wiki_links': ['Information privacy', 'United States Congress', 'Federal Communications Commission', 'Federal Reserve System', 'American Legislative Exchange Council', 'Federal Aviation Administration', 'Akin Gump Strauss Hauer & Feld'], 'doc_title': 'Amazon (company)', 'section_id': 'Ih1f-G8BtLQBgyHGiGGf', 'score': 0.0}]


def remove_parens(s):
    if '(' not in s: return s
    return s[:s.index('(')].strip()


def remove_overlap(old_string: str, new_string: str) -> str:
    """Removes overlapping elements from new string. Returns the longest contiguous substring from the new string. """
    non_overlapping_sequence = ''
    for (tag, i1, i2, j1, j2) in SequenceMatcher(lambda x: x in " \t\n", old_string, new_string).get_opcodes():
        if tag == 'insert' or tag == 'replace':
            if j2-j1 > len(non_overlapping_sequence):
                non_overlapping_sequence = new_string[j1:j2]
    return non_overlapping_sequence

def split_dict_with_length(d, l):
    a = {key: (value[:l]) if isinstance(value, list) else value for key, value in d.items()}
    b = {key: (value[l:]) if isinstance(value, list) else value for key, value in d.items()}
    logger.primary_info(f"{a} {b}")
    return a, b
