Skip to content

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

Open
yeoji wants to merge 3 commits into
belambert:mainfrom
yeoji:importable-module
Open

Allow library to be imported and used as a module#37
yeoji wants to merge 3 commits into
belambert:mainfrom
yeoji:importable-module

Conversation

@yeoji
Copy link
Copy Markdown

@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