Skip to content

Instantly share code, notes, and snippets.

@zhangmozhi
zhangmozhi / iternorm.py
Last active June 12, 2021 18:36
Code for "Are Girls Neko or Shōjo? Cross-Lingual Alignment of Non-Isomorphic Embeddings with Iterative Normalization"
"""Iterative Normalization"""
from argparse import ArgumentParser
import numpy as np
def load_embed(filename, max_vocab=-1):
words, embeds = [], []
with open(filename, 'r') as f:
next(f)
for line in f:
@kylebgorman
kylebgorman / function_words.py
Created June 22, 2018 18:57
Function words
"""English function words.
Sets of English function words, based on
E.O. Selkirk. 1984. Phonology and syntax: The relationship between
sound and structure. Cambridge: MIT Press. (p. 352f.)
The categories are of my own creation.
"""
def pearsonr(x, y):
"""
Mimics `scipy.stats.pearsonr`
Arguments
---------
x : 1D torch.Tensor
y : 1D torch.Tensor
Returns