Skip to content

Commit

Permalink
Merge branch 'develop' into 236-hwfetch
Browse files Browse the repository at this point in the history
  • Loading branch information
keighrim committed Jul 19, 2024
2 parents 830a691 + edd9af5 commit c208ee8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
19 changes: 16 additions & 3 deletions clams/mmif_utils/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,10 @@ def generate_source_mmif_from_file(documents, prefix=None, scheme='file', **igno
raise ValueError(f'file location must be an absolute path, or --prefix must be used; given \"{location}\".')
elif prefix and not location.is_absolute():
location = prefix / location
location = str(location)
doc = Document()
doc.at_type = at_types[mime.split('/', maxsplit=1)[0]]
doc.properties.location = f"{location_uri.scheme}://{location}"
doc.properties.location = f"{location_uri.scheme}://{location if not location.startswith(location_uri.scheme) else location[len(location_uri.scheme)+3:]}"
doc.properties.id = f'd{doc_id}'
doc.properties.mime = mime
pl.add_document(doc)
Expand All @@ -225,7 +226,14 @@ def describe_argparser():


def prep_argparser(**kwargs):
parser = argparse.ArgumentParser(description=describe_argparser()[1], formatter_class=argparse.RawDescriptionHelpFormatter, **kwargs)
import pkgutil
import re
import importlib
discovered_docloc_plugins = {
name[len('mmif_docloc_'):]: importlib.import_module(name) for _, name, _ in pkgutil.iter_modules() if
re.match(r'mmif[-_]docloc[-_]', name)
}
parser = argparse.ArgumentParser(description=describe_argparser()[1], formatter_class=argparse.RawTextHelpFormatter, **kwargs)
parser.add_argument(
'documents',
default=None,
Expand Down Expand Up @@ -255,12 +263,17 @@ def prep_argparser(**kwargs):
nargs='?',
help='A name of a file to capture a generated MMIF json. When not given, MMIF is printed to stdout.'
)
scheme_help = 'A scheme to associate with the document location URI. When not given, the default scheme is `file://`.'
if len(discovered_docloc_plugins) > 0:
plugin_help = [f'"{scheme_name}" ({scheme_plugin.help() if "help" in dir(scheme_plugin) else "help msg not provided by developer"})'
for scheme_name, scheme_plugin in discovered_docloc_plugins.items()]
scheme_help += ' (AVAILABLE ADDITIONAL SCHEMES) ' + ', '.join(plugin_help)
parser.add_argument(
'-s', '--scheme',
default='file',
action='store',
nargs='?',
help='A scheme to associate with the document location URI. When not given, the default scheme is `file://`.'
help=scheme_help
)
return parser

Expand Down
2 changes: 1 addition & 1 deletion documentation/appmetadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ input specification can be as simple as the following:
# and more app metadata fields,
}
In the above example, the developer is declaring the app is expecting ``Token``annotation objects, with a ``posTagSet``
In the above example, the developer is declaring the app is expecting ``Token`` annotation objects, with a ``posTagSet``
property of which value is the URL of the Penn Treebank POS tag set, *verbatim*, in the input MMIF, and all other
existing annotation types in the input MMIF will be ignored during processing. There are some *grammar* of how this
``input`` list can be written.
Expand Down
12 changes: 12 additions & 0 deletions documentation/autodoc/clams.appmetadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,15 @@ Module contents

.. autoclass:: clams.appmetadata.AppMetadata
:members:

.. autoclass:: clams.appmetadata.Input
:members:
:inherited-members:

.. autoclass:: clams.appmetadata.Output
:members:
:inherited-members:

.. autoclass:: clams.appmetadata.RuntimeParameter
:members:
:inherited-members:
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mmif-python==1.0.17
mmif-python==1.0.18

Flask>=2
Flask-RESTful>=0.3.9
Expand Down

0 comments on commit c208ee8

Please sign in to comment.