#
# Toplevel
#

from MAT.Operation import OptionParser, OptionGroup

parser = OptionParser(usage = """Usage: %prog [options] mat_1_3_root task_xml [outdir]

mat_1_3_root: a 1.3 final MAT root directory, typically src/MAT in the 1.3 distribution
task_xml: the task.xml file to update. The original file will be written to task.xml.1_3, and the new
  file, no matter what this name is, is task.xml. This way, you can repeatedly update the
  1.3 task.xml file if you need to
outdir: the directory to save the task.xml files to. Optional. By default, this will be the same
  directory you started with.""")

parser.add_option("--print_to_stdout", action = "store_true",
                  help = "if present, print to stdout instead of task.xml, and don't copy the original")
parser.add_option("--cheat_on_1_3_requirement", action = "store_true",
                  help = "don't require that the mat_1_3_root actually be 1.3, but permit early versions of 2.0")
options, args = parser.parse_args()

if len(args) not in (2, 3):
    parser.print_help()
    sys.exit(1)

[MAT_1_3_ROOT, TASK_XML] = args[:2]
MAT_1_3_ROOT = os.path.realpath(os.path.abspath(MAT_1_3_ROOT))
PRINT_TO_STDOUT = options.print_to_stdout

TASK_XML = os.path.realpath(os.path.abspath(TASK_XML))
if len(args) == 3:
    OUTDIR = args[2]
from MAT.Operation import OptionParser, OptionGroup

import MAT.PluginMgr

PLUGIN_DIR = MAT.PluginMgr.LoadPlugins()

parser = OptionParser(usage="""Usage: %prog [options] task outfile

task: the name of a MAT task. Known tasks are: """ +
                      ", ".join(PLUGIN_DIR.keys()) + """
outfile: the output file to write the JSON version of the annotation info to. If the file
  is '-', the JSON will be written to standard output.""")

parser.add_option(
    "--dont_remove_redundant_info",
    action="store_true",
    help=
    "By default, the tool removes redundant information to improve readability. If this flag is present, the redundant information will be retained. Both the Java library and the Javascript standalone viewer are configured to repopulate redundant information."
)
parser.add_option(
    "--compact",
    action="store_true",
    help=
    "By default, the tool pretty-prints its JSON output. If this flag is present, the JSON will not be pretty-printed."
)
parser.add_option(
    "--keep_noncontent_annotations",
    action="store_true",
    help=
    "By default, the tool does not preserve token, zone or admin annotation type descriptors. If this flag is present, all annotation types will be presented."
)
parser.add_option(
parser = OptionParser(usage = """Usage: %prog [options] task_name output_doc pivot_doc otherdoc...

task_name: the name of a known task. Known tasks are: """ + ", ".join(PLUGIN_DIR.keys()) + """
output_doc: the file to save the comparison document to.
pivot_doc: the document to which each of the other documents will be compared.
otherdoc...: a sequence of other documents, which all share the same signal with the pivot_doc.""")

# Progressive enhancement.
from MAT.Operation import CmdlineOpArgumentAggregator
AGGREGATOR = CmdlineOpArgumentAggregator(parser)

parser.add_activation_option("--file_type", AGGREGATOR, MAT.DocumentIO.DocumentIO, subtype = "inputArgs",
                             classFilters = ["excluderaw"],
                             default = "mat-json", help = "The file type of the input documents. Default is mat-json.")
parser.add_option("--similarity_profile", dest="similarity_profile",
                 metavar = "profile",
                 help = "If provided, the name of a similarity profile in the specified task.")
options, args = parser.parse_args()

def Usage():
    global parser
    parser.print_help()
    sys.exit(1)

if len(args) < 4:
    Usage()

values = AGGREGATOR.convertToKW(options)

[TASKNAME, OUTPUT_DOC, PIVOT_DOCNAME] = args[0:3]
OTHERS = args[3:]
Esempio n. 4
0
def _allOperations(cls, lst):
    if (cls.name is not None) and cls.availability & CMDLINE_AVAILABLE_MASK:
        lst.append(cls.name)
    for c in cls.__subclasses__():
        _allOperations(c, lst)
ALL_OPERATIONS = []
_allOperations(WorkspaceGeneralOperation, ALL_OPERATIONS)

parser = OptionParser(usage = """Usage: %prog [options] <dir> create ...
""" + "\n".join(["       %prog [options] <dir> " + op + " ..." for op in ALL_OPERATIONS]) + \
"""

Provide the directory and operation followed by --help for more detailed help.""")
parser.add_option("--other_app_dir", action = "append",
                  dest="other_dirs",
                  help="additional directory to load a task from. Optional.")
MAT.ExecutionContext.addOptions(parser)

parser.disable_interspersed_args()

coreOptions, args = parser.parse_args()

if len(args) < 1:
    parser.print_help()
    sys.exit(1)

# At this point, we can load the plugins.

otherDirs = coreOptions.other_dirs or []
Esempio n. 5
0
MAT_PKG_PYLIB = "MF_MAT_PKG_PYLIB"
sys.path.insert(0, MAT_PKG_PYLIB)

#
# Toplevel
#

from MAT.Operation import OptionParser
import MAT.ExecutionContext

parser = OptionParser(usage = """Usage: %prog [options] <xml_file>

<xml_file>: An experiment XML file""")
parser.add_option("--force", action = "store_true",
                  dest = "force",
                  help = "redo all analysis")
parser.add_option("--batch_test_runs", action = "store_true",
                  dest = "batch_test_runs",
                  help = "don't interleave test runs with model builds")
parser.add_option("--mark_done", action = "store_true",
                  dest = "mark_done",
                  help = "forcibly mark the experiment as done")
parser.add_option("--exp_dir", dest = "exp_dir",
                  metavar = "dir",
                  help = "optionally, the directory to use for the record of the experiment. This directory path is used when no 'dir' attribute is provided to the <experiment> element in the experiment XML file.")
parser.add_option("--pattern_dir", dest = "pattern_dir",
                  metavar = "dir",
                  help = "optionally, this path is the prefix used for relative directory paths in file patterns in the <pattern> element in the corpora in the experiment XML file. Otherwise, these patterns must be absolute pathnames.")
parser.add_option("--binding", dest = "bindings",
                  action = "append",