clams-python 0.0.1__tar.gz → 0.0.1a1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. {clams-python-0.0.1 → usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages}/clams/__init__.py +2 -2
  2. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/clams/__pycache__/__init__.cpython-36.pyc +0 -0
  3. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/clams/restify/__pycache__/__init__.cpython-36.pyc +0 -0
  4. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/clams/serialize/__init__.py +173 -0
  5. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/clams/serialize/__pycache__/__init__.cpython-36.pyc +0 -0
  6. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/clams/serve/__pycache__/__init__.cpython-36.pyc +0 -0
  7. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/clams/vocab/__init__.py +24 -0
  8. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/clams/vocab/__pycache__/__init__.cpython-36.pyc +0 -0
  9. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/clams_python-0.0.1a1-py3.6.egg-info/PKG-INFO +32 -0
  10. {clams-python-0.0.1/clams_python.egg-info → usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/clams_python-0.0.1a1-py3.6.egg-info}/SOURCES.txt +5 -2
  11. {clams-python-0.0.1/clams_python.egg-info → usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/clams_python-0.0.1a1-py3.6.egg-info}/top_level.txt +1 -1
  12. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/tests/__pycache__/__init__.cpython-36.pyc +0 -0
  13. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/tests/__pycache__/test_clamsapp.cpython-36.pyc +0 -0
  14. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/tests/__pycache__/test_serialization.cpython-36.pyc +0 -0
  15. usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/tests/test_serialization.py +30 -0
  16. clams-python-0.0.1/PKG-INFO +0 -36
  17. clams-python-0.0.1/README.md +0 -18
  18. clams-python-0.0.1/clams_python.egg-info/PKG-INFO +0 -36
  19. clams-python-0.0.1/setup.cfg +0 -4
  20. clams-python-0.0.1/setup.py +0 -25
  21. {clams-python-0.0.1 → usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages}/clams/restify/__init__.py +0 -0
  22. {clams-python-0.0.1 → usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages}/clams/serve/__init__.py +0 -0
  23. {clams-python-0.0.1/clams_python.egg-info → usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/clams_python-0.0.1a1-py3.6.egg-info}/dependency_links.txt +0 -0
  24. {clams-python-0.0.1/test → usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/tests}/__init__.py +0 -0
  25. {clams-python-0.0.1/test → usr/local/anaconda3/envs/clamssdk/lib/python3.6/site-packages/tests}/test_clamsapp.py +0 -0
@@ -1,7 +1,7 @@
1
+ from clams.serialize import *
1
2
  from clams.serve import *
2
3
  from clams.restify import Restifier
3
- from mmif.serialize import *
4
- from mmif.vocab import *
4
+ from clams.vocab import *
5
5
 
6
6
 
7
7
 
