Esempio n. 1
0
File: main.py Progetto: kowey/educe
def copy_parses(settings):
    "Copy relevant stanford parser outputs from corpus to report"
    output_dir = settings.output_dir

    docs = set(k.doc for k in settings.corpus)
    for doc in docs:
        subdocs = set(k.subdoc for k in settings.corpus if k.doc == doc)
        if subdocs:
            k = FileId(doc=doc,
                       subdoc=list(subdocs)[0],
                       stage=None,
                       annotator=None)
            i_style_dir = fp.dirname(parsed_file_name(k, settings.corpus_dir))
            o_style_dir = fp.dirname(parsed_file_name(k, output_dir))
            i_style_file = fp.join(i_style_dir, 'CoreNLP-to-HTML.xsl')
            if fp.exists(i_style_file):
                if not fp.exists(o_style_dir):
                    os.makedirs(o_style_dir)
                shutil.copy(i_style_file, o_style_dir)
        for subdoc in subdocs:
            k = FileId(doc=doc, subdoc=subdoc, stage=None, annotator=None)
            i_file = parsed_file_name(k, settings.corpus_dir)
            o_file = parsed_file_name(k, output_dir)
            o_dir = fp.dirname(o_file)
            if fp.exists(i_file):
                if not fp.exists(o_dir):
                    os.makedirs(o_dir)
                shutil.copy(i_file, o_dir)
Esempio n. 2
0
def copy_parses(settings):
    corpus = settings.corpus
    output_dir = settings.output_dir

    docs = set(k.doc for k in settings.corpus)
    for doc in docs:
        subdocs = set(k.subdoc for k in settings.corpus if k.doc == doc)
        if subdocs:
            k = FileId(doc=doc,
                       subdoc=list(subdocs)[0],
                       stage=None,
                       annotator=None)
            i_style_dir = os.path.dirname(stac_corenlp.parsed_file_name(k, settings.corpus_dir))
            o_style_dir = os.path.dirname(stac_corenlp.parsed_file_name(k, output_dir))
            i_style_file = os.path.join(i_style_dir, 'CoreNLP-to-HTML.xsl')
            if os.path.exists(i_style_file):
                if not os.path.exists(o_style_dir):
                    os.makedirs(o_style_dir)
                shutil.copy(i_style_file, o_style_dir)
        for subdoc in subdocs:
            k = FileId(doc=doc, subdoc=subdoc, stage=None, annotator=None)
            i_file = stac_corenlp.parsed_file_name(k, settings.corpus_dir)
            o_file = stac_corenlp.parsed_file_name(k, output_dir)
            o_dir = os.path.dirname(o_file)
            if os.path.exists(i_file):
                if not os.path.exists(o_dir):
                    os.makedirs(o_dir)
                shutil.copy(i_file, o_dir)
Esempio n. 3
0
def copy_parses(settings):
    "Copy relevant stanford parser outputs from corpus to report"
    output_dir = settings.output_dir

    docs = set(k.doc for k in settings.corpus)
    for doc in docs:
        subdocs = set(k.subdoc for k in settings.corpus if k.doc == doc)
        if subdocs:
            k = FileId(doc=doc,
                       subdoc=list(subdocs)[0],
                       stage=None,
                       annotator=None)
            i_style_dir = fp.dirname(parsed_file_name(k, settings.corpus_dir))
            o_style_dir = fp.dirname(parsed_file_name(k, output_dir))
            i_style_file = fp.join(i_style_dir, 'CoreNLP-to-HTML.xsl')
            if fp.exists(i_style_file):
                if not fp.exists(o_style_dir):
                    os.makedirs(o_style_dir)
                shutil.copy(i_style_file, o_style_dir)
        for subdoc in subdocs:
            k = FileId(doc=doc, subdoc=subdoc, stage=None, annotator=None)
            i_file = parsed_file_name(k, settings.corpus_dir)
            o_file = parsed_file_name(k, output_dir)
            o_dir = fp.dirname(o_file)
            if fp.exists(i_file):
                if not fp.exists(o_dir):
                    os.makedirs(o_dir)
                shutil.copy(i_file, o_dir)
Esempio n. 4
0
def _prepare_path(output_dir, k):
    """
    Return an output filename and create its parent dir if needed
    """
    output_path = parsed_file_name(k, output_dir)
    parent_dir = fp.dirname(output_path)
    if not fp.exists(parent_dir):
        os.makedirs(parent_dir)
    return output_path
Esempio n. 5
0
def _prepare_path(output_dir, k):
    """
    Return an output filename and create its parent dir if needed
    """
    output_path = parsed_file_name(k, output_dir)
    parent_dir = fp.dirname(output_path)
    if not fp.exists(parent_dir):
        os.makedirs(parent_dir)
    return output_path