Example #1
0
def save_output(basename, dialoguetext, root):
    """
    Save output to a pair of files with a given name prefix
    """
    with codecs.open(basename+".ac", "w", "utf-8") as out:
        out.write(dialoguetext)
    with codecs.open(basename+".aa", "w", "ascii") as out:
        out.write(prettify(root))
Example #2
0
def save_output(basename, dialoguetext, root):
    """Save output to a pair of files with a given name prefix.

    The pair of files has extensions .ac (for text) and .aa (for
    annotations).

    Parameters
    ----------
    basename : string
        Basename for files.
    dialoguetext : string
        Text that supports the annotation.
    root : xml.etree.Element
        XML representation of the annotation on `dialoguetext`.
    """
    with codecs.open(basename + ".ac", "w", "utf-8") as out:
        out.write(dialoguetext)
    with codecs.open(basename + ".aa", "w", "ascii") as out:
        out.write(prettify(root))
Example #3
0
def save_output(basename, dialoguetext, root):
    """Save output to a pair of files with a given name prefix.

    The pair of files has extensions .ac (for text) and .aa (for
    annotations).

    Parameters
    ----------
    basename : string
        Basename for files.
    dialoguetext : string
        Text that supports the annotation.
    root : xml.etree.Element
        XML representation of the annotation on `dialoguetext`.
    """
    with codecs.open(basename + ".ac", "w", "utf-8") as out:
        out.write(dialoguetext)
    with codecs.open(basename + ".aa", "w", "ascii") as out:
        out.write(prettify(root))
Example #4
0
def main():

    #ligne de commande : python nonling_annotations.py ../../data/pilot_nonling/test/pilot14/ SILVER

    init_mk_id()

    parser = argparse.ArgumentParser()

    parser.add_argument('folder',
                        help='folder where the files to annotate are')
    parser.add_argument('metal',
                        help=('version of the game you want to '
                              'annotate (ex: GOLD)'))

    args = parser.parse_args()
    folder = os.path.abspath(args.folder)
    metal = args.metal
    name = os.path.basename(folder)

    unitsfolder = os.path.join(folder, 'units', metal)
    discoursefolder = os.path.join(folder, 'discourse', metal)

    N = len(os.listdir(unitsfolder)) / 2

    Implicit_Relations = []
    events = Events()

    for i in range(1, N + 1):
        e = events

        subdoc = name + '_%02d' % i

        textname = os.path.join(folder, 'unannotated', subdoc + '.ac')
        unitsname = os.path.join(unitsfolder, subdoc + '.aa')
        discoursename = os.path.join(discoursefolder, subdoc + '.aa')
        textfile = codecs.open(textname, 'r', 'utf-8')
        unitsfile = codecs.open(unitsname, 'r', 'ascii')
        discoursefile = codecs.open(discoursename, 'r', 'ascii')

        text = textfile.read()
        stringtree_units = unitsfile.read()
        units_tree = ET.fromstring(stringtree_units)
        stringtree_discourse = discoursefile.read()
        discourse_tree = ET.fromstring(stringtree_discourse)

        units_root = add_units_annotations(units_tree, text)
        discourse_root, events, errors = add_discourse_annotations(
            discourse_tree, text, e, subdoc)

        Implicit_Relations.extend(errors)

        with codecs.open(unitsname, 'w', 'ascii') as out:
            out.write(prettify(units_root))
        with codecs.open(discoursename, 'w', 'ascii') as out:
            out.write(prettify(discourse_root))

        textfile.close()
        unitsfile.close()
        discoursefile.close()

    if Implicit_Relations != []:
        error_report = '\n'.join(Implicit_Relations)
        filename = os.path.join(folder, 'Implicit_Relations.txt')
        with codecs.open(filename, 'w', 'ascii') as out:
            out.write(error_report)
def main():

    #ligne de commande : python nonling_annotations.py ../../data/pilot_nonling/test/pilot14/ SILVER

    init_mk_id()

    parser = argparse.ArgumentParser()

    parser.add_argument('folder', help='folder where the files to annotate are')
    parser.add_argument('metal', help=('version of the game you want to '
                                       'annotate (ex: GOLD)'))

    args = parser.parse_args()
    folder = os.path.abspath(args.folder)
    metal = args.metal
    name = os.path.basename(folder)

    unitsfolder = os.path.join(folder, 'units', metal)
    discoursefolder = os.path.join(folder, 'discourse', metal)

    N = len(os.listdir(unitsfolder)) / 2

    Implicit_Relations = []
    events = Events()

    for i in range(1, N+1):
        e = events

        subdoc = name + '_%02d' % i

        textname = os.path.join(folder, 'unannotated', subdoc + '.ac')
        unitsname = os.path.join(unitsfolder, subdoc + '.aa')
        discoursename = os.path.join(discoursefolder, subdoc + '.aa')
        textfile = codecs.open(textname, 'r', 'utf-8')
        unitsfile = codecs.open(unitsname, 'r', 'ascii')
        discoursefile = codecs.open(discoursename, 'r', 'ascii')

        text = textfile.read()
        stringtree_units = unitsfile.read()
        units_tree = ET.fromstring(stringtree_units)
        stringtree_discourse = discoursefile.read()
        discourse_tree = ET.fromstring(stringtree_discourse)

        units_root = add_units_annotations(units_tree, text)
        discourse_root, events, errors = add_discourse_annotations(
            discourse_tree, text, e, subdoc)

        Implicit_Relations.extend(errors)

        with codecs.open(unitsname, 'w', 'ascii') as out:
            out.write(prettify(units_root))
        with codecs.open(discoursename, 'w', 'ascii') as out:
            out.write(prettify(discourse_root))

        textfile.close()
        unitsfile.close()
        discoursefile.close()

    if Implicit_Relations != []:
        error_report = '\n'.join(Implicit_Relations)
        filename = os.path.join(folder, 'Implicit_Relations.txt')
        with codecs.open(filename, 'w', 'ascii') as out:
            out.write(error_report)