@@ -0,0 +1,173 @@
1
+ import datetime
2
+ import json
3
+
4
+
5
+ class MmifObject(object):
6
+ def __init__(self, mmif_json=None):
7
+ if mmif_json is not None:
8
+ self.deserialize(mmif_json)
9
+
10
+ def serialize(self):
11
+ return self.__dict__
12
+
13
+ def deserialize(self, mmif):
14
+ raise NotImplementedError()
15
+
16
+ def __str__(self):
17
+ return json.dumps(self.serialize(), cls=MmifObjectEncoder)
18
+
19
+ def pretty(self):
20
+ return json.dumps(self, indent=2, cls=MmifObjectEncoder)
21
+
22
+
23
+ class MmifObjectEncoder(json.JSONEncoder):
24
+ def default(self, obj):
25
+ if hasattr(obj, 'serialize'):
26
+ return obj.serialize()
27
+ elif hasattr(obj, '__str__'):
28
+ return str(obj)
29
+ else:
30
+ return json.JSONEncoder.default(self, obj)
31
+
32
+
33
+ class Mmif(MmifObject):
34
+ context: str
35
+ metadata: dict
36
+ media: list
37
+ contains: dict
38
+ views: list
39
+
40
+ def __init__(self, mmif_json=None):
41
+ self.context = ''
42
+ self.metadata = {}
43
+ self.media = []
44
+ self.contains = {}
45
+ self.views = []
46
+ super().__init__(mmif_json)
47
+
48
+ def serialize(self):
49
+ d = self.__dict__.copy()
50
+ d['@context'] = d.pop('context')
51
+ return d
52
+
53
+ def deserialize(self, mmif):
54
+ in_json = json.loads(mmif)
55
+
56
+ # TODO (krim @ 10/3/2018): more robust json parsing
57
+ self.context = in_json["@context"]
58
+ self.contains = in_json["contains"]
59
+ self.metadata = in_json["metadata"]
60
+ self.media = in_json["media"]
61
+ self.views = in_json["views"]
62
+
63
+ def new_view_id(self):
64
+ return 'v_' + str(len(self.views))
65
+
66
+ def new_view(self):
67
+ new_view = View(self.new_view_id())
68
+ self.views.append(new_view)
69
+ return new_view
70
+
71
+ def add_media(self, medium):
72
+ try:
73
+ self.get_medium_location(medium)
74
+ # TODO (krim @ 10/7/2018): if get_m_location returns, raise "already exists" error
75
+ except Exception:
76
+ self.media.append(medium)
77
+
78
+ def get_medium_location(self, md_type):
79
+ for medium in self.media:
80
+ if medium["type"] == md_type:
81
+ return medium["location"]
82
+ raise Exception("{} type media not found".format(md_type))
83
+
84
+ def get_view_by_id(self, id):
85
+ for view in self.views:
86
+ if view['id'] == id:
87
+ return view
88
+ raise Exception("{} view not found".format(id))
89
+
90
+ def get_view_contains(self, attype):
91
+ return self.get_view_by_id(self.contains[attype])
92
+
93
+
94
+ class Medium(MmifObject):
95
+ id: str
96
+ type: str
97
+ location: str
98
+ metadata: dict
99
+
100
+ def __init__(self, id, md_type='', uri=''):
101
+ self.id = id
102
+ self.type = md_type
103
+ self.location = uri
104
+ self.metadata = {}
105
+
106
+ def deserialize(self, mmif):
107
+ pass
108
+
109
+ def add_metadata(self, name, value):
110
+ self.metadata[name] = value
111
+
112
+
113
+ class Annotation(MmifObject):
114
+ start: int
115
+ end: int
116
+ feature: dict
117
+ id: str
118
+ attype: str
119
+
120
+ def __init__(self, id, at_type=''):
121
+ # TODO (krim @ 10/4/2018): try deserialize "id", then if fails defaults to 0s
122
+ super().__init__()
123
+ self.start = 0
124
+ self.end = 0
125
+ self.feature = {}
126
+ self.id = id
127
+ self.attype = at_type
128
+
129
+ def deserialize(self, mmif):
130
+ pass
131
+
132
+ def add_feature(self, name, value):
133
+ self.feature[name] = value
134
+
135
+
136
+ class View(MmifObject):
137
+ id: str
138
+ contains: dict
139
+ annotation: list
140
+
141
+ def __init__(self, id="UNIDENTIFIED"):
142
+ super().__init__()
143
+ self.id = id
144
+ self.contains = {}
145
+ self.annotations = []
146
+
147
+ def deserialize(self, view):
148
+ pass
149
+
150
+ def new_contain(self, at_type, producer=""):
151
+ new_contain = Contain()
152
+ new_contain.gen_time = datetime.datetime.utcnow().isoformat()
153
+ self.contains[at_type] = new_contain
154
+ return new_contain
155
+
156
+ def new_annotation(self, aid):
157
+ new_annotation = Annotation(aid)
158
+ self.annotations.append(new_annotation)
159
+ return new_annotation
160
+
161
+
162
+ class Contain(MmifObject):
163
+ producer: str
164
+ gen_time: str
165
+
166
+ def __init__(self):
167
+ super().__init__()
168
+ self.producer = ''
169
+ self.gen_time = None # datetime.datetime
170
+
171
+ def deserialize(self, mmif):
172
+ pass
173
+
@@ -0,0 +1,24 @@
1
+ # TODO (krim @ 10/7/2018): reimplement with proper enum
2
+ class AnnotationTypes(object):
3
+ FA = "https://vocab.clams.ai/attype/forced-alignment"
4
+ # FFA = "filtered-forced-alignment"
5
+ BD = "https://vocab.clams.ai/attype/bar-detection"
6
+ SD = "https://vocab.clams.ai/attype/slate-detection"
7
+ TD = "https://vocab.clams.ai/attype/tone-detection"
8
+ ND = "https://vocab.clams.ai/attype/noise-detection"
9
+ OCR = "https://vocab.clams.ai/attype/raw-ocr-output"
10
+ TBOX = "https://vocab.clams.ai/attype/text-box"
11
+ FACE = "https://vocab.clams.ai/attype/face-box"
12
+ SHOT = "https://vocab.clams.ai/attype/shot-detection"
13
+ # TODO linguistic annotations to leverage on the LAPPS/LIF vocab
14
+ # Sentences = "segment-sentences"
15
+ # Paragraphs = "segment-paragraphs"
16
+ # Tokens = "segment-tokens"
17
+
18
+
19
+ class MediaTypes(object):
20
+ V = "https://vocab.clams.ai/mtype/audio-video"
21
+ A = "https://vocab.clams.ai/mtype/audio-only"
22
+ T = "https://vocab.clams.ai/mtype/text"
23
+ I = "https://vocab.clams.ai/mtype/image"
24
+
@@ -0,0 +1,32 @@
1
+ Metadata-Version: 2.1
2
+ Name: clams-python
3
+ Version: 0.0.1a1
4
+ Summary: A collection of APIs to develop CLAMS app for python
5
+ Home-page: https://www.clams.ai
6
+ Author: Brandeis Lab for Linguistics and Computation
7
+ Author-email: admin@clams.ai
8
+ License: UNKNOWN
9
+ Description: # CLAMS sdk for python
10
+
11
+ ## installation:
12
+ ```
13
+ python setup.py install
14
+ ```
15
+ This will install a packge `clams` to local python
16
+
17
+ ## APIs
18
+
19
+
20
+ `clams.ClamsApp` : an abstract class for clams tool s
21
+
22
+ `clams.Mmif` : serialization APIs
23
+
24
+ Platform: UNKNOWN
25
+ Classifier: Development Status :: 2 - Pre-Alpha
26
+ Classifier: Framework :: Flask
27
+ Classifier: Framework :: Pytest
28
+ Classifier: Intended Audience :: Developers
29
+ Classifier: License :: OSI Approved :: Apache Software License
30
+ Classifier: Programming Language :: Python :: 3 :: Only
31
+ Requires-Python: >=3.6
32
+ Description-Content-Type: text/markdown
@@ -2,10 +2,13 @@ README.md
2
2
  setup.py
