Skip to content

Instantly share code, notes, and snippets.

View syu-id's full-sized avatar

Shaoyun Yu syu-id

  • The Hong Kong Polytechnic University
  • Hong Kong SAR
View GitHub Profile
@syu-id
syu-id / mattr.R
Last active May 20, 2016 11:32
RによるMATTRの実装 https://github.com/rongmu/mattr
# An alternative implementation of the MATTR algorithm in R
# author: Shaoyun YU <eric.rongmu@gmail.com>
# ref: Covington & Mcfall (2010) Cutting the Gordian Knot: The Moving-Average Type-Token Ratio
# usage: mattr(vector_of_tokens, window_size)
window_types <- function(i_start, win_size, data) {
i_end <- i_start + win_size - 1
win <- data[i_start:i_end]
@syu-id
syu-id / gset.yaml
Created January 24, 2014 12:51
my gnome settings in yaml
# vim: ft=yaml fdm=marker
# desc: gnome settings
general: #{{{1
- schema: org.gnome.settings-daemon.plugins.power
setting:
percentage-low: 15
percentage-critical: 10
percentage-action: 6
use-time-for-policy: false
@syu-id
syu-id / 20-dns.conf
Created January 21, 2014 09:36
Android DNS configuration: use Google Public DNS; file: /system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf; source: - http://blog.varunkumar.me/2010/09/how-to-change-dns-server-on-android.html - http://varun-scratchpad.googlecode.com/svn/trunk/static/20-dns.conf
# Set net.<iface>.dnsN properties that contain the
# DNS server addresses given by the DHCP server.
set_dns_props()
{
case "${new_domain_name_servers}" in
"") return 0;;
esac
count=1
@syu-id
syu-id / hub.PKGBUILD.sh
Created January 21, 2014 07:49
PKGBUILD for hub 1.11.1
# $Id$
# Maintainer: Daniel Wallace <danielwallace at gtmanfred dot com>
# Contributor: Alfredo Palhares <masterkorp@masterkorp.net>
pkgname=hub
pkgver=1.11.1
pkgrel=1
pkgdesc="cli interface for Github"
arch=('any')
url="http://hub.github.com/"
@syu-id
syu-id / upeditor.PKGBUILD.sh
Last active January 2, 2016 09:19
archlinux aur/upeditor fix: use the right name for i686 installer
# Maintainer: Yangtse Su<yangtsesu@gmail.com>
pkgname=upeditor
pkgver=1.0
pkgrel=2
pkgdesc='unionpay security control plugin'
url='https://online.unionpay.com/'
arch=('i686' 'x86_64')
license=('unknown')
depends=('openssl')
@syu-id
syu-id / LC-2015.12.11-graph.R
Last active December 17, 2015 13:54
学習者コーパス論 2015.12.11 作図
library(dplyr)
library(ggplot2)
library(scales)
df <- read.csv('out/2015.12.04-awl_asl.csv')
df_plot <- df %>%
mutate(
native = plyr::revalue(native, c(en = 'L1 English ', ja='L1 Japanese'))
@syu-id
syu-id / LC-2015.12.04-graph.R
Last active December 17, 2015 13:20
学習者コーパス論 2015.12.04 作図
library(dplyr)
library(ggplot2)
df <- read.csv('out/2015.12.04-awl_asl.csv')
df_plot <- df %>%
mutate(
native = plyr::revalue(native, c(en = 'L1 English ', ja='L1 Japanese'))
)
@syu-id
syu-id / mi-zsh-prpt.zsh
Created May 10, 2013 01:38
A minimalistic Zsh prompt, with a reverse ordered current working directory on the right-hand side, and a vi normal mode indicator.
# load colors
autoload -U colors
colors
PROMPT="%{$fg_bold[white]%}%#%{$reset_color%} "
# RPROMPT vi mode indicator
VI_INDICATOR="%{$fg_bold[blue]%}vi%{$reset_color%}"
revpwd() {
@syu-id
syu-id / 2015.12.04-learner_corpus-2
Created December 5, 2015 17:57
2015.12.04-learner_corpus-2
トークン数と TTR について少し数学的に考えてみると、プロットの結果が当たり前のことです。
トークン数とタイプ数は線形的な関係にあると仮定します。
$$
type = \beta_0 + \beta_1 \cdot token
$$
$token = 1$ の場合、$type=1$ になるので、$\beta_0$ と $\beta_1$ の和が $1$ に決まっています。
@syu-id
syu-id / LC-2015.12.04-awl_asl.R
Created December 5, 2015 06:33
学習者コーパス論 2015.12.04 AWL と ASL の計算
library(dplyr)
tokens <- read.csv('data/tokens.csv', as.is = TRUE)
result <- tokens %>%
group_by(native, id) %>%
summarise(
n_token = n(),
n_type = n_distinct(token),