Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow library to be imported and used as a module #37

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yeoji
Copy link

@yeoji yeoji commented Sep 1, 2020

Hello, thanks for this awesome library!

Not too sure if this PR would be of any value, so let me know if I should close it.

Purpose

This PR will allow the library to be used as a module in another application.

It exposes the results from the evaluation and returns it as a dict so it is accessible instead of just printing it out.

To do this, the changes in the PR also removed the use of global variables that keeps track of the counters/word confusions.

Example Usage

from asr_evaluation.asr_evaluation import evaluate as asr_evaluation

class AsrEvaluationArgs(dict):
    def __getattr__(self, name):
        return self[name]

ref = open('./ref.txt', 'r')
hyp = open('./hyp.txt', 'r')

results = asr_evaluation(AsrEvaluationArgs({
         'ref': ref,
         'hyp': hyp,
         'print_instances': True,
         'print_errors': False,
         'head_ids': False,
         'tail_ids': False,
         'confusions': True,
         'min_word_count': 1,
         'print_wer_vs_length': False,
         'case_insensitive': True,
         'remove_empty_refs': False
}))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant