Path: blob/main/a4/__pycache__/utils.cpython-310.pyc
1003 views
o u�!d� � @ s~ d Z ddlZddlmZ ddlZddlZddlmZ ddl m m Z ddlZddl Zdd� Zddd�Zd d � Zddd �ZdS )z� CS224N 2022-23: Homework 4 utils.py: Utility Functions Pencheng Yin <[email protected]> Sahil Chopra <[email protected]> Vera Lin <[email protected]> Siyan Li <[email protected]> � N)�Listc s. g }t dd� | D ��� � �fdd�| D �}|S )a% Pad list of sentences according to the longest sentence in the batch. The paddings should be at the end of each sentence. @param sents (list[list[str]]): list of sentences, where each sentence is represented as a list of words @param pad_token (str): padding token @returns sents_padded (list[list[str]]): list of sentences where sentences shorter than the max length sentence are padded out with the pad_token, such that each sentences in the batch now has equal length. c S s g | ]}t |��qS � ��len)�.0�sentr r �7/Users/yimingwang/Desktop/cs224n/assignment/a4/utils.py� <listcomp>&