dice-group / palmetto-py

Python interface for https://github.com/dice-group/Palmetto
Apache License 2.0
40 stars 9 forks source link

Connection error and endpoint down with the latest 3.3 version #13

Closed finch-f closed 2 years ago

finch-f commented 2 years ago

Hi,

I run the following code

words =[items_en.iat[i,0],items_en.iat[j,0]]
            similarity_pmi[i,j]=palmetto.get_coherence(words,coherence_type="npmi")

and two errors reported,


E:\Program Files\Anaconda\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    515 
--> 516             raise ConnectionError(e, request=request)
    517 

ConnectionError: HTTPSConnectionPool(host='palmetto.demos.dice-research.org', port=443): Max retries exceeded with url: /service/npmi?words=hair%20hair (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000002558E231B50>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。'))

During handling of the above exception, another exception occurred:

EndpointDown                              Traceback (most recent call last)
C:\Users\PSYCHO~1\AppData\Local\Temp/ipykernel_45956/180416603.py in <module>
      9         if i<=j:
     10             words =[items_en.iat[i,0],items_en.iat[j,0]]
---> 11             similarity_pmi[i,j]=palmetto.get_coherence(words,coherence_type="npmi")
     12             similarity_pmi[j,i]=similarity_pmi[i,j]
     13 

E:\Program Files\Anaconda\lib\site-packages\palmettopy\palmetto.py in get_coherence(self, words, coherence_type)
    102             Output: a float number less than 1, i.e. 0.53493
    103         """
--> 104         return self._get_coherence(words, coherence_type)
    105 
    106     def get_coherence_fast(self, words):

E:\Program Files\Anaconda\lib\site-packages\palmettopy\palmetto.py in _get_coherence(self, words, coherence_type)
     89             raise CoherenceTypeNotAvailable(coherence_type)
     90 
---> 91         coherence = self._request_by_service(words, coherence_type)
     92 
     93         return float(coherence)

E:\Program Files\Anaconda\lib\site-packages\palmettopy\palmetto.py in _request_by_service(self, words, service_type, content_type)
     27             r = requests.get(request_uri, timeout=self.timeout)
     28         except BaseException:
---> 29             raise EndpointDown(request_uri)
     30 
     31         if(not r.ok):

EndpointDown: http://palmetto.aksw.org/palmetto-webapp/service/npmi?words=hair%20hair

How can I fixed these problems? Thank for your time~

MichaelRoeder commented 2 years ago

Hi,

thank you for using Palmetto. Unfortunately, there is no simple fix available (see #12 for an explanation). The only alternative that I am aware of is to download and set up a local Palmetto service. The service is based on Java and Maven. A description can be found at https://github.com/dice-group/Palmetto/wiki/How-Palmetto-can-be-used#local-palmetto-service

MichaelRoeder commented 2 years ago

Please use the endpoint at http://palmetto.cs.upb.de:8080/service/ for the time being. (edited)

julien-blanchard commented 2 years ago

Hi Michael,

Big fan of Palmetto here.

In case this helps, running:

palmetto = Palmetto("http://palmetto.cs.upb.de:8080/") words = ["cake", "apple", "banana", "cherry", "chocolate"] palmetto.get_coherence(words, coherence_type="cp")

Returns the following error log:

EndpointDown: http://palmetto.cs.upb.de:8080/cp?words=cake%20apple%20banana%20cherry%20chocolate

Thanks for your work on Palmetto, using it a lot for school. Hope the above helps :)

MichaelRoeder commented 2 years ago

I am happy that you like our project :smiley:

The endpoint is correct. However, I missed that you need to give the exact URL of the service endpoint:

palmetto = Palmetto("http://palmetto.cs.upb.de:8080/service/")
julien-blanchard commented 2 years ago

Thanks Michael, working perfectly now.

And yes, on a separate note, in our university's repo of MSc thesis, pretty much all recent submissions around information extraction / topic modelling use Palmetto for topic evaluation.

Cheers from Ireland!

finch-f commented 2 years ago

Please use the endpoint at http://palmetto.cs.upb.de:8080/service/ for the time being. (edited)

Thanks, Michael. It works now. Perfect!

MichaelRoeder commented 2 years ago

The "old" URL https://palmetto.demos.dice-research.org/ works again. The endpoint is the same so it doesn't matter which one is used :wink:

We apologize that it took so long to finally get it fixed.