3
3
  clams/__init__.py
4
4
  clams/restify/__init__.py
5
+ clams/serialize/__init__.py
5
6
  clams/serve/__init__.py
7
+ clams/vocab/__init__.py
6
8
  clams_python.egg-info/PKG-INFO
7
9
  clams_python.egg-info/SOURCES.txt
8
10
  clams_python.egg-info/dependency_links.txt
9
11
  clams_python.egg-info/top_level.txt
10
- test/__init__.py
11
- test/test_clamsapp.py
12
+ tests/__init__.py
13
+ tests/test_clamsapp.py
14
+ tests/test_serialization.py
@@ -0,0 +1,30 @@
1
+ import unittest
2
+
3
+ import clams.serialize
4
+ from clams import Mmif, Medium, MediaTypes
5
+
6
+
7
+ dummy_attype = "http://clams.ai/vocab/dummy"
8
+
9
+ class ExampleInputMMIF(object):
10
+
11
+ @staticmethod
12
+ def get_gold_mmif():
13
+ mmif = Mmif()
14
+ mmif.context = "mmif-prototype-0.0.1.jsonld"
15
+ mmif.metadata = {}
16
+ mmif.media = [Medium(0, MediaTypes.V, "/dummy/dir/dummy.file.mp4")]
17
+ mmif.contains = {}
18
+ mmif.views = []
19
+ return str(mmif)
20
+
21
+
22
+ class TestSerialization(unittest.TestCase):
23
+
24
+ def setUp(self):
25
+ self.mmif = Mmif(ExampleInputMMIF.get_gold_mmif())
26
+
27
+ def test_view_is_empty(self):
28
+ self.assertEqual(len(self.mmif.contains), 0)
29
+ self.assertEqual(len(self.mmif.views), 0)
30
+
@@ -1,36 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: clams-python
3
- Version: 0.0.1
4
- Summary: A collection of APIs to develop CLAMS app for python
5
- Home-page: https://www.clams.ai
6
- Author: Brandeis Lab for Linguistics and Computation
7
- Author-email: admin@clams.al
8
- License: UNKNOWN
9
- Description: # CLAMS sdk for python
10
-
11
- **NOTE** that this project is in pre-alpha and being actively developed. Nothing is guaranteed to reliably work for the moment and developer need to be very careful when using APIs implemented here. Please use [the issue track](../../issues) to report bugs and malfunctions, or send pull requests for even more contribution.
12
-
13
- ## CLAMS project
14
- [CLAMS project](https://www.clams.ai) aims at free and open-source software platform for computational analysis and metadata generation applications for multimedia material.
15
-
16
- ## installation:
17
- Package `clams-python` is distributed via the official pypi. Users are supposed to pip-install to get latest release.
18
- ```
19
- pip install clams-python
20
- ```
21
- This will install a packge `clams` to local python
22
-
23
- ## APIs
24
-
25
-
26
- `clams.ClamsApp` : an abstract class for clams apps
27
-
28
- Platform: UNKNOWN
29
- Classifier: Development Status :: 2 - Pre-Alpha
30
- Classifier: Framework :: Flask
31
- Classifier: Framework :: Pytest
32
- Classifier: Intended Audience :: Developers
33
- Classifier: License :: OSI Approved :: Apache Software License
34
- Classifier: Programming Language :: Python :: 3 :: Only
35
- Requires-Python: >=3.6
36
- Description-Content-Type: text/markdown
@@ -1,18 +0,0 @@
1
- # CLAMS sdk for python
2
-
3
- **NOTE** that this project is in pre-alpha and being actively developed. Nothing is guaranteed to reliably work for the moment and developer need to be very careful when using APIs implemented here. Please use [the issue track](../../issues) to report bugs and malfunctions, or send pull requests for even more contribution.
4
-
5
- ## CLAMS project
6
- [CLAMS project](https://www.clams.ai) aims at free and open-source software platform for computational analysis and metadata generation applications for multimedia material.
7
-
8
- ## installation:
9
- Package `clams-python` is distributed via the official pypi. Users are supposed to pip-install to get latest release.
10
- ```
11
- pip install clams-python
12
- ```
13
- This will install a packge `clams` to local python
14
-
15
- ## APIs
16
-
17
-
18
- `clams.ClamsApp` : an abstract class for clams apps
@@ -1,36 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: clams-python
3
- Version: 0.0.1
4
- Summary: A collection of APIs to develop CLAMS app for python
5
- Home-page: https://www.clams.ai
6
- Author: Brandeis Lab for Linguistics and Computation
7
- Author-email: admin@clams.al
8
- License: UNKNOWN
9
- Description: # CLAMS sdk for python
10
-
11
- **NOTE** that this project is in pre-alpha and being actively developed. Nothing is guaranteed to reliably work for the moment and developer need to be very careful when using APIs implemented here. Please use [the issue track](../../issues) to report bugs and malfunctions, or send pull requests for even more contribution.
12
-
13
- ## CLAMS project
14
- [CLAMS project](https://www.clams.ai) aims at free and open-source software platform for computational analysis and metadata generation applications for multimedia material.
15
-
16
- ## installation:
17
- Package `clams-python` is distributed via the official pypi. Users are supposed to pip-install to get latest release.
18
- ```
19
- pip install clams-python
20
- ```
21
- This will install a packge `clams` to local python
22
-
23
- ## APIs
24
-
25
-
26
- `clams.ClamsApp` : an abstract class for clams apps
27
-
28
- Platform: UNKNOWN
29
- Classifier: Development Status :: 2 - Pre-Alpha
30
- Classifier: Framework :: Flask
31
- Classifier: Framework :: Pytest
32
- Classifier: Intended Audience :: Developers
33
- Classifier: License :: OSI Approved :: Apache Software License
34
- Classifier: Programming Language :: Python :: 3 :: Only
35
- Requires-Python: >=3.6
36
- Description-Content-Type: text/markdown
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
@@ -1,25 +0,0 @@
1
- import setuptools
2
-
3
- with open('README.md') as readme:
4
- long_desc = readme.read()
5
-
6
- setuptools.setup(
7
- name="clams-python",
8
- version="0.0.1",
9
- author="Brandeis Lab for Linguistics and Computation",
10
- author_email="admin@clams.al",
11
- description="A collection of APIs to develop CLAMS app for python",
12
- long_description=long_desc,
13
- long_description_content_type="text/markdown",
14
- url="https://www.clams.ai",
15
- classifiers=[
16
- 'Development Status :: 2 - Pre-Alpha',
17
- 'Framework :: Flask',
18
- 'Framework :: Pytest',
19
- 'Intended Audience :: Developers ',
20
- 'License :: OSI Approved :: Apache Software License',
21
- 'Programming Language :: Python :: 3 :: Only',
22
- ],
23
- python_requires='>=3.6',
24
- packages=setuptools.find_packages()
25
- )