Skip to content

Commit

Permalink
Merge pull request #15 from desh2608/v1.2
Browse files Browse the repository at this point in the history
More changes for v1.2
  • Loading branch information
desh2608 authored Apr 16, 2023
2 parents 32a9e94 + 4f04113 commit 00c77b7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 25 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ Options:
of the maximal matching for greedy label
mapping [default: False]

--sort-first If this flag is set, sort inputs by DER
first before label mapping (only applicable
when label mapping type is hungarian)
[default: False]

--label-mapping [hungarian|greedy]
Choose label mapping algorithm to use
[default: greedy]
Expand Down Expand Up @@ -93,7 +88,8 @@ _* The Greedy label mapping is exponential in number of inputs (see [this paper]

The algorithm is implemented in pure Python with NumPy for tensor computations.
The time complexity is expected to increase exponentially with the number of
inputs, but it should be reasonable for combining up to 10 input hypotheses.
inputs, but it should be reasonable for combining up to 10 input hypotheses. For
combining more than 10 inputs, we recommend setting `--label-mapping hungarian`.

For smaller number of inputs (up to 5), the algorithm should take only a few seconds
to run on a laptop.
Expand All @@ -104,8 +100,8 @@ DOVER-Lap is meant to be used to combine **more than 2 systems**, since
black-box voting between 2 systems does not make much sense. Still, if 2 systems
are provided as input, we fall back on the Hungarian algorithm for label mapping,
since it is provably optimal for this case. Both the systems are assigned equal
weights, and in case of voting conflicts, the region is equally divided among the
two labels. This is not the intended use case and will almost certainly lead
weights, and in case of voting conflicts, the region is assigned to both
labels. This is not the intended use case and will almost certainly lead
to performance degradation.

## Citation
Expand Down
8 changes: 0 additions & 8 deletions dover_lap/dover_lap.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ def load_rttms(rttm_list: List[str]) -> List[List[Turn]]:
show_default=True,
help="Choose label mapping algorithm to use",
)
@click.option(
"--sort-first",
is_flag=True,
default=False,
show_default=True,
help="If this flag is set, sort inputs by DER first before label mapping "
"(only applicable when label mapping type is hungarian)",
)
@click.option(
"--second-maximal",
is_flag=True,
Expand Down
2 changes: 0 additions & 2 deletions dover_lap/src/doverlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def combine_turns_list(
turns_list: List[List[Turn]],
file_id: str,
label_mapping: Optional[str] = "greedy",
sort_first: Optional[bool] = False,
second_maximal: Optional[bool] = False,
voting_method: Optional[str] = "average",
weight_type: Optional[str] = "rank",
Expand All @@ -28,7 +27,6 @@ def combine_turns_list(
file_id,
method=label_mapping,
second_maximal=second_maximal,
sort_first=sort_first,
)

# Compute weights based on rank
Expand Down
3 changes: 1 addition & 2 deletions dover_lap/src/label_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def get_mapped_turns_list(
turns_list: List[List[Turn]],
file_id: str,
method: Optional[str] = "greedy",
sort_first: Optional[bool] = False,
second_maximal: Optional[bool] = False,
) -> List[List[Turn]]:
"""
Expand All @@ -23,7 +22,7 @@ def get_mapped_turns_list(

if (len(turns_list) == 2) or (method == "hungarian"):
# We replace the original turns list with one sorted by average DER
hungarian_map = HungarianMap(sort_first=sort_first)
hungarian_map = HungarianMap()
label_mapping, weights = hungarian_map.compute_mapping(turns_list)
turns_list = hungarian_map.sorted_turns_list

Expand Down
10 changes: 5 additions & 5 deletions dover_lap/src/mapping/hungarian.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


class HungarianMap:
def __init__(self, sort_first: Optional[bool] = True) -> None:
self.sort_first = sort_first
def __init__(self) -> None:
pass

def compute_mapping(
self,
Expand All @@ -24,9 +24,9 @@ def compute_mapping(

weights = self._compute_weights()
self.sorted_turns_list = self.turns_list
if self.sort_first:
sorted_idx = weights.argsort().tolist()
self.sorted_turns_list = [self.turns_list[i] for i in sorted_idx]
# Sort the hypotheses by their weights
sorted_idx = weights.argsort().tolist()
self.sorted_turns_list = [self.turns_list[i] for i in sorted_idx]

cur_turns = self.sorted_turns_list[0]
self.global_mapping = dict()
Expand Down

0 comments on commit 00c77b7

Please sign in to comment.