Example #1
0
def explainAnchorTextZoning(guid, max_inlinks=10, use_full_text=False):
    """
        This generates a clipping collection file, including all the citation
        contexts of other files to this file
    """
    meta=cp.Corpus.getMetadataByGUID(guid)
    all_html=["""<h1 class="title">%s</h1><span>Inlink context summary for %s</span>""" % (meta["title"],formatCitation(meta))]
    global CURRENT_CITATION
    CURRENT_CITATION=re.escape(formatCitation(meta))

    for index, link in enumerate(meta["inlinks"]):
        if index == max_inlinks:
            break
        print("Processing anchor text from %s" % link)
        doc=cp.Corpus.loadSciDoc(link)

        if not use_full_text:
            trimDocToRelevantBits(doc, guid)

        renderer=SciDocRenderer(doc)
        html=renderer.prettyPrintDocumentHTML(
            formatspans=True,
            include_bibliography=use_full_text,
            wrap_with_HTML_tags=False,
            extra_attribute_function=extraAttributes,
            citation_formatting_function=citationFormatting,
            reference_formatting_function=referenceFormatting)
        all_html.append(html)

    html=padWithHTML(" ".join(all_html))
    writeFileText(html,os.path.join(cp.Corpus.paths.output,guid+"_ilc_zoning.html"))
Example #2
0
def explainInFileZoning(guid):
    """
        Given a guid, generates a HTML visualization where sentences are tagged
        with their class for the contents of that file
    """
    doc=cp.Corpus.loadSciDoc(guid)
    renderer=SciDocRenderer(doc)
    html=renderer.prettyPrintDocumentHTML(True,True, False, extra_attribute_function=extraAttributes, wrap_with_HTML_tags=False,
        reference_formatting_function=referenceFormatting)
    html=padWithHTML(html)
    writeFileText(html,os.path.join(cp.Corpus.paths.output,guid+"_text_zoning.html"))