Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions python/TransformerTagging/plugin-files/descriptor/descriptor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"componentName": "TransformerTagging",
"componentVersion": "7.2",
"middlewareVersion": "7.2",
"sourceLanguage": "python",
"batchLibrary": "ArgosTranslation",
"environmentVariables": [],
"algorithm": {
"name": "TRANSFORMERTAGGING",
"description": "Uses SentenceTransformers to tag sentences.",
"actionType": "DETECTION",
"requiresCollection": {
"states": []
},
"providesCollection": {
"states": [
"DETECTION",
"DETECTION_TAGGING",
"DETECTION_TAGGING_TRANSFORMER"
],
"properties": [
{
"name": "FEED_FORWARD_PROP_TO_PROCESS",
"description": "Comma-separated list of property names indicating which properties in the feed-forward track or detection to consider translating. If the first property listed is present, then that property will be translated. If it's not, then the next property in the list is considered. At most, one property will be translated.",
"type": "STRING",
"defaultValue": "TEXT,TRANSCRIPT,TRANSLATION"
},
{
"name": "SCORE_THRESHOLD",
"description": "The minimum score score which must be met or exceeded. Tags below this threshold are silently discarded.",
"type": "DOUBLE",
"defaultValue": "0.3"
},
{
"name": "TRANSFORMER_TAGGING_CORPUS",
"description": "Name of a JSON file that describes a tag hierarchy to be used for matching sentences. Will default to the plugin's config folder unless an alternate path to corpus file is specified (i.e. `$MPF_HOME/.../transformer_text_tags_corpus.json`).",
"type": "STRING",
"defaultValue": "transformer_text_tags_corpus.json"
},
{
"name": "ENABLE_DEBUG",
"description": "If true, each detection will include a `TEXT [TAG] TRIGGER SENTENCES MATCHES` property for each entry in `TAGS`. The value will be the sentence in the corpus which generated the highest match score for that tag.",
"type": "BOOLEAN",
"defaultValue": "FALSE"
}
]
}
},
"actions": [
{
"name": "ARGOS TRANSLATION (WITH FF REGION) ACTION",
"description": "Uses Argos Translation to perform translation on feed-forward tracks and detections.",
"algorithm": "ARGOSTRANSLATION",
"properties": [
{
"name": "FEED_FORWARD_TYPE",
"value": "REGION"
},
{
"name": "OUTPUT_MERGE_WITH_PREVIOUS_TASK",
"value": "TRUE"
}
]
},
{
"name": "ARGOS TRANSLATION TEXT FILE ACTION",
"description": "Uses Argos Translation to perform translation on a plain text file.",
"algorithm": "ARGOSTRANSLATION",
"properties": [
]
}
],
"tasks": [
{
"name": "ARGOS TRANSLATION (WITH FF REGION) TASK",
"description": "Uses Argos Translate to perform translation on feed-forward tracks and detections.",
"actions": [
"ARGOS TRANSLATION (WITH FF REGION) ACTION"
]
},
{
"name": "ARGOS TRANSLATION TEXT FILE TASK",
"description": "Uses Argos Translate to perform translation on a plain text file.",
"actions": [
"ARGOS TRANSLATION TEXT FILE ACTION"
]
}
],
"pipelines": [
{
"name": "ARGOS TRANSLATION TEXT FILE PIPELINE",
"description": "Uses Argos Translate to perform translation on a plain text file.",
"tasks": [
"ARGOS TRANSLATION TEXT FILE TASK"
]
}
]
}
29 changes: 29 additions & 0 deletions python/TransformerTagging/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#############################################################################
# NOTICE #
# #
# This software (or technical data) was produced for the U.S. Government #
# under contract, and is subject to the Rights in Data-General Clause #
# 52.227-14, Alt. IV (DEC 2007). #
# #
# Copyright 2023 The MITRE Corporation. All Rights Reserved. #
#############################################################################

#############################################################################
# Copyright 2023 The MITRE Corporation #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#############################################################################

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
45 changes: 45 additions & 0 deletions python/TransformerTagging/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#############################################################################
# NOTICE #
# #
# This software (or technical data) was produced for the U.S. Government #
# under contract, and is subject to the Rights in Data-General Clause #
# 52.227-14, Alt. IV (DEC 2007). #
# #
# Copyright 2023 The MITRE Corporation. All Rights Reserved. #
#############################################################################

#############################################################################
# Copyright 2023 The MITRE Corporation #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#############################################################################

[metadata]
name = TransformerTagging
version = 7.2

[options]
packages = transformer_tagging_component
install_requires =
mpf_component_api>=7.2
mpf_component_util>=7.2
nltk
sentence_transformers
pandas

[options.entry_points]
mpf.exported_component =
component = transformer_tagging_component.transformer_tagging_component:TransformerTaggingComponent

[options.package_data]
transformer_tagging_component=transformer_text_tags_corpus.json
10 changes: 10 additions & 0 deletions python/TransformerTagging/tests/config/custom_corpus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"text": "This sentence is beach.",
"tag": "beach"
},
{
"text": "This sentence is forest.",
"tag": "forest"
}
]
3 changes: 3 additions & 0 deletions python/TransformerTagging/tests/data/simple_input.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
I drove to the beach today and will be staying overnight at a hotel. I texted my friend before I left so she could look
after my cats. She will drop by to check on them after stopping by the bank. I plan to spend all day at the beach
tomorrow.
Loading