You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (5,) + inhomogeneous part.
Yeah, I meant that example, these are the steps I'm performing:
$mkdir python_matching
$cd python_matching/
$python3 -m venv env
$source env/bin/activate
$pip install schema-matching
$touch matching_test.py ( and copy the example code into it)
$cp -r 'Test Data'/ ~/python_matching/TestData (copy the Test Data directory from the repository)
$python3 matching_test.py
schema_matching|Loading sentence transformer, this will take a while...
schema_matching|Done loading sentence transformer
Traceback (most recent call last):
File "/python_matching/matching_test.py", line 3, in
df_pred,df_pred_labels,predicted_pairs = schema_matching("TestData/QA/Table1.json","TestData/QA/Table2.json")
File "/python_matching/env/lib/python3.10/site-packages/schema_matching/cal_column_similarity.py", line 83, in schema_matching
features,_ = make_data_from(table1_df, table2_df, type="test")
File "/python_matching/env/lib/python3.10/site-packages/schema_matching/relation_features.py", line 122, in make_data_from
colnames_features = get_colnames_features(c1_name, c2_name,column_name_embeddings)
File "/python_matching/env/lib/python3.10/site-packages/schema_matching/relation_features.py", line 88, in get_colnames_features
colnames_features = np.array([bleu_score, edit_distance, lcs,transformer_score, one_in_one])
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (5,) + inhomogeneous part.
Activity
fireindark707 commentedon Oct 18, 2023
Hello @rsancheztaksoiai
Do you mean the example using python package?
Install
Example
I just tried that and it works well:
rsancheztaksoiai commentedon Oct 18, 2023
Hi @fireindark707 , thanks for your quick response!
Yeah, I meant that example, these are the steps I'm performing:
$mkdir python_matching
$cd python_matching/
$python3 -m venv env
$source env/bin/activate
$pip install schema-matching
$touch matching_test.py ( and copy the example code into it)
$cp -r 'Test Data'/ ~/python_matching/TestData (copy the Test Data directory from the repository)
$python3 matching_test.py
schema_matching|Loading sentence transformer, this will take a while...
schema_matching|Done loading sentence transformer
Traceback (most recent call last):
File "
/python_matching/matching_test.py", line 3, in/python_matching/env/lib/python3.10/site-packages/schema_matching/cal_column_similarity.py", line 83, in schema_matchingdf_pred,df_pred_labels,predicted_pairs = schema_matching("TestData/QA/Table1.json","TestData/QA/Table2.json")
File "
features,_ = make_data_from(table1_df, table2_df, type="test")
File "
/python_matching/env/lib/python3.10/site-packages/schema_matching/relation_features.py", line 122, in make_data_from/python_matching/env/lib/python3.10/site-packages/schema_matching/relation_features.py", line 88, in get_colnames_featurescolnames_features = get_colnames_features(c1_name, c2_name,column_name_embeddings)
File "
colnames_features = np.array([bleu_score, edit_distance, lcs,transformer_score, one_in_one])
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (5,) + inhomogeneous part.
hyperdigitalplatform commentedon Jan 17, 2024
i was getting this error and able to fix the issue by adding below line:
transformer_score = transformer_score.item()
in the function :
def get_colnames_features(text1,text2,column_name_embeddings):
"""
Use BLEU, edit distance and word2vec to calculate features.
"""
bleu_score = bleu([text1], text2, smoothing_function=smoothie)
print(type(bleu_score))
edit_distance = damerau.distance(text1, text2)
lcs = metriclcs.distance(text1, text2)
transformer_score = util.cos_sim(column_name_embeddings[text1], column_name_embeddings[text2])
transformer_score = transformer_score.item()
one_in_one = text1 in text2 or text2 in text1
colnames_features = np.array([bleu_score, edit_distance, lcs,transformer_score, one_in_one])
return colnames_features
zcasanova commentedon Feb 1, 2025
Thank you. I had the same issue and this fixed it.