code for STACL(Simultaneous Translation with Intergrated Aniticipation and Controllable Latency) paper
details in Sec.4 of STACL paper
python metricAL.py
# output:
# corpus mean: 5.96639835314598
# weighted average: 5.486924076400874RW2AL(s, add_eos=False)
- get
ALvalue from a single RW sequence sis RW sequence, a string, in format of0 0 0 1 1 0 1 0 1, orR R R W W R W R W, flexible on blank/commaadd_eosis used to add eos token for both src and tgt if you did not do it during RW generating (to add tail0and1into the RW sequence)- output is a single value as
AL
RW2AL_file(file_rw, is_weight_ave=False)
- get
ALvalue from a file with RW sequences file_rwis the path to a RW sequence fileis_weight_aveis used to return weighted average result against READ length or mean result on corpus- output is a single value as
AL