我有一个用UTF-8编码的字符串.例如:
Thats a nice joke
Run Code Online (Sandbox Code Playgroud)
我必须提取句子中的所有表情符号.表情符号可以是任何表情符号
当在终端使用命令查看此句子时,less text.txt它被视为:
Thats a nice joke <U+1F606><U+1F606><U+1F606> <U+1F61B>
Run Code Online (Sandbox Code Playgroud)
这是表情符号的相应UTF代码.emojis的所有代码都可以在emojitracker找到.
为了找到所有的出现,我使用了正则表达式模式,(<U\+\w+?>)但它不适用于UTF-8编码的字符串.
以下是我的代码:
String s="Thats a nice joke ";
Pattern pattern = Pattern.compile("(<U\\+\\w+?>)");
Matcher matcher = pattern.matcher(s);
List<String> matchList = new ArrayList<String>();
while (matcher.find()) {
matchList.add(matcher.group());
}
for(int i=0;i<matchList.size();i++){
System.out.println(matchList.get(i));
}
Run Code Online (Sandbox Code Playgroud)
这个pdf说Range: 1F300–1F5FF for Miscellaneous Symbols and Pictographs.所以我想捕捉这个范围内的任何角色.
我正在尝试使用 BERT 获取给定词嵌入的文本表示(或最接近的词)。基本上我试图获得与 gensim 类似的功能:
>>> your_word_vector = array([-0.00449447, -0.00310097, 0.02421786, ...], dtype=float32)
>>> model.most_similar(positive=[your_word_vector], topn=1))
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已经能够使用bert-as-service生成上下文词嵌入,但无法弄清楚如何获得与此嵌入最接近的词。我使用了预训练的 bert 模型(uncased_L-12_H-768_A-12)并且没有做任何微调。
我在eclipse中有一个WebSphere Application Server V8.5 Liberty Profile.我的webapp一直在给java.lang.OutOfMemoryError,因此我需要增加堆大小.
由于这个和这篇文章建议我改变了server.xml,通过添加jvmEntries标签(以前没有):
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>jsp-2.2</feature>
<feature>localConnector-1.0</feature>
<feature>jpa-2.0</feature>
</featureManager>
<!-- To access this server from a remote client add a host attribute to
the following element, e.g. host="*" -->
<httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint" />
<jvmEntries initialHeapSize="1024" maximumHeapSize="2048" />
<applicationMonitor updateTrigger="mbean" />
<webApplication id="app" location="app.war"
name="app" />
</server>
Run Code Online (Sandbox Code Playgroud)
但是eclipse将它显示为无效标记,并出现以下错误:
cvc-complex-type.2.4.a:从元素'jvmEntries'开始发现无效内容.其中一个'{include,variable,trustAssociation,applicationMonitor,application,classloading,basicRegistry,bundleRepository,osgiApplication,authentication,authCache,jaasLoginModule,jaasLoginContextEntry,cdiContainer,channelfw,tcpOptions,library,collectiveMember,hostAuthInfo,managedExecutorService,connectionManager,contextService,distributedMap, enterpriseApplication,web应用,httpDispatcher,MIME类型,httpEncoding,虚拟主机,httpOptions,httpAccessLogging,httpEndpoint,的authData,数据源,jdbcDriver,jndiEntry,JPA jspEngine,文件集,执行者,的FeatureManager,配置,customLdapFilterProperties,edirectoryLdapFilterProperties,domino50LdapFilterProperties,netscapeLdapFilterProperties,ldapRegistry,securewayLdapFilterProperties, iplanetLdapFilterProperties,idsLdapFilterProperties,activedLdapFilterProperties,logging,ltpa,ejbContainer,monitor,oauthProvider,oauth-roles,remoteFileAccess,administrator-role,
quickStartSecurity,pluginConfiguration,w ebContainer,httpSession,httpSessionDatabase,sslDefault,keyStore,ssl,sslOptions,timedOperation,transaction,webAppSecurity,federatedRepository,zosLogging,authorization-roles}'是预期的.
那么我应该如何增加堆大小呢?
我显示了一个编辑文本和一个保存按钮。当按下后退键时,我希望它们消失(如果它们可见)并且下一次后退将执行后退按钮的默认操作。代码如下:
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK
&& event.getRepeatCount() == 0) {
event.startTracking();
return true;
}
return super.onKeyDown(keyCode, event);
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking()
&& !event.isCanceled()) {
if(save.isShown())
{
save.setVisibility(Button.GONE);
text.setVisibility(EditText.GONE);
}
//else ???????????????
return true;
}
return super.onKeyUp(keyCode, event);
}
Run Code Online (Sandbox Code Playgroud)
上面的代码有以下结果: 1. 当 edittext 和 button 可见时,后退按钮使它们消失但接下来的按下什么都不呈现。虽然如果一直按下后退按钮,我们会回到上一个活动。2.当edittext和button最初不存在时,按下后退按钮会意外停止应用程序。虽然如果保持按下后退按钮,我们会回到上一个活动。
代替 else,我尝试了 finish() 但程序意外停止。返回 false 也结果相同..
我在dynamoDB中有一个名为'Contributors'的表.我有一个主复合键,其中哈希键是'UserId',排序键是'NoteId'.我想查询属于特定hashkey的所有项目.
现在,如果我使用aws-cli,则以下命令有效:
aws dynamodb query \
--table-name Contributors \
--key-condition-expression 'UserId = :UserId' \
--expression-attribute-values '{
":UserId": {"N":"2"}
}'
Run Code Online (Sandbox Code Playgroud)
但是当我在Node.js中编写查询时,以下两个参数对象都不起作用:
var params = {
TableName: "Contributors",
KeyConditionExpression: "#UserId = :UserId",
ExpressionAttributeNames: {
"#UserId": "UserId"
},
ExpressionAttributeValues: {
":UserId": { "N": "2" }
}
};
Run Code Online (Sandbox Code Playgroud)
或这个:
var params = {
TableName: "Contributors",
KeyConditionExpression: "#UserId = :UserId",
ExpressionAttributeNames: {
"#UserId": "UserId"
},
ExpressionAttributeValues: {
":UserId": "2"
}
};
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
ValidationException:一个或多个参数值无效:条件参数类型与模式类型不匹配
什么应该是正确的param对象?