Skip to content

Instantly share code, notes, and snippets.

View Hironsan's full-sized avatar
💤
Zzz

Hiroki Nakayama Hironsan

💤
Zzz
View GitHub Profile
@Hironsan
Hironsan / infinite_relational_model.py
Last active March 6, 2025 00:33
Python implementation of infinite relational model
import random
from collections import defaultdict
from collections.abc import Iterator
from typing import Literal, Optional
import networkx as nx
import numpy as np
import numpy.typing as npt
import tqdm
from scipy.special import betaln, logsumexp
[paths]
train = "./train.spacy"
dev = "./dev.spacy"
init_tok2vec = null
vectors = null
[corpora]
[corpora.train]
@readers = "spacy.Corpus.v1"
import spacy
from spacy.tokens import DocBin
from spacy_partial_tagger.tokenizer import CharacterTokenizer
text = "Selegiline - induced postural hypotension in Parkinson's disease: a longitudinal study on the effects of drug withdrawal."
patterns = [
{"label": "Chemical", "pattern": [{"LOWER": "selegiline"}]},
{"label": "Disease", "pattern": [{"LOWER": "hypotension"}]},
{
"label": "Disease",
This file has been truncated, but you can view the full file.
{"0": {"points": [0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20, 1, 21, 1, 22, 1, 23, 1, 24, 1, 25, 1, 26, 1, 27, 1, 28, 1, 29, 1, 30, 1, 31, 1, 32, 1, 33, 1, 34, 1, 35, 1, 36, 1, 37, 1, 38, 2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2, 10, 2, 11, 2, 12, 2, 13, 2, 14, 2, 15, 2, 16, 2, 17, 2, 18, 2, 19, 2, 20, 2, 21, 2, 22, 2, 23, 2, 24, 2, 25, 2, 26, 2, 27, 2, 28, 2, 29, 2, 30, 2, 31, 2, 32, 2, 33, 2, 34, 2, 35, 2, 36, 2, 37, 2, 38, 3, 0, 3, 1, 3, 2, 3, 3, 3, 4, 3, 5, 3, 6, 3, 7, 3, 8, 3, 9, 3, 10, 3, 11, 3, 12, 3, 13, 3, 14, 3, 15, 3, 16, 3, 17, 3, 18, 3, 19, 3, 20, 3, 21, 3, 22, 3, 23, 3, 24, 3, 25, 3, 26, 3, 27, 3, 28, 3, 29, 3, 30, 3,
@Hironsan
Hironsan / lambda_function.py
Created June 30, 2020 08:59
spaCy for Lambda
import os
import urllib.request
import spacy
import tarfile
from pathlib import Path
def maybe_download(model, dest):
save_path = Path(dest) / model
if not os.path.exists(save_path):
#!/bin/bash
REGION=us-east-1
RUNTIME=python3.7
while getopts :n:r:p: OPT
do
case $OPT in
n) PACKAGE=$OPTARG;;
r) REGION=$OPTARG;;
p) RUNTIME=$OPTARG;;
REGION=us-west-1
RUNTIME=python3.7
docker run \
-v $(pwd):/opt \
-it lambci/lambda:build-$RUNTIME \
pip install spacy -t /opt/python
zip -r spacy.zip python/
@Hironsan
Hironsan / todo.md
Last active January 28, 2021 11:49
「機械学習・深層学習による自然言語処理入門」の誤植等の管理

「機械学習・深層学習による自然言語処理入門」の誤植等

  • より良い本にするため、誤植や誤り、改善点等の洗い出しと反映を行う。
  • サポートページへ反映されるまで時間がかかるので、一旦ここで管理する。
  • 正式な内容は編集に依頼してサポートページへ掲載する。
  • フィードバック、指摘、マサカリ、感謝します。

誤植

| ページ | 誤 | 正しい | 備考 |

1444062497
284862083
762630884
1188614369
1104161854
1280855887
586449534
1206728554
468429333
566799704