本文整理汇总了C#中System.String.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# String.ToList方法的具体用法?C# String.ToList怎么用?C# String.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.String
的用法示例。
在下文中一共展示了String.ToList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public static void Run (Action<List<String>> fx, String[] args) {
try {
ExitCode=ExitCodes.InitError; App.Init();
ExitCode=ExitCodes.FxError; fx(args.ToList());
ExitCode=ExitCodes.ExitError; App.Exit();
} catch (Exception ex) {
App.Crash(ex);
}
}
示例2: FileStructure
public FileStructure(String[] rootFolders, List<StorageInformation> info)
{
if (_Index == null)
_Index = new FileStructure();
_Index.IndexRoots = new List<RootFolder>();
_Index.algo = new UploadAlgorithm(info);
_Index.InstantiateIndex(rootFolders.ToList<String>());
}
示例3: complexity
public int complexity(String s)
{
Sequitur alg = new Sequitur();
List<String> strings = new List<string>();
s.ToList().ForEach(c => strings.Add(c.ToString()));
alg.Evaluate(strings);
HashSet<Rule> rl = alg.getRules();
int symbol_leght = 1; // start rule
rl.ToList().ForEach(r => symbol_leght += r.Symbols.Count);
return symbol_leght;
}
示例4: CreateNode
public static svm_node[] CreateNode(string x, IReadOnlyList<string> vocabulary)
{
var node = new List<svm_node>(vocabulary.Count);
int sum = 0;
List<string> allWords = new List<string>();
x = x.Replace(",", "");
Bigram b = new Bigram();
String[] stopwords = new String[] { "hon.", "gentleman", "member", "friend", "lady", "a", "about", "above", "above", "across", "after", "afterwards", "again", "against", "all", "almost", "alone", "along", "already", "also", "although", "always", "am", "among", "amongst", "amoungst", "amount", "an", "and", "another", "any", "anyhow", "anyone", "anything", "anyway", "anywhere", "are", "around", "as", "at", "back", "be", "became", "because", "become", "becomes", "becoming", "been", "before", "beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "bill", "both", "bottom", "but", "by", "call", "can", "cannot", "cant", "co", "con", "could", "couldnt", "cry", "de", "describe", "detail", "do", "done", "down", "due", "during", "each", "eg", "eight", "either", "eleven", "else", "elsewhere", "empty", "enough", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly", "forty", "found", "four", "from", "front", "full", "further", "get", "give", "go", "had", "has", "hasnt", "have", "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "how", "however", "hundred", "i", "ie", "if", "in", "inc", "indeed", "interest", "into", "is", "it", "its", "itself", "keep", "last", "latter", "latterly", "least", "less", "ltd", "made", "many", "may", "me", "meanwhile", "might", "mill", "mine", "more", "moreover", "most", "mostly", "move", "much", "must", "my", "myself", "name", "namely", "neither", "never", "nevertheless", "next", "nine", "no", "nobody", "none", "noone", "nor", "not", "nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one", "only", "onto", "or", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "own", "part", "per", "perhaps", "please", "put", "rather", "re", "same", "see", "seem", "seemed", "seeming", "seems", "serious", "several", "she", "should", "show", "side", "since", "sincere", "six", "sixty", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "still", "such", "system", "take", "ten", "than", "that", "the", "their", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "thickv", "thin", "third", "this", "those", "though", "three", "through", "throughout", "thru", "thus", "to", "together", "too", "top", "toward", "towards", "twelve", "twenty", "two", "un", "under", "until", "up", "upon", "us", "very", "via", "was", "we", "well", "were", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "whoever", "whole", "whom", "whose", "why", "will", "with", "within", "without", "would", "yet", "you", "your", "yours", "yourself", "yourselves", "the" };
List<String> stop = stopwords.ToList<String>();
x = x.Replace(",", "");
x = x.ToLower();
String[] sp = x.Split(' ');
String sent = "";
for (int z = 0; z < sp.Length; z++)
{
String word = sp[z];
if (stop.Contains(word))
{
Debug.WriteLine("Stop Word");
}
else
{
sent += word;
sent += " ";
}
}
allWords = b.getNG(sent);
string[] words = allWords.ToArray();
for (int i = 0; i < vocabulary.Count; i++)
{
int occurenceCount = words.Count(s => String.Equals(s, vocabulary[i], StringComparison.OrdinalIgnoreCase));
if (occurenceCount == 0)
continue;
node.Add(new svm_node
{
index = i + 1,
value = occurenceCount
});
}
return node.ToArray();
}
示例5: dirReduc
public static string[] dirReduc(String[] arr)
{
List<string> directions = arr.ToList();
List<string> input = new List<string>();
for (int i = 0; i < directions.Count - 1; i++)
{
input = directions.GetRange(i, 2);
if (input.OrderBy(s => s).SequenceEqual(EWPair.OrderBy(t => t)))
{
directions.RemoveRange(i, 2);
directions = dirReduc(directions.ToArray()).ToList();
}
if (input.OrderBy(s => s).SequenceEqual(NSPair.OrderBy(t => t)))
{
directions.RemoveRange(i, 2);
directions = dirReduc(directions.ToArray()).ToList(); ;
}
}
return directions.ToArray();
}
示例6: Create
public ActionResult Create(PromotionCreateModel promotion)
{
String[] stringList = new String[50];
try
{
if (ModelState.IsValid)
{
if (!String.IsNullOrEmpty(promotion.Tags))
{
stringList = promotion.Tags.Split(',');
}
using (var unitOfWork = new UnitOfWork())
{
var promId = unitOfWork.InsertPromotionDetailsByUsername(promotion.Price,promotion.Description,promotion.StartDate,promotion.EndDate,User.Identity.Name);
if (promId.HasValue)
{
foreach (var s in stringList.ToList())
{
if (!String.IsNullOrEmpty(s))
{
var tag = s.Trim();
unitOfWork.InsertPromotionTag(promId, tag);
}
}
}
}
}
return RedirectToAction("Index");
}
catch(Exception ex)
{
return View();
}
}
示例7: findSequence
private static List<int> findSequence(String encodedText, String match)
{
int j = 0;
List<Char> encodedTextSequence = encodedText.ToList();
List<Char> matchTextSequence = match.ToList();
List<int> sequence = new List<int>();
while (sequence.Count < matchTextSequence.Count && j < encodedTextSequence.Count)
{
List<int> positions = matchTextSequence.Select((c, i) => new { character = c, index = i })
.Where(list => String.Compare(list.character.ToString(), encodedTextSequence[j].ToString(), true) == 0)
.Select(o => o.index).ToList();
foreach (int pos in positions)
{
if (!sequence.Contains(pos))
{
sequence.Add(pos);
break;
}
}
j++;
}
return sequence;
}
示例8: ImportData
//public bool ImportData(String[] fileNamesToImport,
// Guid? foreignKeyToConnectTo = null,
// MaterialJPGForeignKeyConnectorenTyp foreignKeyTypToConnectTo = null)
// {
// List<MaterialJPG> NewMaterialJPGList = ImportData(fileNamesToImport,
// SelectedKoordinatenSource, SelectedMaterialJPGTyp, true,
// foreignKeyToConnectTo, foreignKeyTypToConnectTo);
// return (NewMaterialJPGList != null);
// }
public List<MaterialJPG> ImportData(String[] fileNamesToImport, Ort selectedKoordinatenSource,
MaterialJPGTyp selectedMaterialJPGTyp, bool showProgressUI, Guid? foreignKeyToConnectTo = null,
MaterialJPGForeignKeyConnectorenTyp foreignKeyTypToConnectTo = null)
{
MaterialProgressDataModell ProgressModell = new MaterialProgressDataModell();
Window ProgressWindow = new Window();
if (showProgressUI)
{
ProgressModell = new MaterialProgressDataModell();
ProgressModell.InsertProgressEntries(fileNamesToImport.ToList());
ProgressWindow = new Window();
ProgressWindow.Title = "ImportData gestarted";
MaterialProgressView ProgressControl = new MaterialProgressView();
ProgressControl.MaterialProgressDataModellInstance = ProgressModell;
ProgressWindow.Content = ProgressControl;
ProgressWindow.Show();
}
List<MaterialJPG> Result = new List<MaterialJPG>();
ListOfFileNamesToImport = fileNamesToImport;
int Index = 0;
foreach (string fileNameToImport in ListOfFileNamesToImport)
{
if (showProgressUI)
ProgressModell.SetStatus(Index, "Gestarted");
MaterialJPG newMaterialRow = Data.DbServer3.Blob.MaterialienJPG.NewRow();
newMaterialRow.Id = Guid.NewGuid();
newMaterialRow.FullFileNameToLoadFrom = fileNameToImport.ToLower();
FileInfo fileInfo = new FileInfo(fileNameToImport);
newMaterialRow.Value = fileInfo.LoadAs_ByteArray();
newMaterialRow.HashCode = newMaterialRow.Value.Sha1Hash().ConvertTo_Hex();
newMaterialRow.ValueThumb = newMaterialRow.Value.ConvertTo_Image()
.ResizeToMaximum(300, 200).ConvertTo_JpgByteArray(80);
MaterialJPG[] EqualEntries = Data.DbServer3.Blob.MaterialienJPG.Load_AllForHashCode(newMaterialRow.HashCode);
if (EqualEntries.Length > 0)
{
//MessageBox.Show("Es gibt einen Eintrag mit gleichem HashCode\r\n" +
// "gespeichert ist derzeit der File:\r\n\""
// + EqualEntries[0].FullFileNameToLoadFrom + "\"\r\n" +
// "der folgende File soll importiert werden:\r\n\"" +
// newMaterialRow.FullFileNameToLoadFrom + "\"\r\n" +
// "Dieser Eintrag wird übersprungen!!");
if (showProgressUI)
{
ProgressModell.SetStatus(Index++, "Eintrag schon vorhanden");
}
Result.Add(EqualEntries[0]);
continue;
}
newMaterialRow.LastWriteFileTime = fileInfo.LastWriteTime;
newMaterialRow.TypId = selectedMaterialJPGTyp.Id;
newMaterialRow.WLaengeOrt = selectedKoordinatenSource.WLaenge;
newMaterialRow.WBreiteOrt = selectedKoordinatenSource.WBreite;
String NamePart = Path.GetFileName(Path.GetDirectoryName(fileNameToImport)) + "\\"
+ Path.GetFileName(fileNameToImport);
newMaterialRow.NameId = "Ort_" + fileInfo.LastWriteTime.ToString("yyyy-MM-dd_HH_mm") + "_" + NamePart;
newMaterialRow.Description = "Ort_" + selectedKoordinatenSource.Bezeichnung;
newMaterialRow.LastLoadTime = DateTime.Now;
newMaterialRow.PictureTakenDateTime = fileInfo.LastWriteTime;
Data.DbServer3.Blob.MaterialienJPG.Rows.Add(newMaterialRow);
Data.DbServer3.Blob.SaveAnabolic(true);
newMaterialRow.Value = null;
Data.DbServer3.Blob.AcceptChanges();
if (showProgressUI)
ProgressModell.SetStatus(Index++, "Eintrag gespeichert");
Result.Add(newMaterialRow);
}
if ((foreignKeyToConnectTo != null)
&& (foreignKeyTypToConnectTo != null))
{
if (showProgressUI)
{
ProgressModell.CompletionStatus = "Bilder registriert";
ProgressWindow.Title = "ImportData fertig, Die Daten werden jetzt verknüpft";
}
Index = 0;
foreach (MaterialJPG materialJPG in Result)
{
MaterialJPGForeignKeyConnector foreignConnector
= Data.DbServer3.Blob.MaterialJPGForeignKeyConnectoren.NewRow();
foreignConnector.Id = Guid.NewGuid();
foreignConnector.Description = materialJPG.Description;
foreignConnector.ForeignId = foreignKeyToConnectTo;
foreignConnector.JPGId = materialJPG.Id;
foreignConnector.TypId = foreignKeyTypToConnectTo.Id;
Data.DbServer3.Blob.MaterialJPGForeignKeyConnectoren.Rows.Add(foreignConnector);
Data.DbServer3.Blob.SaveAnabolic();
Data.DbServer3.Blob.AcceptChanges();
//.........这里部分代码省略.........
示例9: join
/**
* Joins array of strings to one string with glue
*
* @param what Array of string to join
* @param glue Glue for joined strings
* @return Joined string
*/
public static String join(String[] what, String glue)
{
return join(what.ToList(), glue);
}
示例10: button_AddClick
private void button_AddClick(object sender, EventArgs e)
{
String listboxname = "lbx" + tctrlSettings.TabPages[m_selectedTabIndex].Name;
String txtboxaddname = "tbxAdd" + tctrlSettings.TabPages[m_selectedTabIndex].Name + "Name";
String txtboxaddval = "tbxAdd" + tctrlSettings.TabPages[m_selectedTabIndex].Name + "Value";
ListBox lstBox = (ListBox)tctrlSettings.TabPages[m_selectedTabIndex].Controls.Find(listboxname, true)[0];
TextBox txtBoxAddname = (TextBox)tctrlSettings.TabPages[m_selectedTabIndex].Controls.Find(txtboxaddname, true)[0];
TextBox txtBoxAddvalue = (TextBox)tctrlSettings.TabPages[m_selectedTabIndex].Controls.Find(txtboxaddval, true)[0];
String attribute = tctrlSettings.TabPages[m_selectedTabIndex].Name;
String setting = "";
String value = "";
if (lstBox == null)
return;
if (txtBoxAddname == null)
return;
setting = txtBoxAddname.Text;
value = txtBoxAddvalue.Text;
m_iniFile.Add(attribute, setting, value);
lstBox.Items.Clear();
String[] array = new String[m_iniFile.Attributes[attribute].Keys.Count];
m_iniFile.Attributes[attribute].Keys.CopyTo(array, 0);
var list = array.ToList<String>();
list.Sort();
foreach (String key in list)
lstBox.Items.Add(key);
}
示例11: SendEmail
public bool SendEmail(string sentFrom, String[] sentTo, String[] ccList, string subject, ListDictionary replacements, string emailTemplateName)
{
string emailSendEnabledSetting = CommonUtils.GetAppSettingValue(CommonUtils.AppSettingKey.EmailSendEnabled);
if (emailSendEnabledSetting.ToLower() != "true")
{
mLog.Info("CMS setting 'SendEmailEnabled' is set to False. Exiting SendEmail() method.");
return false;
}
MailDefinition md = new MailDefinition();
md.Subject = subject;
md.From = sentFrom;
StringBuilder emailTemplate = new StringBuilder();
string filePath = GetMailDefinitionFilePath(emailTemplateName);
if (!File.Exists(filePath))
{
mLog.Error("Could not find html file for email named '{0}'.", filePath);
throw new FileNotFoundException(string.Format("Could not find html file for email named '{0}'.", filePath));
}
emailTemplate.Append(ReadEmailTemplate(filePath));
MailMessage message = md.CreateMailMessage(string.Join(",", sentTo), replacements, emailTemplate.ToString(), new System.Web.UI.Control());
message.IsBodyHtml = true;
//message.From = new MailAddress(sentFrom);
ccList.ToList().ForEach(message.CC.Add);
SmtpClient client = new SmtpClient();
client.Host = CommonUtils.GetAppSettingValue(CommonUtils.AppSettingKey.EmailMailHost);
try
{
//SEND!
string testEmail = CommonUtils.GetAppSettingValue(CommonUtils.AppSettingKey.EmailDefaultTest);
if (IsValidEmailaddress(testEmail))
{
InterceptEmail(message, testEmail);
}
mLog.Info("Sending email.{0}From = {1}{0}To = {2}{0}Cc = {3}{0}Host = {4}.",
Environment.NewLine, message.From, message.To, message.CC, client.Host);
mLog.Verbose("{0}", message.Body);
client.Send(message);
}
catch (Exception exception)
{
mLog.Error(exception.Message, exception, "Possible relay error");
if (exception.InnerException != null)
{
mLog.Error(exception.InnerException.Message, exception.InnerException, "Possible relay error inner exception.");
}
}
return true;
}
示例12: removeDuplicates
//Eliminating duplicates(if it contains in the file)
private String[] removeDuplicates(String[] arr)
{
List<String> list = arr.ToList();
list = list.Distinct().ToList();
return list.ToArray();
}
示例13: DoAccumulator
//.........这里部分代码省略.........
case "OR":
args = input[1].Split(new Char[] { '(', ')' });
OR(memoryPointer, int.Parse(args[0]));
instrucitonCount += 1;
break;
case "NOT":
NOT();
instrucitonCount += 1;
break;
case "XOR":
args = input[1].Split(new Char[] { '(', ')' });
XOR(memoryPointer, int.Parse(args[0]));
instrucitonCount += 1;
break;
case "JUMP":
int vsl;
if (int.TryParse(input[1],out vsl))
{
JUMP(vsl);
}
else
JUMP(input[1]);
instrucitonCount += 1;
break;
case "BZERO":
args = input[1].Split(new Char[] { '(', ')' });
BZERO(memoryPointer, int.Parse(args[0]));
referenceCount += 1;
instrucitonCount += 1;
break;
case "SEQ":
args = input[1].Split(new Char[] { '(', ')' });
SEQ(memoryPointer, int.Parse(args[0]));
instrucitonCount += 1;
break;
case "SNE":
args = input[1].Split(new Char[] { '(', ')' });
SNE(memoryPointer, int.Parse(args[0]));
instrucitonCount += 1;
break;
case "SGT":
args = input[1].Split(new Char[] { '(', ')' });
SGT(memoryPointer, int.Parse(args[0]));
instrucitonCount += 1;
break;
case "SLT":
args = input[1].Split(new Char[] { '(', ')' });
SLT(memoryPointer, int.Parse(args[0]));
instrucitonCount += 1;
break;
case "SGE":
args = input[1].Split(new Char[] { '(', ')' });
SGE(memoryPointer, int.Parse(args[0]));
instrucitonCount += 1;
break;
case "SLE":
args = input[1].Split(new Char[] { '(', ')' });
SLE(memoryPointer, int.Parse(args[0]));
instrucitonCount += 1;
break;
case "PUSH":
if (input.Length == 2)
{
args = input[1].Split(new Char[] { '(', ')' });
PUSH(memoryPointer, int.Parse(args[0]));
}
else
PUSH();
referenceCount += 1;
instrucitonCount += 1;
break;
case "POP":
POP();
referenceCount += 1;
instrucitonCount += 1;
break;
case "CALL":
args = input[1].Split(new Char[] { '(', ')' });
CALL(memoryPointer, int.Parse(args[0]));
referenceCount += 1;
instrucitonCount += 1;
break;
case "RET":
RET();
referenceCount += 1;
instrucitonCount += 1;
break;
default:
//Add the tag to if that is what it represents
if (input[0].Contains(":"))
{
List<string> tempInput = input.ToList();
tempInput.RemoveAt(0);
DoAccumulator(tempInput.ToArray());
break;
}
Console.WriteLine("An error has been found, cannot compute instruction at line {0}", currentCounter);
break;
}
}
示例14: Main
static void Main()
{
const string dataFilePath = @"C:\Users\Rory\Desktop\Han.csv";
List<String> negwords = new List<String>();
List<String> poswords = new List<String>();
sentC = new List<String>();
//String negFile = "C:/Users/Rory/Desktop/negative-words.txt";
//String posFile = "C:/Users/Rory/Desktop/positive-words.txt";
//GetNeg(negwords, negFile);
//GetNeg(poswords, posFile);
String[] stopwords = new String[]{"hon.","gentleman","member","friend","lady","a", "about", "above", "above", "across", "after", "afterwards", "again", "against", "all", "almost", "alone", "along", "already", "also","although","always","am","among", "amongst", "amoungst", "amount", "an", "and", "another", "any","anyhow","anyone","anything","anyway", "anywhere", "are", "around", "as", "at", "back","be","became", "because","become","becomes", "becoming", "been", "before", "beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "bill", "both", "bottom","but", "by", "call", "can", "cannot", "cant", "co", "con", "could", "couldnt", "cry", "de", "describe", "detail", "do", "done", "down", "due", "during", "each", "eg", "eight", "either", "eleven","else", "elsewhere", "empty", "enough", "etc", "even", "ever", "every", "everyone", "everything", "everywhere", "except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly", "forty", "found", "four", "from", "front", "full", "further", "get", "give", "go", "had", "has", "hasnt", "have", "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers", "herself", "him", "himself", "his", "how", "however", "hundred", "i","ie", "if", "in", "inc", "indeed", "interest", "into", "is", "it", "its", "itself", "keep", "last", "latter", "latterly", "least", "less", "ltd", "made", "many", "may", "me", "meanwhile", "might", "mill", "mine", "more", "moreover", "most", "mostly", "move", "much", "must", "my", "myself", "name", "namely", "neither", "never", "nevertheless", "next", "nine", "no", "nobody", "none", "noone", "nor", "not", "nothing", "now", "nowhere", "of", "off", "often", "on", "once", "one", "only", "onto", "or", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "own","part", "per", "perhaps", "please", "put", "rather", "re", "same", "see", "seem", "seemed", "seeming", "seems", "serious", "several", "she", "should", "show", "side", "since", "sincere", "six", "sixty", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "still", "such", "system", "take", "ten", "than", "that", "the", "their", "them", "themselves", "then", "thence", "there", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "thickv", "thin", "third", "this", "those", "though", "three", "through", "throughout", "thru", "thus", "to", "together", "too", "top", "toward", "towards", "twelve", "twenty", "two", "un", "under", "until", "up", "upon", "us", "very", "via", "was", "we", "well", "were", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby", "wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "whoever", "whole", "whom", "whose", "why", "will", "with", "within", "without", "would", "yet", "you", "your", "yours", "yourself", "yourselves", "the"};
List<String> stop = stopwords.ToList<String>();
var dataTable = DataTable.New.ReadCsv(dataFilePath);
List<string> x = dataTable.Rows.Select(row => row["Text"]).ToList();
double[] y = dataTable.Rows.Select(row => double.Parse(row["IsPos"])).ToArray();
//var vocab = x.SelectMany(GetWords).Distinct().OrderBy(word => word).ToList();
Bigram b = new Bigram();
List<String> v = new List<string>();
String sent = "";
for(int i = 0; i < x.Count; i++)
{
String c = x[i].ToString();
c = c.Replace(",", "");
c = c.ToLower();
String[] sp = c.Split(' ');
for (int z = 0; z < sp.Length; z++)
{
String word = sp[z];
if(stop.Contains(word))
{
Debug.WriteLine("Stop Word");
}
else
{
sent += word;
sent += " ";
}
}
sent = sent.Trim();
v.AddRange(b.getNG(sent));
sent = "";
}
// int bound = v.Count();
//v.AddRange(negwords);
// int nBound = v.Count();
//v.AddRange(poswords);
// v = v.Distinct().ToList();
var problemBuilder = new TextClassificationProblemBuilder();
var problem = problemBuilder.CreateProblem(x, y, v);
ProblemHelper.WriteProblem(@"C:\Users\Rory\Desktop\hanData.problem", problem);
problem = ProblemHelper.ReadProblem(@"C:\Users\Rory\Desktop\hanData.problem");
const int C = 1;
var model = new C_SVC(problem, KernelHelper.LinearKernel(), C);
var accuracy = model.GetCrossValidationAccuracy(10);
Console.WriteLine("Accuracy of the model is {0:P}", accuracy);
string userInput;
_predictionDictionary = new Dictionary<int, string> { { -1, "Negative" }, { 1, "Positive" } };
getSent();
for (int i = 0; i < nText.Count; i++)
{
userInput = nText[i].ToString();
var newX = TextClassificationProblemBuilder.CreateNode(userInput, v);
var predictedY = model.Predict(newX);
Console.WriteLine("The prediction is {0}", _predictionDictionary[(int)predictedY]);
String pred = _predictionDictionary[(int)predictedY];
Console.WriteLine(new string('=', 50));
sentC.Add(pred);
}
addToO();
getNumbers();
forPeople();
using(StreamWriter file = new StreamWriter(@"C:\Users\Rory\Desktop\Peop.csv"))
{
file.WriteLine("PersID,Name,Positive,Negative,Party");
for(int i = 0; i < pl.Count; i++)
{
String line = pl[i].getID().ToString() + "," + pl[i].getName().ToString() + "," + pl[i].getPos().ToString() + "," + pl[i].getNeg().ToString() + "," + pl[i].getParty().ToString();
//var json = JsonConvert.SerializeObject(pl[i]);
file.WriteLine(line);
}
}
using (StreamWriter file = new StreamWriter(@"C:\Users\Rory\Desktop\PositiveSent.csv"))
//.........这里部分代码省略.........
示例15: String_Array_Push
public static String[] String_Array_Push(String[] _input,string item)
{
List<string> temp = _input.ToList();
temp.Add(item);
return temp.ToArray();
}