Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (750,) + inhomogeneous part. #94

@guankaisi

Description

@guankaisi

sent1 = np.array([s.split() for s in sent1])[not_empty_idx]
In this line, the element of [s.split() for s in sent1] is not the same len. It will report this error. Has anyone met the same one?
I change the code to
`sent1_lengths = [len(s.split()) for s in sent1]
sent2_lengths = [len(s.split()) for s in sent2]
max_length = max(max(sent1_lengths), max(sent2_lengths))

sent1 = np.array([s.split() + [''] * (max_length - len(s.split())) for s in sent1])[not_empty_idx]
sent2 = np.array([s.split() + [''] * (max_length - len(s.split())) for s in sent2])[not_empty_idx]
`
and then the code go right.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions