This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(dplyr) | |
tokens <- read.csv('data/tokens.csv') | |
result <- tokens %>% | |
group_by(native, id) %>% | |
summarise( | |
n_token = length(token), | |
n_type = length(unique(token)), | |
ttr = n_type / n_token, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
native | id | n_token | n_type | ttr | gi | |
---|---|---|---|---|---|---|
591 | 365 | 144 | 0.394520547945205 | 7.53730448529908 | ||
en | 501 | 738 | 361 | 0.489159891598916 | 13.2885936376732 | |
en | 502 | 636 | 340 | 0.534591194968553 | 13.4818769572084 | |
en | 503 | 834 | 353 | 0.42326139088729 | 12.2233903227874 | |
en | 504 | 824 | 336 | 0.407766990291262 | 11.7051146400992 | |
en | 505 | 898 | 393 | 0.437639198218263 | 13.1145798598269 | |
en | 506 | 834 | 341 | 0.408872901678657 | 11.8078643061488 | |
en | 507 | 600 | 264 | 0.44 | 10.777754868246 | |
en | 508 | 848 | 332 | 0.391509433962264 | 11.4009268077412 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
トークン数と TTR について少し数学的に考えてみると、プロットの結果が当たり前のことです。 | |
トークン数とタイプ数は線形的な関係にあると仮定します。 | |
$$ | |
type = \beta_0 + \beta_1 \cdot token | |
$$ | |
$token = 1$ の場合、$type=1$ になるので、$\beta_0$ と $\beta_1$ の和が $1$ に決まっています。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
OlderNewer