这可能有点早,但我正在运行Windows 10 Technical Preview Build 10122.我想设置Cortana以获得自定义命令.以下是她的工作方式:
Hey Cortana, <she'll listen and process this command>
Run Code Online (Sandbox Code Playgroud)
Microsoft将处理该命令,如果没有任何内容,她将只搜索bing上的输入.但是,我想能够说出类似的话,例如
Hey Cortana, I'm going to bed now
Run Code Online (Sandbox Code Playgroud)
并让输入I'm going to bed now触发器运行批处理脚本,VBScript,命令或任何某种自定义响应,基本上执行以下操作.
C:\> shutdown -s
Run Code Online (Sandbox Code Playgroud)
有没有办法为Cortana设置预定义的自定义命令?
更新:
我创建了这个基本的YouTube教程,这个更高级的教程与相应的GitHub回购基于talkitbr的优秀且非常有用的答案如下.
起初他的答案超出了我的理解,所以我决定将其细节分解为像我这样的未来用户.
我正在努力创建自定义Cortana命令.使用通用Windows平台应用程序注册和执行命令.(GitHub的)
例如,我已经注册了以下命令
<Command Name="ShutDown">
<ListenFor>Shut down</ListenFor>
<Navigate/>
</Command>
Run Code Online (Sandbox Code Playgroud)
在UWP应用程序中运行此功能
static async void ShutDown()
{
var dialog = new MessageDialog("This is where I would shut the computer down.");
await dialog.ShowAsync();
//System.Diagnostics.Process.Start("Shutdown", "-s -t 10");
}
Run Code Online (Sandbox Code Playgroud)
但是在设置之后System.Diagnostics.Process,UWP不支持我学到的东西.
我想运行的自定义命令涉及某种执行,例如启动外部程序,运行其他脚本或打开网站.
UWP不支持它们是有意义的,因为它是通用的,XBox或手机可能无法做到这些,但我希望在Windows 10 PC上有一些替代或黑客的方法来实现这一点.
我有办法Process在UWP应用程序中执行命令或具有类似功能的其他东西吗?似乎即使我可以让Cortana执行我的C#代码,UWP也不支持在这种情况下有用的东西.
提前致谢.
我想从DataGridView获取Grid值的DataTable.
换句话说,DataTable与DataGridView值相同
我正在为与数据库同步的Windows平板电脑构建一个C#程序.他们每个人都有自己的本地.MDFSQL Server数据库,他们使用SQL Server Express进行交互.
但是,用户将从互联网连接中取出平板电脑并进行更改.然后,当一个人重新连接到包含DataBase的"主副本"的网络时,我想要将它们的.MDF数据库同步.然后用新同步的数据库替换计算机和平板电脑的数据库文件.
我有一个uniqueidentifier列,以及datetime最后一次更改该行的时间,所以如果有冲突,我会采取最近的更改.
我已经阅读了一些关于此的文献,但我很乐意看到一个明确的例子或教程如何做到这一点.我知道我想要的是合并复制,并且Microsoft Sync Framework似乎具有我想要的功能.我正在努力实现它.或者,您可以随意推荐其他工具.
提前致谢!
database sql-server synchronization merge-replication microsoft-sync-framework
我想从一个对象数组中提取所有唯一属性,你可以使用spread运算符和Set来非常干净地在ES6中这样做:
var arr = [ {foo:1, bar:2}, {foo:2, bar:3}, {foo:3, bar:3} ]
const uniqueBars = [... new Set(arr.map(obj => obj.bar))];
>> [2, 3]
Run Code Online (Sandbox Code Playgroud)
但是,在TypeScript 1.8.31中,这给了我构建错误:
找不到名字'Set'
我知道我可以通过使用迫使VS忽略它
declare var Set;
Run Code Online (Sandbox Code Playgroud)
但我希望TypeScript可以编译成非ES6,以便它可以在旧系统上使用.
有谁知道我可以使用这样的功能吗?
编辑:
实际上,即使我使用declare var Set;,上面的代码编译但反复抛出此错误,所以即使没有编译,我也不确定如何使用它:
未捕获的TypeError :(中间值).slice不是函数
如何更新我Set在TypeScript中使用的代码?
我有这样的文件:
documents = [
"I work on c programing.",
"I work on c coding.",
]
Run Code Online (Sandbox Code Playgroud)
我有同义词文件,如:
synonyms = {
"c programing": "c programing",
"c coding": "c programing"
}
Run Code Online (Sandbox Code Playgroud)
我想替换我编写此代码的所有同义词:
# added code to pre-compile all regex to save compilation time. credits alec_djinn
compiled_dict = {}
for value in synonyms:
compiled_dict[value] = re.compile(r'\b' + re.escape(value) + r'\b')
for doc in documents:
document = doc
for value in compiled_dict:
lowercase = compiled_dict[value]
document = lowercase.sub(synonyms[value], document)
print(document)
Run Code Online (Sandbox Code Playgroud)
输出:
I work on c …Run Code Online (Sandbox Code Playgroud) 我想创建一个图表,显示来自邻接矩阵的节点之间的连接,如下所示.

