有没有一种简单的方法可以在没有上下文的情况下使用nltk 确定给定单词的最可能的词性标记.或者,如果不使用任何其他工具/数据集.
我试图使用wordnet,但似乎sysnets不是按可能性排序的.
>>> wn.synsets('says')
[Synset('say.n.01'), Synset('state.v.01'), ...]
Run Code Online (Sandbox Code Playgroud) 我找到了与Stanford Core NLP兼容的德语解析和pos-tag模型.但是我无法让德语词典化工作.有办法吗?
我使用TensorFlow中的rnn.rnn帮助器实现了Sequence to Sequence模型.
with tf.variable_scope("rnn") as scope, tf.device("/gpu:0"):
cell = tf.nn.rnn_cell.BasicLSTMCell(4096)
lstm = tf.nn.rnn_cell.MultiRNNCell([cell] * 2)
_, cell = rnn.rnn(lstm, input_vectors, dtype=tf.float32)
tf.get_variable_scope().reuse_variables()
lstm_outputs, _ = rnn.rnn(lstm, output_vectors, initial_state=cell)
Run Code Online (Sandbox Code Playgroud)
该模型在具有16 GB内存的Titan X上耗尽内存,同时为LSTM单元分配渐变:
W tensorflow/core/kernels/matmul_op.cc:158] Resource exhausted: OOM when allocating tensor with shape[8192,16384]
W tensorflow/core/common_runtime/executor.cc:1102] 0x2b42f00 Compute status: Resource exhausted: OOM when allocating tensor with shape[8192,16384]
[[Node: gradients/rnn/RNN/MultiRNNCell_1/Cell0/BasicLSTMCell/Linear/MatMul_grad/MatMul_1 = MatMul[T=DT_FLOAT, transpose_a=true, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](rnn/RNN/MultiRNNCell_1/Cell0/BasicLSTMCell/Linear/concat, gradients/rnn/RNN/MultiRNNCell_1/Cell0/BasicLSTMCell/add_grad/tuple/control_dependency)]]
Run Code Online (Sandbox Code Playgroud)
如果我将输入和输出序列的长度减少到4或更少,模型运行没有问题.
这向我表明TF正在尝试同时为所有时间步骤分配梯度.有没有办法避免这种情况?
我正在寻找一种方法将按键转换为对应于字符的字符串.像这样的东西:
$(document).keydown(function(event) {
console.log(String.fromCharCode(event.which));
});
Run Code Online (Sandbox Code Playgroud)
除了这段代码没有考虑大小写并且不适用于特殊字符,例如",".这个:
$(document).keypress(function(event) {
console.log(String.fromCharCode(event.which));
});
Run Code Online (Sandbox Code Playgroud)
似乎是诀窍,但它无法阻止默认的浏览器操作(例如返回退格)并且似乎存在浏览器兼容问题.
有没有更好的方法,适用于浏览器和键盘布局?