Skip to content

Instantly share code, notes, and snippets.

View kingjr's full-sized avatar

Jean-Rémi KING kingjr

View GitHub Profile
import functools
import inspect
import shutil
import sys
import time
from datetime import datetime, timedelta
from pathlib import Path
from joblib import Memory
from transformers import AutoModel, AutoTokenizer
import torch
from tqdm.notebook import trange, tqdm
import pandas as pd
from bm.studies.utils import match_list
import numpy as np
import matplotlib.pyplot as plt
@kingjr
kingjr / narratives2020.py
Last active May 11, 2023 10:00
to put in bm/studies/
import itertools
import json
import os
import re
import typing as tp
from collections import defaultdict
from pathlib import Path
import datalad
import datalad.api
#pip install benepar
#pip install protobuf==3.20.0
import spacy
import numpy as np
class Parser():
def __init__(self,):
model = 'fr_core_news_sm'
@kingjr
kingjr / align.py
Last active September 29, 2022 16:06
import grequests # pip install grequests
from pathlib import Path
from tqdm import tqdm
import textgrid # pip install git+https://github.com/kylerbrown/textgrid#egg=textgrid
import typing as tp
import numpy as np
def online_MAUS_aligner(
txt_files, wav_files, language, ext="TextGrid", save_dir=None,
from Levenshtein import editops
def match_list(A, B, on_replace="delete"):
"""Match two lists of different sizes and return corresponding indice
Parameters
----------
A: list | array, shape (n,)
The values of the first list
@kingjr
kingjr / move_cursor.py
Created March 31, 2022 16:19
move_cursor.py
from pynput.mouse import Controller
import time
mouse = Controller()
for i in range(10_000_000):
mouse.move((i % 2)*2-1, 0)
time.sleep(60.)
@kingjr
kingjr / omar.py
Created January 3, 2022 15:11
omar
import numpy as np
from scipy.stats import ttest_1samp, wilcoxon
def ttest(a):
return ttest_1samp(a, 0)
n_times = 30
n_chans = 4
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kingjr
kingjr / svetlana.py
Created September 9, 2021 14:24
svetlana.py
# To add a new cell, type '# %%'
# To add a new markdown cell, type '# %% [markdown]'
# %%
#%matplotlib inline
# pip install python-levenshtein
import mne
import pandas as pd
import numpy as np
from scipy.io import loadmat
import matplotlib.pyplot as plt