Change the names of the dimensions in the word embeddings.

textDimName(word_embeddings, dim_names = TRUE)

Arguments

word_embeddings

List of word embeddings

dim_names

(boolean) If TRUE the word embedding name will be attached to the name of each dimension; is FALSE, the attached part of the name will be removed.

Value

Word embeddings with changed names.

See also

Examples

# \donttest{
# Note that dimensions are called Dim1_harmonytexts etc.
word_embeddings_4$texts$harmonytexts
#> # A tibble: 40 × 10
#>    Dim1_ha…¹ Dim2_h…² Dim3_h…³ Dim4_h…⁴ Dim5_…⁵ Dim6_…⁶ Dim7_h…⁷ Dim8_…⁸ Dim9_…⁹
#>        <dbl>    <dbl>    <dbl>    <dbl>   <dbl>   <dbl>    <dbl>   <dbl>   <dbl>
#>  1   0.421    0.00160 -9.49e-4 -0.00953  0.100  -0.450   0.457     0.628 -0.154 
#>  2  -0.00679  0.0737   3.11e-1 -0.103   -0.105  -0.611   0.241     0.606 -0.366 
#>  3   0.119   -0.0586   3.91e-1 -0.160    0.0384 -0.362  -0.134     0.802 -0.437 
#>  4  -0.0370   0.234    2.30e-1 -0.0742   0.170   0.0253 -0.408     0.258 -0.0241
#>  5   0.172    0.0862   3.82e-1 -0.256    0.137  -0.251   0.286     0.860 -0.132 
#>  6   0.210    0.260   -6.05e-2 -0.0254   0.0469 -0.113   0.301     0.670 -0.379 
#>  7   0.487    0.269    1.47e-1  0.0644   0.0636 -0.405  -0.0268    1.02  -0.553 
#>  8   0.359    0.0775   6.50e-2 -0.135    0.0101 -0.337   0.00484   0.836 -0.245 
#>  9   0.219    0.231    2.80e-1 -0.0616   0.0224 -0.289  -0.189     0.571 -0.278 
#> 10   0.0794   0.389    2.22e-1 -0.292    0.0854 -0.279   0.278     0.842 -0.276 
#> # … with 30 more rows, 1 more variable: Dim10_harmonytexts <dbl>, and
#> #   abbreviated variable names ¹​Dim1_harmonytexts, ²​Dim2_harmonytexts,
#> #   ³​Dim3_harmonytexts, ⁴​Dim4_harmonytexts, ⁵​Dim5_harmonytexts,
#> #   ⁶​Dim6_harmonytexts, ⁷​Dim7_harmonytexts, ⁸​Dim8_harmonytexts,
#> #   ⁹​Dim9_harmonytexts
# Here they are changed to just Dim
w_e_T <- textDimName(word_embeddings_4$texts["harmonytexts"],
  dim_names = FALSE
)
# Here they are changed back
w_e_F <- textDimName(w_e_T, dim_names = TRUE)
# }