我有一个带有 label 和 tweets 的文本文件。
Run Code Online (Sandbox Code Playgroud)positive,I love this car negative,I hate this book positive,Good product.
我需要将每一行转换为向量值。如果我使用seq2sparse命令意味着整个文档被转换为向量,但我需要将每一行转换为向量而不是整个文档。ex : key : positive value : vectorvalue(tweet) 我们如何在 mahout 中实现这一点?
/* 这是我所做的 */
StringTokenizer str= new StringTokenizer(line,",");
String label=str.nextToken();
while (str.hasMoreTokens())
{
tweetline =str.nextToken();
System.out.println("Tweetline"+tweetline);
StringTokenizer words = new StringTokenizer(tweetline," ");
while(words.hasMoreTokens()){
featureList.add(words.nextToken());}
}
Vector unclassifiedInstanceVector = new RandomAccessSparseVector(tweetline.split(" ").length);
FeatureVectorEncoder vectorEncoder = new AdaptiveWordValueEncoder(label);
vectorEncoder.setProbes(1);
System.out.println("Feature List: "+featureList);
for (Object feature: featureList) {
vectorEncoder.addToVector((String) feature, unclassifiedInstanceVector);
}
context.write(new Text("/"+label), new VectorWritable(unclassifiedInstanceVector)); …Run Code Online (Sandbox Code Playgroud) 我有以下 Unix shell 脚本。我想将其转换为 Windows.bat文件(我知道我可以使用 Cygwin 而不是使其适应 Windows 环境。但 Cygwin 不是我的选择)。
我知道我可以在线使用 Windows PowerShell 阅读材料。但我不想为了这一一次性要求而花费数小时在线学习基础知识。请不要因为我懒惰而抨击我。我相信这对其他人也有帮助,因为它可以成为将来在线搜索的人的快速指南。
这是脚本:
#!/bin/bash
echo ""
cat $1 | grep -A4 "Device_name"; echo ""
cat $1 | grep -A45 "Device_Oops"; echo ""
cat $1 | grep -A150 "Processes:" | sed '/Radar/q'; echo ""
cat $1 | grep -E '[0-9][0-9]:[0-9][0-9]:[0-9][0-9]' | grep -i -E 'error|restart'
Run Code Online (Sandbox Code Playgroud)
要回答有关我尝试过的问题的问题,我在运行“ find”命令时遇到了麻烦,该命令相当于grep本网站http://tldp.org/LDP/abs/html/dosbatch.html
这是我的Joy.txt文件(接下来的两行):
Device_name router@home
testing only
Run Code Online (Sandbox Code Playgroud)
然后在 PowerShell 提示符下,我运行了以下命令:
cat Joy.txt | find "Device_name" …Run Code Online (Sandbox Code Playgroud) 我试图选择已知目录中的所有.txt文件.例如,我知道路径:C:/../ Desktop /现在我想要获取桌面上的所有.txt文件.
那么我应该使用哪个regularExpression以及如何搜索它?关于java,我不太了解knowlegde.如果你帮助我,我会很开心.
String regularExpression = ?
String path = "C:/../Desktop/";
Pattern pattern = Pattern.compile(regularExpression);
boolean isMatched = Pattern.matches(regularExpression,path);
Run Code Online (Sandbox Code Playgroud)