Skip to content

Commit

Permalink
auto-tagging script added, signature updated, --version added
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammad2928 committed Mar 8, 2021
1 parent c5bea2c commit d795c96
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 19 deletions.
26 changes: 24 additions & 2 deletions SLTev/SLTev.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def main():
parser.add_argument("-T", "--elitr-testset", metavar="DIR", help="use DIR as git clone of elitr-testset instead of elitr-testset", default= "elitr-testset", type=str)
parser.add_argument("-e", metavar="EVALDIR", help="evaluate evaluation directory EVALDIR", type=str)
parser.add_argument("--commitid", help="use elitr-testset at commit COMMITID", default= "HEAD", type=str)
parser.add_argument("--version", help="report the SLTev version", action='store_true', default='False')
args = parser.parse_args()

#-----------add SLTev home to the path
Expand All @@ -33,6 +34,21 @@ def main():
except:
sltev_home = os.path.dirname(os.path.realpath(sys.argv[0]))
sys.path.insert(1, sltev_home)

#print SLTev version
if args.version != "False":
try:
__version__ = pkg_resources.get_distribution("SLTev").version
eprint(__version__)
except:
try:
repo = git.Repo(os.path.split(sltev_home)[0])
commit_id = repo.head.commit
eprint("The commit id is: ", commit_id)
except:
eprint("SLTev is not installed, you can use the following command for installation:\n pip install SLTev")
sys.exit(1)

#sacremoses checking
try:
tokenize = MosesTokenizer().tokenize
Expand All @@ -48,7 +64,10 @@ def main():
sha = repo.head.object.hexsha
SLTev_commit_id = 'SLTev_' + repo.git.rev_parse(sha, short=True) + '-'
except:
SLTev_commit_id = ''
try:
SLTev_commit_id = 'SLTev_version_' + pkg_resources.get_distribution("SLTev").version + '-'
except:
SLTev_commit_id = 'SLTev_NONE' + '-'
#-----------check output directory
if args.e is None and args.g is None:
parser.print_help()
Expand Down Expand Up @@ -137,7 +156,9 @@ def main():
elitr_commit_id = 'elitrtestset_' + repo.git.rev_parse(sha, short=True)
signature = signature + elitr_commit_id
except:
pass
signature = signature + 'elitrtestset_NONE'
else:
signature = signature + 'elitrtestset_NONE'

"""
Naming template:
Expand Down Expand Up @@ -239,3 +260,4 @@ def main():

if __name__ == "__main__":
main()

2 changes: 2 additions & 0 deletions SLTev/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
sltev_home = pkg_resources.resource_filename('SLTev', '')
sys.path.insert(1, sltev_home)

__version__ = "1.1.6"

1 change: 1 addition & 0 deletions SLTev/delay_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,4 @@ def evaluate_segmenter(Ts, MT, MovedWords, language, SLTev_home, temp_folder):
sum_missing_words += temp_list[0][1]
sum_delay += temp_list[0][0]
return sum_delay, sum_missing_words, mWERQuality

24 changes: 12 additions & 12 deletions SLTev/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def evaluator(ostt=None, asr=False, tt=[], align=[], mt=None, b_time=3000, SLTev

#----------------------------------------
if simple == 'False':
eprint("P ... considering Partial segments in delay and quality calculation (in addition to Complete segments)")
eprint("P ... considering Partial segments in delay and quality calculation(in addition to Complete segments)")
eprint("T ... considering source Timestamps supplied with MT output")
eprint("W ... segmenting by mWER segmenter (i.e. not segmenting by MT source timestamps)")
eprint("A ... considering word alignment (by GIZA) to relax word delay (i.e. relaxing more than just linear delay calculation)")
Expand Down Expand Up @@ -142,17 +142,7 @@ def evaluator(ostt=None, asr=False, tt=[], align=[], mt=None, b_time=3000, SLTev
print("tot MissedTokens PWA ", missing_words)
except:
os.chdir(current_path)
shutil.rmtree(temp_folder, ignore_errors=True)

if simple == 'False' and time_stamp == "True":
print("tot Flicker count_changed_Tokens ", int(calc_revise(MT)))

if time_stamp == "True":
print("tot Flicker count_changed_content ", int(calc_flicker(MT)))

if simple == 'False' and time_stamp == "True":
print("macroavg Flicker count_changed_content ", str("{0:.3f}".format(round(calc_average_flickers_per_sentence(MT), 3))) )
print("microavg Flicker count_changed_content ", str("{0:.3f}".format(round(calc_average_flickers_per_document(MT), 3))))
shutil.rmtree(temp_folder, ignore_errors=True)


sacre_score = calc_bleu_score_document(references, MT)
Expand All @@ -177,6 +167,16 @@ def evaluator(ostt=None, asr=False, tt=[], align=[], mt=None, b_time=3000, SLTev
pass


if simple == 'False' and time_stamp == "True":
print("tot Flicker count_changed_Tokens ", int(calc_revise(MT)))

if time_stamp == "True":
print("tot Flicker count_changed_content ", int(calc_flicker(MT)))

if simple == 'False' and time_stamp == "True":
print("mean flicker across sentences ", str("{0:.3f}".format(round(calc_average_flickers_per_sentence(MT), 3))) )

print("mean flicker across whole documents ", str("{0:.3f}".format(round(calc_average_flickers_per_document(MT), 3))))



1 change: 1 addition & 0 deletions SLTev/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,4 @@ def submissionArgument():
parser.add_argument("--simple", help="report a simplified set of scores", action='store_true', default='False')
args = parser.parse_args()
return args

9 changes: 9 additions & 0 deletions auto-tagging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# tagging into the SLTev repo (https://github.com/ELITR/SLTev.git)

import git
from SLTev import __version__

repo = git.Repo(".")
new_tag = repo.create_tag(__version__, message='Tagging version "{0}"'.format(__version__))

repo.remotes.origin.push(new_tag)
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from setuptools import setup, find_packages
from SLTev import __version__
import sys

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

if sys.version_info[:2] >= (3,7):
numpy_version = "numpy"
else:
Expand All @@ -12,11 +10,10 @@

setup(
name='SLTev',
version='1.1.5',
version=__version__,
author="Mohammad Mahmoudi",
author_email="zaribar2928@gmail.com",
description="a tool for evaluation",
long_description=long_description,
packages=['SLTev',],
data_files = [ ('SLTev', ['SLTev/mwerSegmenter']) ],
include_package_data=True,
Expand All @@ -39,3 +36,5 @@

)



0 comments on commit d795c96

Please sign in to comment.