gplot似乎是最好的工具.但是,为了使用它,我需要传递每个节点的坐标.问题是我不知道坐标应该在哪里,我希望这个函数能够为我找出一个好的布局.
例如,这是我的输出使用以下任意坐标:
A = [1 1 0 0 1 0;
1 0 1 0 1 0;
0 1 0 1 0 0;
0 0 1 0 1 1;
1 1 0 1 0 0;
0 0 0 1 0 0];
crd = [0 1;
1 1;
2 1;
0 2;
1 2;
2 2];
gplot (A, crd, "o-");
Run Code Online (Sandbox Code Playgroud)

这很难读,但是如果我稍微使用坐标并将它们更改为以下内容就会变得更具可读性.
crd = [0.5 0;
0 1;
0 2;
1 2;
1 1;
1.5 2.5];
Run Code Online (Sandbox Code Playgroud)

我不希望完美优化的坐标或任何东西,但我怎么能告诉MATLAB自动为我找出一组坐标看起来没问题使用某种算法,所以我可以绘制一些看起来像顶部图片的东西.
提前致谢.
我正在尝试编写一个switch语句,但它似乎没有按我的意愿工作.
getExerciseDescription(exerciseId, intensity_level){
alert(exerciseId + " " + intensity_level)
switch (exerciseId && intensity_level) {
case (1 && 1):
this.header="Exercise 1 Level 1";
this.instructions="Exercise 1 Level 1";
break;
case (1 && 2):
this.header="Exercise 1 Level 2";
this.instructions="Exercise 1 Level 2";
break;
case (2 && 1):
this.header="Exercise 2 Level 1";
this.instructions="Exercise 2 Level 1";
break;
case (2 && 2):
this.header="Exercise 2 Level 2";
this.instructions="Exercise 2 Level 2";
break;
default:
this.header="Default";
this.instructions="Default";
break;
}
return new Popup(this.header, this.instructions);
}
Run Code Online (Sandbox Code Playgroud)
警报给出2和1,但返回值为(1 && 1).为什么会这样?我怎样才能解决这个问题?
这是一个类,所以它必须使用递归,我已经迭代地编写了一个工作代码,但我无法让它在递归中工作,我真的迷失了.我已经为此工作了一个星期.任何指导或建议都会非常有帮助.
这是我的函数,我需要将十六进制作为char指针并输出相应的十进制数.我经常遇到堆栈溢出或内存分配运行时错误,任何人都可以识别出错误并引导我朝着正确的方向前进吗?
int hexToDecimal(const char *hex, int offset, int power){
if(offset >= 0){
hexChar = *(hex+offset);
if( isalpha(hexChar) ) {
hexChar = toupper(hexChar);
hexNum = hexChar - asciiCharOffset;
} else {
hexNum = hexChar - asciiIntOffset;
}
return hexToDecimal(hex, offset--, power++) + hexNum * (int)pow(16,power);
} else {
return 0;
}
}
Run Code Online (Sandbox Code Playgroud) c# ×2
cortana ×2
javascript ×2
python ×2
typescript ×2
windows-10 ×2
c++ ×1
cpython ×1
database ×1
datagridview ×1
datatable ×1
ecmascript-6 ×1
graph-theory ×1
matlab ×1
matrix ×1
nlp ×1
octave ×1
onenote ×1
onenote-api ×1
python-3.x ×1
recursion ×1
scripting ×1
set ×1
sql-server ×1
uwp ×1
word2vec ×1