我正在使用此处定义的可搜索配置在我的活动中实现语音搜索。但是,如果设备的区域设置不同,设置android:voiceLanguage="tr"
似乎不起作用。搜索应用程序对话框将在设备的区域设置以及搜索结果中打开。我使用SearchView
,因此无法捕获该onSearchRequested
函数,否则我可以以编程方式指定参数。设备区域设置为俄语,因此搜索查询会以西里尔语返回。如何强制以土耳其语或至少英语区域设置返回搜索结果?
可搜索.xml
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_name"
android:voiceLanguage="tr"
android:voiceLanguageModel="web_search"
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer" />
Run Code Online (Sandbox Code Playgroud)
搜索视图设置
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchItem = menu.findItem(R.id.search);
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setQueryHint(getString(R.string.search));
searchView.setOnQueryTextListener(new SearchWatcher());
if (searchManager != null)
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
return true;
}
Run Code Online (Sandbox Code Playgroud)
处理搜索结果
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
handleIntent(intent);
}
private void handleIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
searchView.setQuery(query, false);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试匹配 HTML 文档中的字符串并特别突出显示它。我将 BeautifulSoup 与 html.parser 一起使用。
到目前为止我尝试过使用 find_all() 并传递要匹配的字符串,但它没有帮助,因为它返回元素中存在的整个文本。
我希望您指导我如何定位文档中的特定字符串并突出显示它。
例如:标记:
<p>Lorem is simply dummy text of the printing and typesetting industry.</p>
<p>Lorem has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it
Run Code Online (Sandbox Code Playgroud)
突出显示后: 标记:
<p><mark>Lorem</mark> is simply dummy text of the printing and typesetting industry.</p>
<p><mark>Lorem</mark> has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of …
Run Code Online (Sandbox Code Playgroud) 考虑一个项目数量可变的计划,在 1 到 6 之间。如果有 1 - 4 个项目,它们应该覆盖 2x2 布局,例如:
ONE TWO
THREE FOUR
Run Code Online (Sandbox Code Playgroud)
如果有 5 - 6 个项目,它们应该覆盖 2x3 布局,例如:
ONE TWO THREE
FOUR FIVE SIX
Run Code Online (Sandbox Code Playgroud)
但是,我需要以编程方式将x22
或x23
类应用于项目,具体取决于项目的数量。我更喜欢在我的模板中不需要额外逻辑的解决方案。
ONE TWO
THREE FOUR
Run Code Online (Sandbox Code Playgroud)
ONE TWO THREE
FOUR FIVE SIX
Run Code Online (Sandbox Code Playgroud)
在以下示例中:如果用户说太妃糖,那不应该翻译成糖果吗?我问,因为传递给我的意图的价值是“太妃糖”。所以不确定我有什么不对。
types":[
{
"name":"SHOPPING_LIST",
"values":[
{
"id":null,
"name":{
"value":"candy",
"synonyms":[
"toffee"
]
}
},
{
"name":"GetPrice",
"samples":[
"Get me the price of {item}",
"tell me the price of {item}",
],
"slots":[
{
"name":"item",
"type":"SHOPPING_LIST"
}
]
}
Run Code Online (Sandbox Code Playgroud) alexa aws-lambda alexa-skill alexa-skills-kit alexa-voice-service
我在下面的场景中没有弄清楚static_cast和dynamic_cast之间的真正区别:
**///with static_cast///**
class Foo{};
class Bar: public Foo
{
public:
void func()
{
return;
}
};
int main(int argc, char** argv)
{
Foo* f = new Foo;
Bar* b = static_cast<Bar*>(f);
b->func();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
成功构建和编译!
**///with dynamic_cast///**
class Foo{};
class Bar: public Foo
{
public:
void func()
{
return;
}
};
int main(int argc, char** argv)
{
Foo* f = new Foo;
Bar* b = dynamic_cast<Bar*>(f);
b->func();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
main.cpp:在函数'int main(int,char**)'中:main.cpp:26:34:错误:不能用dynamic_cast'f'(类型'类Foo*')来键入'class Bar*'(源类型不是多态的)Bar*b = dynamic_cast(f);
如果有人能帮助我理解这一点,我将不胜感激!
代码
import numpy as np
a = 5.92270987499999979065
print(round(a, 8))
print(round(np.float64(a), 8))
Run Code Online (Sandbox Code Playgroud)
给
5.92270987
5.92270988
Run Code Online (Sandbox Code Playgroud)
知道为什么吗?
在numpy来源中找不到任何相关内容.
更新:
我知道处理这个问题的正确方法是以这种差异无关紧要的方式构建程序.我做的.我在回归测试中偶然发现了它.
Update2:
关于@VikasDamodar评论.人们不应该相信这个repr()
功能:
>>> np.float64(5.92270987499999979065)
5.922709875
>>> '%.20f' % np.float64(5.92270987499999979065)
'5.92270987499999979065'
Run Code Online (Sandbox Code Playgroud)
Update3:
在python3.6.0 x32,numpy 1.14.0,win64上测试.另外在python3.6.4 x64,numpy 1.14.0,debian.
Update4:
只是为了确定:
import numpy as np
a = 5.92270987499999979065
print('%.20f' % round(a, 8))
print('%.20f' % round(np.float64(a), 8))
5.92270987000000026512
5.92270988000000020435
Run Code Online (Sandbox Code Playgroud)
Update5:
以下代码演示了在不使用str
以下情况下发生差异的阶段:
>>> np.float64(a) - 5.922709874
1.000000082740371e-09
>>> a - 5.922709874
1.000000082740371e-09
>>> round(np.float64(a), 8) - 5.922709874
6.000000496442226e-09
>>> round(a, 8) - …
Run Code Online (Sandbox Code Playgroud) 我创建了一个auth middlewere来检查每个请求,中间是使用服务器(只有在req.connection中找不到数据).我正在尝试将服务注入到我的中间,我一直得到相同的错误"Nest无法解析AuthenticationMiddleware(?)的依赖关系.请验证当前上下文中是否有[0]参数可用."
AuthenticationModule:
@Module({
imports: [ServerModule],
controllers: [AuthenticationMiddleware],
})
export class AuthenticationModule {
}
Run Code Online (Sandbox Code Playgroud)
AuthenticationMiddleware:
@Middleware()
export class AuthenticationMiddleware implements NestMiddleware {
constructor(private service : UserService) {}
resolve(): (req, res, next) => void {
return (req, res, next) => {
if (req.connection.user)
next();
this.service.getUsersPermissions()
}
}
Run Code Online (Sandbox Code Playgroud)
ServerModule:
@Module({
components: [ServerService],
controllers: [ServerController],
exports: [ServerService]
})
export class ServerModule {}
Run Code Online (Sandbox Code Playgroud)
ApplicationModule:
@Module({
imports: [
CompanyModule,
ServerModule,
AuthenticationModule
]
})
export class ApplicationModule implements NestModule{
configure(consumer: MiddlewaresConsumer): void {
consumer.apply(AuthenticationMiddleware).forRoutes(
{ path: …
Run Code Online (Sandbox Code Playgroud) 我需要证明该方程组没有解决方案(原因是它被过度确定)。在Coq中有一种简单的方法吗?是战术还是图书馆?
Require Import Reals.
Open Scope R.
Lemma no_solution:
forall
b11 b12 b13 b14 b21 b22 b23 b24 b31 b32 b33 b34
r r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 : R,
1 = r * b11 + r0 * b21 + r1 * b31 ->
0 = r * b12 + r0 * b22 + r1 * b32 ->
0 = r * b13 + r0 * b23 + r1 * b33 -> …
Run Code Online (Sandbox Code Playgroud) 当我设置GoogleSignInOptions
为DEFAULT_SIGN_IN
一切正常时登录成功但当我尝试登录时GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN
返回Status{statusCode=unknown status code: 12501, resolution=null}
。
这是我在developers.google docs中编写的代码
GoogleSignInClient signInClient = GoogleSignIn.getClient(activity,
GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
Intent intent = signInClient.getSignInIntent();
activity.startActivityForResult(intent, RC_SIGN_IN);
Run Code Online (Sandbox Code Playgroud) android google-play google-play-services google-play-games google-signin
android ×3
python ×2
alexa ×1
alexa-skill ×1
aws-lambda ×1
c++ ×1
coq ×1
css ×1
css-grid ×1
dynamic-cast ×1
google-play ×1
grid-layout ×1
html ×1
html-parsing ×1
inheritance ×1
lint ×1
minify ×1
nestjs ×1
node.js ×1
numpy ×1
oop ×1
python-3.x ×1
rounding ×1
searchview ×1
static-cast ×1