lazarinastoy / meta-descriptions-BERT

If you want a quick and dirty way to programmatically meta descriptions at scale using Python, this is the tutorial for you. Jupyter notebook, as well as a step-by-step process included.
18 stars 7 forks source link

"Summarizer" object is not callable #1

Open deanlongio opened 2 years ago

deanlongio commented 2 years ago

Hi Laza

Thank you for the article demonstrating how to use BERT to generate meta description

However, when I try the code, it shows an error "Summarizer" object is not callable.

I found a issue in this git repo too but there's no solution https://github.com/dmmiller612/bert-extractive-summarizer/issues/48

do you know what I should do?

I have tried pip3 install bert-extractive-summarizer

then

pip3 install summarize

but none of these work

Webclimb commented 2 years ago

I tried running the script but received the error: ValueError: Length of values (1) does not match length of index (321)

Any ideas on how to fix?

ValueError Traceback (most recent call last) Input In [3], in 25 metadesc.append(full) 27 #save stored values in a in a column ---> 28 df['Meta Desc'] = metadesc 30 #save output 31 output = df.to_csv('output.csv')

File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/frame.py:3612, in DataFrame.setitem(self, key, value) 3609 self._setitem_array([key], value) 3610 else: 3611 # set column -> 3612 self._set_item(key, value)

File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/frame.py:3784, in DataFrame._set_item(self, key, value) 3774 def _set_item(self, key, value) -> None: 3775 """ 3776 Add series to DataFrame in specified column. 3777 (...) 3782 ensure homogeneity. 3783 """ -> 3784 value = self._sanitize_column(value) 3786 if ( 3787 key in self.columns 3788 and value.ndim == 1 3789 and not is_extension_array_dtype(value) 3790 ): 3791 # broadcast across multiple columns if necessary 3792 if not self.columns.is_unique or isinstance(self.columns, MultiIndex):

File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/frame.py:4509, in DataFrame._sanitize_column(self, value) 4506 return _reindex_for_setitem(value, self.index) 4508 if is_list_like(value): -> 4509 com.require_length_match(value, self.index) 4510 return sanitize_array(value, self.index, copy=True, allow_2d=True)

File /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pandas/core/common.py:531, in require_length_match(data, index) 527 """ 528 Check the length of data matches the length of the index. 529 """ 530 if len(data) != len(index): --> 531 raise ValueError( 532 "Length of values " 533 f"({len(data)}) " 534 "does not match length of index " 535 f"({len(index)})" 536 )

ValueError: Length of values (1) does not match length of index (321)

Albita88 commented 2 years ago

Still not working.

It was too good to be true

lazarinastoy commented 2 years ago

Hi all,

This is explained in this thread.

https://github.com/dmmiller612/bert-extractive-summarizer/issues/48

lazarinastoy commented 2 years ago

"the error most likely means you already have a package called summarizer installed."

Check-in anaconda or whatever else platform you use, what you have installed, or create a new base with the appropriate model installed and run the script with that. Can also use pip to install/uninstall all packages that might share the same name with the BERT summariser. :)

lazarinastoy commented 2 years ago

@webclimb This error you are facing is related to your data frame. Please check out a solution and explanation of the problem here: ⬇️

https://stackoverflow.com/questions/42382263/valueerror-length-of-values-does-not-match-length-of-index-pandas-dataframe-u