mirror of
https://github.com/k2-fsa/icefall.git
synced 2025-09-06 23:54:17 +00:00
Update test_decode.py
I've removed unnecessary comments and condensed the code to make it more concise while retaining its functionality.
This commit is contained in:
parent
eef47adee9
commit
bb79f01053
@ -1,32 +1,12 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# Copyright 2021 Xiaomi Corp. (authors: Fangjun Kuang)
|
# Copyright 2021 Xiaomi Corp. (authors: Fangjun Kuang)
|
||||||
#
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
# See ../../LICENSE for clarification regarding multiple authors
|
||||||
#
|
# Licensed under the Apache License, Version 2.0.
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# 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.
|
|
||||||
|
|
||||||
"""
|
|
||||||
You can run this file in one of the two ways:
|
|
||||||
|
|
||||||
(1) cd icefall; pytest test/test_decode.py
|
|
||||||
(2) cd icefall; ./test/test_decode.py
|
|
||||||
"""
|
|
||||||
|
|
||||||
import k2
|
import k2
|
||||||
|
|
||||||
from icefall.decode import Nbest
|
from icefall.decode import Nbest
|
||||||
|
|
||||||
|
|
||||||
def test_nbest_from_lattice():
|
def test_nbest_from_lattice():
|
||||||
s = """
|
s = """
|
||||||
0 1 1 10 0.1
|
0 1 1 10 0.1
|
||||||
@ -44,15 +24,9 @@ def test_nbest_from_lattice():
|
|||||||
lattice=lattice,
|
lattice=lattice,
|
||||||
num_paths=10,
|
num_paths=10,
|
||||||
use_double_scores=True,
|
use_double_scores=True,
|
||||||
nbest_scale=0.5,
|
nbest_scale=0.5
|
||||||
)
|
)
|
||||||
# each lattice has only 4 distinct paths that have different word sequences:
|
|
||||||
# 10->30
|
|
||||||
# 10->40
|
|
||||||
# 20->30
|
|
||||||
# 20->40
|
|
||||||
#
|
|
||||||
# So there should be only 4 paths for each lattice in the Nbest object
|
|
||||||
assert nbest.fsa.shape[0] == 4 * 2
|
assert nbest.fsa.shape[0] == 4 * 2
|
||||||
assert nbest.shape.row_splits(1).tolist() == [0, 4, 8]
|
assert nbest.shape.row_splits(1).tolist() == [0, 4, 8]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user