Example #6
0
def main():

    #ligne de commande : python nonling_annotations.py ../../data/pilot_nonling/test/pilot14/ SILVER

    init_mk_id()

    parser = argparse.ArgumentParser()

    parser.add_argument('Folder',
                        help='folder where the files to annotate are')
    parser.add_argument(
        'Metal',
        help=
        'version of the game you want to annotate : BRONZE, SILVER, or GOLD (or other)'
    )

    args = parser.parse_args()
    Folder = args.Folder
    Metal = args.Metal
    Name = Folder.split('/')[-2]

    UnitsFolder = Folder + 'units/' + Metal + '/'
    DiscourseFolder = Folder + 'discourse/' + Metal + '/'

    N = len(os.listdir(UnitsFolder)) / 2

    Implicit_Relations = []
    events = Events()

    for i in range(1, N + 1):
        e = events

        subdoc = Name + '_%02d' % i

        textname = Folder + 'unannotated/' + subdoc + '.ac'
        unitsname = UnitsFolder + subdoc + '.aa'
        discoursename = DiscourseFolder + subdoc + '.aa'
        textfile = open(textname, 'r')
        unitsfile = open(unitsname, 'r')
        discoursefile = open(discoursename, 'r')

        text = textfile.read()
        stringtree_units = unitsfile.read()
        units_tree = ET.fromstring(stringtree_units)
        stringtree_discourse = discoursefile.read()
        discourse_tree = ET.fromstring(stringtree_discourse)

        units_root = add_units_annotations(units_tree, text)
        discourse_root, events, errors = add_discourse_annotations(
            discourse_tree, text, e, subdoc)

        Implicit_Relations.extend(errors)

        with codecs.open(unitsname, 'w', 'ascii') as out:
            out.write(prettify(units_root))
        with codecs.open(discoursename, 'w', 'ascii') as out:
            out.write(prettify(discourse_root))

        textfile.close()
        unitsfile.close()
        discoursefile.close()

    if Implicit_Relations != []:
        error_report = '\n'.join(Implicit_Relations)
        filename = Folder + 'Implicit_Relations.txt'
        with codecs.open(filename, 'w', 'ascii') as out:
            out.write(error_report)
def main():

    #ligne de commande : python nonling_annotations.py ../../data/pilot_nonling/test/pilot14/ SILVER

    init_mk_id()

    parser = argparse.ArgumentParser()

    parser.add_argument('Folder', help = 'folder where the files to annotate are')
    parser.add_argument('Metal', help = 'version of the game you want to annotate : BRONZE, SILVER, or GOLD (or other)')

    args = parser.parse_args()
    Folder = args.Folder
    Metal = args.Metal
    Name = Folder.split('/')[-2]
    
    UnitsFolder = Folder + 'units/' + Metal + '/'
    DiscourseFolder = Folder + 'discourse/' + Metal + '/'

    N = len(os.listdir(UnitsFolder)) / 2
    
    Implicit_Relations = []
    events = Events()

    for i in range(1, N+1):
        e = events

        subdoc = Name + '_%02d' % i

        textname = Folder + 'unannotated/' + subdoc + '.ac'
        unitsname = UnitsFolder + subdoc + '.aa'
        discoursename = DiscourseFolder + subdoc + '.aa'
        textfile = open(textname, 'r')
        unitsfile = open(unitsname, 'r')
        discoursefile = open(discoursename, 'r')

        text = textfile.read()
        stringtree_units = unitsfile.read()
        units_tree = ET.fromstring(stringtree_units)
        stringtree_discourse = discoursefile.read()
        discourse_tree = ET.fromstring(stringtree_discourse)

        units_root = add_units_annotations(units_tree, text)
        discourse_root, events, errors = add_discourse_annotations(discourse_tree, text, e, subdoc)

        Implicit_Relations.extend(errors)

        with codecs.open(unitsname, 'w', 'ascii') as out:
            out.write(prettify(units_root))
        with codecs.open(discoursename, 'w', 'ascii') as out:
            out.write(prettify(discourse_root))

        textfile.close()
        unitsfile.close()
        discoursefile.close()

    if Implicit_Relations != []:
        error_report = '\n'.join(Implicit_Relations)
        filename = Folder + 'Implicit_Relations.txt'
        with codecs.open(filename, 'w', 'ascii') as out:
            out.write(error_report)