官术网_书友最值得收藏!

The FeatureExtractor class

This newly added class provides our feature extraction for the given folder of filesOnce extraction is complete, the classification and strings data is written out to the sampledata file:

using System;
using System.IO;

using chapter03_logistic_regression.Common;
using chapter03_logistic_regression.ML.Base;

namespace chapter03_logistic_regression.ML
{
public class FeatureExtractor : BaseML
{
public void Extract(string folderPath)
{
var files = Directory.GetFiles(folderPath);

using (var streamWriter =
new StreamWriter(Path.Combine(AppContext.BaseDirectory, $"../../../Data/{Constants.SAMPLE_DATA}")))
{
foreach (var file in files)
{
var strings = GetStrings(File.ReadAllBytes(file));

streamWriter.WriteLine($"{file.ToLower().Contains("malicious")}\t{strings}");
}
}

Console.WriteLine($"Extracted {files.Length} to {Constants.SAMPLE_DATA}");
}
}
}
主站蜘蛛池模板: 乐至县| 怀仁县| 顺昌县| 日照市| 曲沃县| 凤冈县| 盱眙县| 桓仁| 万宁市| 芦溪县| 富蕴县| 鲁甸县| 大余县| 西充县| 手游| 石棉县| 出国| 黑水县| 丰原市| 新巴尔虎左旗| 民和| 略阳县| 湛江市| 荥经县| 三门峡市| 花垣县| 申扎县| 日土县| 积石山| 阜平县| 禄劝| 孝义市| 深水埗区| 河东区| 南川市| 锡林浩特市| 宣化县| 盐城市| 瓦房店市| 永城市| 盘山县|