Wednesday, 23 August 2023

Getting jaccard similarity from co-ocurrence matrix

I have a co-occurence matrix in python for co-ocurrences of certain keywords A,B,C

    A   B   C
A   5   1   0
B   1   3   2
C   0   2   3

How can I calculate the jaccard similarity from this matrix in Python for all keywords. Is there any library available to do that or should I simply compute the similarity by using the Jaccard similarity formula?



from Getting jaccard similarity from co-ocurrence matrix

Tuesday, 22 August 2023

gdb python in pyenv virtualenv

I am working inside a pyenv-managed virtualenv

$ which python
/Users/theonlygusti/.pyenv/shims/python

/Users/theonlygusti/.pyenv/shims/python is a shell script and gdb doesn't work

"0x7ffeeb614570s": not in executable format: file format not recognized

How can I use gdb on a python script like here https://stackoverflow.com/a/2664232/3310334 to debug my C extension's segfault?

https://stackoverflow.com/a/53007303/3310334 suggests gdb -ex r --args bash python crash.py, but it doesn't work, same error

"0x7ffee0aa4530s": not in executable format: file format not recognized


from gdb python in pyenv virtualenv

--footer not showing when using wkhtmltopdf within a docker container

I am trying to deploy a flask (python) app that uses wkhtmltopdf.

Everything works perfectly when it is run in a debug environment, however when I run it using docker, it stops showing footers and headers.

I suspect it has something to do with the way Docker installs wkhtmltopdf.

Here is my Dockerfile

# set base image (host OS)
FROM python:3.9
RUN apt-get update && \
    apt-get install -y locales && \
    sed -i -e 's/# es_ES.UTF-8 UTF-8/es_ES.UTF-8 UTF-8/' /etc/locale.gen && \
    dpkg-reconfigure --frontend=noninteractive locales
ENV LC_TIME es_ES.UTF-8

# I BELIEVE I AM MISSING SOMETHING HERE
RUN apt-get install wkhtmltopdf -y

# set the working directory in the container
WORKDIR /app
ENV PYTHONPATH "${PYTHONPATH}:/app/src"

# copy the dependencies file to the working directory
COPY requirements.txt .

# install dependencies
RUN pip install -r requirements.txt

# copy the content of the local src directory to the working directory
COPY . .

# command to run on container start
CMD [ "gunicorn", "src.wsgi:app","--bind","0.0.0.0:5000" ]

Here are the relevante python requirements in case they might be useful.

PyPDF2==1.26.0
pdfkit==0.6.1

Any help will be much appreciated. Thanks!



from --footer not showing when using wkhtmltopdf within a docker container