You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Performance is slow when the dictionaries are large, and text are large, but we are not really sure where the bottlenecks are occurring. See this comment
for instance from SO.
In 'normal' usage of tokens_lookup (i.e. N-to-N matching), it's performance is still good (despite it being such a complex function for nuanced results). With the Guardian corpus (500MB) and LIWC2007 dictionary (10,603 words in 64 keys):
microbenchmark::microbenchmark(
fixed=tokens_lookup(toks, dict_liwc, valuetype='fixed', verbose=FALSE),
glob=tokens_lookup(toks, dict_liwc, valuetype='glob', verbose=FALSE),
times=1
)
#Unit: seconds# expr min lq mean median uq max neval# fixed 61.17901 61.17901 61.17901 61.17901 61.17901 61.17901 1# glob 101.81795 101.81795 101.81795 101.81795 101.81795 101.81795 1
However, it takes forever to finish lematization (or custom stemming), because of the large number of keys. It is taking a lot of time in converting character to ID in regex2id(), but it is absolutely unnecessary in 1-to-1matching. For example, we are just stemming types of tokens in tokens_wordstem().
I was thinking to create a types converter for users who wish to use custom word stemmer. The code would be like:
It does not happen in tokens_lookup(), but dictionary lookup is currently the only way for users to covert tokens (see #514). In order to use steammers not in quanteda, users have to create and apply a massive dictionary in this way:
Activity
[-]benchmark dictionary lookup functions[/-][+]Benchmark dictionary lookup functions[/+]koheiw commentedon Sep 14, 2017
In 'normal' usage of
tokens_lookup(i.e. N-to-N matching), it's performance is still good (despite it being such a complex function for nuanced results). With the Guardian corpus (500MB) and LIWC2007 dictionary (10,603 words in 64 keys):However, it takes forever to finish lematization (or custom stemming), because of the large number of keys. It is taking a lot of time in converting character to ID in
regex2id(), but it is absolutely unnecessary in 1-to-1matching. For example, we are just stemming types of tokens intokens_wordstem().I was thinking to create a types converter for users who wish to use custom word stemmer. The code would be like:
kbenoit commentedon Sep 14, 2017
What do you mean by the "custom stemming" - at what stage does this happen in the
tokens_lookup()process?koheiw commentedon Sep 14, 2017
It does not happen in
tokens_lookup(), but dictionary lookup is currently the only way for users to covert tokens (see #514). In order to use steammers not in quanteda, users have to create and apply a massive dictionary in this way:This is really inefficient.
koheiw commentedon Sep 14, 2017
It is also good to have an argument for a user-defined function to be applied to types:
This is the same as:
Advanced users (including me) would love this.