private void LoadTrainnedFace() { try { LabelList.Clear(); TrainingImages.Clear(); // Load haarcascades for face detection Face = new HaarCascade("haarcascade_frontalface_default.xml"); // Load the number of trained faces var files = GetAllFiles(Application.StartupPath + "/TrainedFaces"); TrainedFacesCounter = files.Count; foreach (var file in files) { TrainingImages.Add(new Image <Gray, byte>(file.FullName)); LabelList.Add(file.Name.Split('@')[0]); } } catch { // By pass } }
//This will calculate the errors //first it must ask what column to use as a label private void externalEvalCalculateButton_Click(object sender, EventArgs e) { //start by parsing label file DelimitedFile delimitedLabelFile = new DelimitedFile(externalEvalLabelText.Text); int labelCol = Prompt.ShowDialog("Enter the Column to use", "Select Attribute", 1, delimitedLabelFile.Data[0].Length); LabelList labels = new LabelList(delimitedLabelFile.GetColumn(labelCol - 1)); //get the Partion file Partition clusterFile = new Partition(externalEvalClusterText.Text); int countOfPoints = clusterFile.DataCount; //create a count mapping //[actual cluster label, number in found clusters] int[,] clusterMatching = new int[labels.UniqueLabels.Count, clusterFile.Clusters.Count]; foreach (Cluster c in clusterFile.Clusters) { foreach (ClusteredItem k in c.Points) { int actualMatching = labels.LabelIndices[k.Id]; int foundMatching = k.ClusterId; clusterMatching[actualMatching, foundMatching]++; } } //One-To-One Mapping like Darla's String greedyError = ExternalEval.GreedyErrorEval(clusterFile, labels, clusterMatching); externalEvalResultText.Text = greedyError; }
protected List <string> ExtractLabelSymbols(CommandBlock lBlock) { var ltemplateLabels = new List <string>(); Match lMatch = LabelList.Match(lBlock.lines[0]); if (lMatch.Success) { if (templateLabels != null) { mError = true; Console.WriteLine("ERROR: Template Block Already has template labels : " + lBlock.filePath + " on line : ", lBlock.lines[0]); return(null); } else { var lMatches = ExtractLabels.Matches(lMatch.Groups[1].Value); for (int i = 0; i < lMatches.Count; ++i) { ltemplateLabels.Add(lMatches[i].Groups[0].Value); } } } else { mError = true; Console.WriteLine("ERROR: Failed to pass block : " + lBlock.lines[0]); return(null); } return(ltemplateLabels); }
public void CreateNPCLabel(string word, int wordOrder) { TempLabel = null; for (int i = 0; i < LabelList.Count; i++) { if (LabelList[i].Text != word || LabelList[i].ForeColour != (wordOrder == 0 ? NameColour : Color.White)) { continue; } TempLabel = LabelList[i]; break; } if (TempLabel != null && !TempLabel.IsDisposed) { return; } TempLabel = new MirLabel { AutoSize = true, BackColour = Color.Transparent, ForeColour = wordOrder == 0 ? NameColour : Color.White, OutLine = true, OutLineColour = Color.Black, Text = word, }; TempLabel.Disposing += (o, e) => LabelList.Remove(TempLabel); LabelList.Add(TempLabel); }
private double CalculateNMI() { var total = ComparisonList.Count; var Bg = LabelList.Max(x => int.Parse(x.EventId)) + 1; var Rg = ResultList.Max(x => x.ClusterId) + 1; var matrix = Matrix <double> .Build.Dense(Bg, Rg, 0); //var matrix = new int[this.LabelList.Max(x => int.Parse(x.EventId)), this.ResultList.Max(x => x.ClusterId)]; ComparisonList.ForEach(x => matrix[x.Item1, x.Item2] += 1d / total); var mi = 0d; for (int i = 0; i < Bg; i++) { for (int j = 0; j < Rg; j++) { if (matrix[i, j] == 0) { continue; } mi += (double)matrix[i, j] * Math.Log(matrix[i, j] / (matrix.Row(i).Sum() * matrix.Column(j).Sum())); } } var hx = -matrix.RowSums().ToArray().Sum(x => x != 0 ? (double)x * Math.Log((double)x) : 0); var hy = -matrix.ColumnSums().ToArray().Sum(y => y != 0 ? (double)y * Math.Log((double)y) : 0); return(2 * mi / (hx + hy)); }
public override void CreateLabel() { base.CreateLabel(); OwnerLabel = null; string ownerText = $"{OwnerName}'s Hero"; for (int i = 0; i < LabelList.Count; i++) { if (LabelList[i].Text != ownerText || LabelList[i].ForeColour != NameColour) { continue; } OwnerLabel = LabelList[i]; break; } if (OwnerLabel != null && !OwnerLabel.IsDisposed) { return; } OwnerLabel = new MirLabel { AutoSize = true, BackColour = Color.Transparent, ForeColour = NameColour, OutLine = true, OutLineColour = Color.Black, Text = ownerText, }; OwnerLabel.Disposing += (o, e) => LabelList.Remove(OwnerLabel); LabelList.Add(OwnerLabel); }
public void CreateGameField() { GameTiles = new List <List <Image> >(); for (int i = 0; i < 4; i++) { GameTiles.Add(new List <Image>()); } foreach (var LabelList in GameTiles) { for (int i = 0; i < 4; i++) { LabelList.Add(new Image() { BackgroundColor = Color.Gray, }); } } int c = 0; int b = 0; foreach (var LabelList in GameTiles) { foreach (var Label in LabelList) { GameGrid.Children.Add(Label, b, c); c++; } c = 0; b++; } }
private void CreateLabel(Color backColour, bool border, bool outline) { NameLabel = null; for (int i = 0; i < LabelList.Count; i++) { if (LabelList[i].Text != Name || LabelList[i].Border != border || LabelList[i].BackColour != backColour || LabelList[i].ForeColour != NameColour || LabelList[i].OutLine != outline) { continue; } NameLabel = LabelList[i]; break; } if (NameLabel != null && !NameLabel.IsDisposed) { return; } NameLabel = new MirControls.MirLabel { AutoSize = true, BorderColour = Color.Black, BackColour = backColour, ForeColour = NameColour, OutLine = outline, Border = border, Text = Regex.Replace(Name, @"\d+$", string.Empty), }; LabelList.Add(NameLabel); }
public ExternalEval(Partition clusterFile, LabelList labels) { P = clusterFile; L = labels; Matches = new List <GroundTruthMatch>(); int[,] clusterMatching = labels.GetMatching(clusterFile); GreedyErrorEval(clusterMatching); }
public void Dependencies() { foreach (var op in _ops) { op.Init(this, _optionId++); } HandlerList = new LabelList(_opHandlers.ToArray()); }
static void Main() { Console.WriteLine("Monadically labeled List:"); var list = new[] { "C#", "F#", "Haskell", "Clojure" }; var labeledList = LabelList.Label(list, new StateMonad <char, char>(s => StateContentPair.Create((char)(s + 1), s)), 'a'); labeledList.ToList().ForEach(Console.WriteLine); }
public Catalog() { countryList = new CountryList(); labelList = new LabelList(); aviaCompanyList = new AviaCompanyList(); aviaCompanyUnionList = new AviaCompanyUnionList(); personList = new PersonList(); countryUnionList = new CountryUnionList(); }
//[Dependencies] public void OptionModules() { _opHandlers = new List <Label>() { LabelFor(Handler_NOP), LabelFor(Handler_Stop), LabelFor(Handler_EOF), }; _optionId = (U8)(_opHandlers.Count); if (_options.Contains(Option.Addr)) { Address = new Ops.Address(AddHandler, _liveQueue, _executeLoopContinue, _executeLoopBreak); Include.Module(Address); } if (_options.Contains(Option.CallSub)) { CallSub = new Ops.CallSub(AddHandler, _liveQueue, _executeLoopContinue, _executeLoopBreak); Include.Module(CallSub); } if (_options.Contains(Option.Increment)) { Increment = new Ops.Increment(AddHandler, _liveQueue, _executeLoopContinue, _executeLoopBreak); Include.Module(Increment); } if (_options.Contains(Option.Pause)) { Pause = new Ops.Pause(AddHandler, _liveQueue, _executeLoopContinue, _executeLoopBreak); Include.Module(Pause); } if (_options.Contains(Option.Tile)) { Tile = new Ops.Tile(AddHandler, _liveQueue, _executeLoopContinue, _executeLoopBreak); Include.Module(Tile); } if (_options.Contains(Option.TileArray)) { TileArray = new Ops.TileArray(AddHandler, _liveQueue, _executeLoopContinue, _executeLoopBreak); Include.Module(TileArray); } if (_options.Contains(Option.TilesRLE)) { TilesRLE = new Ops.TilesRLE(AddHandler, _liveQueue, _executeLoopContinue, _executeLoopBreak); Include.Module(TilesRLE); } if (_options.Contains(Option.FromAddress)) { FromAddress = new Ops.FromAddress(AddHandler, _liveQueue, _executeLoopContinue, _executeLoopBreak); Include.Module(FromAddress); } if (_options.Contains(Option.Palettes)) { Palettes = new Ops.Palettes(AddHandler, _liveQueue, _executeLoopContinue, _executeLoopBreak); Include.Module(Palettes); } HandlerList = new LabelList(_opHandlers.ToArray()); }
public static String GreedyErrorEval(Partition clusterFile, LabelList labels, int[,] clusterMatching) { int truthCount = labels.UniqueLabels.Count; int partitionCount = clusterFile.Clusters.Count; int[] assigned = new int[truthCount]; bool[] ourCIsAssigned = new bool[partitionCount]; for (int i = 0; i < partitionCount; i++) { ourCIsAssigned[i] = false; } int sumCorrect = 0; StringBuilder sb = new StringBuilder(); //for each real cluster, assign the best of our clusters that hasn't //already been assigned for (int realC = 0; realC < truthCount; realC++) { int assignedClust = 0; for (int ourC = 0; ourC < partitionCount; ourC++) { int num = clusterMatching[realC, ourC]; if (assigned[realC] < num && !ourCIsAssigned[ourC]) { assigned[realC] = num; assignedClust = ourC; } } int sumRealC = 0; for (int i = 0; i < partitionCount; i++) { sumRealC += clusterMatching[realC, i]; } if (assigned[realC] == 0) { sb.AppendFormat("Label {0} was not assigned", labels.UniqueLabels[realC]); } else { ourCIsAssigned[assignedClust] = true; sb.AppendFormat("Cluster {0} Assigned to Label {1} Accuracy: ({2}/{3}) {4}%", assignedClust, labels.UniqueLabels[realC], assigned[realC], sumRealC, 100.0 * (double)assigned[realC] / (double)sumRealC); } sb.AppendLine(); sumCorrect += assigned[realC]; } sb.AppendFormat("Total Accuracy: ({0}/{1}) {2}%", sumCorrect, clusterFile.DataCount, 100.0 * (double)sumCorrect / (double)clusterFile.DataCount); sb.AppendLine(); return(sb.ToString()); }
public void LabelListTest() { DockingService_Accessor target = new DockingService_Accessor(); // TODO: Initialize to an appropriate value LabelList expected = null; // TODO: Initialize to an appropriate value LabelList actual; target.LabelList = expected; actual = target.LabelList; Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
private void Init() { this.listFields = new List<IListField>(); #region "List Inits" this.listFields.Add(new BoundsList("Bounds list")); this.listFields.Add(new ColorList("Color List")); this.listFields.Add(new CurveList("Curve List")); this.listFields.Add(new DelayedFloatList("Delayed Float List")); this.listFields.Add(new DelayedIntList("Delayed Int List")); this.listFields.Add(new DelayedTextList("Delayed Text List")); this.listFields.Add(new DoubleList("Double List")); this.listFields.Add(new FloatList("Float List")); this.listFields.Add(new IntList("Int List")); this.listFields.Add(new LayerList("Layer List")); this.listFields.Add(new MaskList("Mask List")); this.listFields.Add(new ObjectList<GameObject>("GameObject List")); this.listFields.Add(new PasswordList("Password List")); this.listFields.Add(new RectList("Rect List")); this.listFields.Add(new TagList("Tag List")); this.listFields.Add(new TextList("Text List")); this.listFields.Add(new Vector2List("Vector2 List")); this.listFields.Add(new Vector3List("Vector3 List")); this.listFields.Add(new Vector4List("Vector4 List")); var label = new LabelList("Label List", new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>("Key1", "Value1"), new KeyValuePair<string, string>("Key2", "Value2") }) { ShowCountField = false }; label.SetCount(2); this.listFields.Add(label); ExampleObj example = null; var select = Selection.activeGameObject; if(select != null && (example = select.GetComponent<ExampleObj>()) != null) { this.serialized = new SerializedObject(example); var property = new PropertyList("Property List", true, new List<SerializedProperty>() { this.serialized.FindProperty("Vec3"), this.serialized.FindProperty("Str"), this.serialized.FindProperty("List") }) { ShowCountField = false }; property.SetCount(3); this.listFields.Add(property); } #endregion }
public static double RandIndex(String labelFile, String clusterFileName) { //CALCULATING THE RAND INDEX //start by parsing label file DelimitedFile delimitedLabelFile = new DelimitedFile(labelFile); int labelCol = delimitedLabelFile.Data[0].Length; LabelList labels = new LabelList(delimitedLabelFile.GetColumn(labelCol - 1)); //get the Partion file Partition clusterFile = new Partition(clusterFileName); int[] assignments = new int[labels.LabelIndices.Length]; for (int cluster = 0; cluster < clusterFile.Clusters.Count; cluster++) { for (int j = 0; j < clusterFile.Clusters[cluster].Points.Count; j++) { int clusterid = clusterFile.Clusters[cluster].Points[j].ClusterId; int id = clusterFile.Clusters[cluster].Points[j].Id; assignments[id] = clusterid; } } // compare two arrays, assigments and labels.LabelIndices int a = 0; int b = 0; for (int i = 0; i < assignments.Length; i++) { for (int j = i + 1; j < assignments.Length; j++) { //Check for case a -> i and j are in same cluster in assignments and LabelIndices if (labels.LabelIndices[i] == labels.LabelIndices[j] && assignments[i] == assignments[j]) { a++; } else if (labels.LabelIndices[i] != labels.LabelIndices[j] && assignments[i] != assignments[j]) { b++; } } } int denominator = assignments.Length * (assignments.Length - 1) / 2; double randIndex = (a + b) / (double)denominator; //return "Group A: " + a + " Group B: " + b + " RandIndex: " + randIndex; return(randIndex); }
//This will calculate the errors //first it must ask what column to use as a label private void externalEvalCalculateButton_Click(object sender, EventArgs e) { //start by parsing label file DelimitedFile delimitedLabelFile = new DelimitedFile(externalEvalLabelText.Text); int labelCol = Prompt.ShowDialog("Enter the Column to use", "Select Attribute", 1, delimitedLabelFile.Data[0].Length); LabelList labels = new LabelList(delimitedLabelFile.GetColumn(labelCol - 1)); //get the Partion file Partition clusterFile = new Partition(externalEvalClusterText.Text); //Calculate the Error ExternalEval error = new ExternalEval(clusterFile, labels); externalEvalResultText.Text = error.TextResults; }
public BulkMapping() { rawPassportList = new RawBulkDataList <RawBulkPassport>(); rawPassportList.Width = RawBulkPassport.Width; rawPassportList.StoredFileName = "Passport"; rawPersonList = new RawBulkDataList <RawBulkPerson>(); rawPersonList.Width = RawBulkPerson.Width; rawPersonList.StoredFileName = "Person"; rawPersonList.StartCell = "H2"; rawMileCardList = new RawBulkDataList <RawBulkMileCard>(); rawMileCardList.Width = RawBulkMileCard.Width; rawMileCardList.StoredFileName = "MileCard"; rawCompanyList = new RawBulkDataList <RawBulkCompany>(); rawCompanyList.Width = RawBulkCompany.Width; rawCompanyList.StoredFileName = "Company"; rawPassportList.StatusUpdated += OnListUpdated; rawPersonList.StatusUpdated += OnListUpdated; rawMileCardList.StatusUpdated += OnListUpdated; rawCompanyList.StatusUpdated += OnListUpdated; dict = new Dictionary <RawFileType, IRawBulkDataList>(); dict.Add(RawFileType.passport, rawPassportList); dict.Add(RawFileType.person, rawPersonList); dict.Add(RawFileType.milecard, rawMileCardList); dict.Add(RawFileType.company, rawCompanyList); string labelName = "Unverified"; LabelList labelList = new LabelList(); labelList.Load(); labelUnverified = labelList.Find(item => item.Name == labelName); if (labelUnverified == null) { labelUnverified = labelList.Create(); labelUnverified.Name = labelName; labelUnverified.Save(); } }
public static double Purity(String labelFile, String clusterFileName) { //start by parsing label file DelimitedFile delimitedLabelFile = new DelimitedFile(labelFile); int labelCol = delimitedLabelFile.Data[0].Length; LabelList labels = new LabelList(delimitedLabelFile.GetColumn(labelCol - 1)); //get the Partion file Partition clusterFile = new Partition(clusterFileName); int[] majority = new int[clusterFile.Clusters.Count]; for (int cluster = 0; cluster < clusterFile.Clusters.Count; cluster++) { int[] assignments = new int[labels.UniqueLabels.Count]; for (int j = 0; j < clusterFile.Clusters[cluster].Points.Count; j++) { int clusterid = clusterFile.Clusters[cluster].Points[j].ClusterId; int id = clusterFile.Clusters[cluster].Points[j].Id; assignments[labels.LabelIndices[id]]++; } // now find the max of assignments int maxAssign = 0; for (int k = 0; k < assignments.Length; k++) { if (assignments[k] > maxAssign) { maxAssign = assignments[k]; } } majority[cluster] = maxAssign; } // add up majority[] and divide by number of vertices int total = 0; for (int i = 0; i < majority.Length; i++) { total += majority[i]; } return((double)total / labels.LabelIndices.Length); }
public void InitPanels(WabbitcodeStatusBar statusBar) { StatusBar = new WabbitcodeStatusBarService(this, statusBar); //Init Normal Panels LabelList = new LabelList(); LabelList.Show(DockManager, AnchorStyle.Right); ProjectViewer = new ProjectViewer(); ProjectViewer.Show(DockManager, AnchorStyle.Left); OutputWindow = new OutputWindow(); OutputWindow.Show(DockManager, AnchorStyle.Bottom); ErrorList = new ErrorList(); ErrorList.Show(DockManager, AnchorStyle.Bottom); if (File.Exists(pathsService.DockConfig)) { try { DockManager.RestoreLayout(pathsService.DockConfig); } catch (Exception) { } } IDocumentService documentService = ServiceFactory.Instance.GetServiceInstance <DocumentService>(); try { DocumentContent[] docs = new DocumentContent[Documents.Count]; Documents.CopyTo(docs, 0); foreach (Editor doc in docs) { documentService.OpenDocument(doc); } } catch (Exception ex) { ShowError("Error restoring documents", ex); } }
public static String CheckForNoise(String labelFile, String clusterFileName) { // need to calculate ns, ms and cs, as described in Yang and Leskovec ICDM2012 //start by parsing label file DelimitedFile delimitedLabelFile = new DelimitedFile(labelFile); int labelCol = delimitedLabelFile.Data[0].Length; LabelList labels = new LabelList(delimitedLabelFile.GetColumn(labelCol - 1)); //get the Partion file Partition clusterFile = new Partition(clusterFileName); int[] assignments = new int[labels.LabelIndices.Length]; // initialize assignments array to -1 // ultimately, nodes that have been removed as part of a critical attack set will stay at -1 assignment for (int i = 0; i < assignments.Length; i++) { assignments[i] = -1; } int noiseThreshold; //if (assignments.Length == 550) noiseThreshold = 500; //else if (assignments.Length == 770) noiseThreshold = 700; //else noiseThreshold = 1100; if (assignments.Length == 220) { noiseThreshold = 200; } else if (assignments.Length == 440) { noiseThreshold = 400; } else { noiseThreshold = 800; } for (int cluster = 0; cluster < clusterFile.Clusters.Count; cluster++) { for (int j = 0; j < clusterFile.Clusters[cluster].Points.Count; j++) { int clusterid = clusterFile.Clusters[cluster].Points[j].ClusterId; int id = clusterFile.Clusters[cluster].Points[j].Id; assignments[id] = clusterid; } } int[] ns = new int[clusterFile.Clusters.Count]; int[] ms = new int[clusterFile.Clusters.Count]; int[] cs = new int[clusterFile.Clusters.Count]; Boolean[] isAllNoise = new Boolean[clusterFile.Clusters.Count]; // if we're doing this without reassign, we need new nodes and edges valuse int edges = 0; int nodes = 0; for (int cluster = 0; cluster < clusterFile.Clusters.Count; cluster++) { ns[cluster] = clusterFile.Clusters[cluster].Points.Count; isAllNoise[cluster] = true; for (int j = 0; j < clusterFile.Clusters[cluster].Points.Count; j++) // for each vertex in this cluster { nodes++; if (clusterFile.Clusters[cluster].Points[j].Id < noiseThreshold) { isAllNoise[cluster] = false; } for (int k = 0; k < clusterFile.Graph.Nodes[clusterFile.Clusters[cluster].Points[j].Id].Edge.Length; k++) // for each edge k adjacent to j { edges++; int edge = clusterFile.Graph.Nodes[clusterFile.Clusters[cluster].Points[j].Id].Edge[k]; if (cluster == assignments[edge]) { ms[cluster]++; //if (cluster == 7) Console.WriteLine("ms " + edge); } else { cs[cluster]++; //if (cluster == 7) Console.WriteLine("cs " + edge); } } } } String report = ""; double[] internalDensity = new double[clusterFile.Clusters.Count]; double[] averageDegree = new double[clusterFile.Clusters.Count]; double[] expansion = new double[clusterFile.Clusters.Count]; double[] cutRatio = new double[clusterFile.Clusters.Count]; double[] conductance = new double[clusterFile.Clusters.Count]; double[] separability = new double[clusterFile.Clusters.Count]; double WAinternalDensity = 0; double WAaverageDegree = 0; double WAexpansion = 0; double WAcutRatio = 0; double WAconductance = 0; double WAseparability = 0; for (int cluster = 0; cluster < clusterFile.Clusters.Count; cluster++) { double totalPossibleInternalEdges = ((ns[cluster] * (ns[cluster] - 1)) / 2); internalDensity[cluster] = totalPossibleInternalEdges == 0 ? 0 : (double)ms[cluster] / totalPossibleInternalEdges; averageDegree[cluster] = 2.0 * ms[cluster] / ns[cluster]; expansion[cluster] = (double)cs[cluster] / ns[cluster]; cutRatio[cluster] = (double)cs[cluster] / (ns[cluster] * (assignments.Length - ns[cluster])); conductance[cluster] = (double)cs[cluster] / (2 * ms[cluster] + cs[cluster]); separability[cluster] = (double)ms[cluster] / cs[cluster]; } for (int cluster = 0; cluster < clusterFile.Clusters.Count; cluster++) { WAinternalDensity += internalDensity[cluster] * ns[cluster]; WAaverageDegree += averageDegree[cluster] * ns[cluster]; WAexpansion += expansion[cluster] * ns[cluster]; WAcutRatio += cutRatio[cluster] * ns[cluster]; WAconductance += conductance[cluster] * ns[cluster]; WAseparability += separability[cluster] * ns[cluster]; } WAinternalDensity /= (double)nodes; WAaverageDegree /= (double)nodes; WAexpansion /= (double)nodes; WAcutRatio /= (double)nodes; WAconductance /= (double)nodes; WAseparability /= (double)nodes; for (int cluster = 0; cluster < clusterFile.Clusters.Count; cluster++) { report += clusterFileName.Substring(clusterFileName.LastIndexOf('\\') + 1) + "," + cluster + "," + (isAllNoise[cluster] ? 1 : 0) + "," + ns[cluster] + "," + ms[cluster] + "," + cs[cluster] + "," + internalDensity[cluster] + "," + internalDensity.Min() + "," + WAinternalDensity + "," + internalDensity.Max() + //"," + averageDegree[cluster] + "," + averageDegree.Min() + "," + averageDegree.Average() + "," + averageDegree.Max() + "," + averageDegree[cluster] + "," + averageDegree.Min() + "," + WAaverageDegree + "," + averageDegree.Max() + "," + expansion[cluster] + "," + expansion.Min() + "," + WAexpansion + "," + expansion.Max() + "," + cutRatio[cluster] + "," + cutRatio.Min() + "," + WAcutRatio + "," + cutRatio.Max() + "," + conductance[cluster] + "," + conductance.Min() + "," + WAconductance + "," + conductance.Max() + "," + separability[cluster] + "," + separability.Min() + "," + WAseparability + "," + separability.Max() + "\n"; } return(report); }
public JUMP(Expr exp, LabelList targets) { Exp = exp; Targets = targets; }
public static void SP_WCS_BOX_LABEL_INFO(decimal P_CHUTE_NO, string P_PUSH_MODE, string P_PUSH_DATE) { string procedureName = "SP_WCS_BOX_LABEL_INFO"; using (OracleConnection oracleConnection = new OracleConnection(_connectionString)) { oracleConnection.Open(); OracleCommand oracleCommand = new OracleCommand(procedureName, oracleConnection); oracleCommand.CommandType = CommandType.StoredProcedure; oracleCommand.Parameters.Clear(); oracleCommand.Parameters.Add("P_CHUTE_NO", OracleDbType.Decimal).Value = P_CHUTE_NO; oracleCommand.Parameters.Add("P_PUSH_MODE", OracleDbType.Varchar2, 32767).Value = P_PUSH_MODE; oracleCommand.Parameters.Add("P_PUSH_DATE", OracleDbType.Varchar2, 32767).Value = P_PUSH_DATE; oracleCommand.Parameters.Add("P_RTN_FLAG", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_ERR_MSG", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_LABEL_TYPE", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_BOX_ID", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_BRAND_NM", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_CARR_NM", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_AREA_NM", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_AREA_GROUP", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_AREA_CD", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_SHOP_CD", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_SHOP_NM", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_SHOP_ADDR", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_SHOP_TEL", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_PRINT_DATE", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_BOX_SEQ", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_STYLE_CNT", OracleDbType.Decimal, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_STYLE_LIST", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_STYLE_TOTAL", OracleDbType.Decimal, 32767).Direction = ParameterDirection.Output; oracleCommand.Parameters.Add("P_SKU_LIST", OracleDbType.Varchar2, 32767).Direction = ParameterDirection.Output; oracleCommand.ExecuteNonQuery(); oracleConnection.Close(); LabelList.SetValue("P_RTN_FLAG", oracleCommand.Parameters["P_RTN_FLAG"].Value.ToString()); LabelList.SetValue("P_ERR_MSG", oracleCommand.Parameters["P_ERR_MSG"].Value.ToString()); LabelList.SetValue("P_LABEL_TYPE", oracleCommand.Parameters["P_LABEL_TYPE"].Value.ToString()); LabelList.SetValue("P_BOX_ID", oracleCommand.Parameters["P_BOX_ID"].Value.ToString()); LabelList.SetValue("P_BRAND_NM", oracleCommand.Parameters["P_BRAND_NM"].Value.ToString()); LabelList.SetValue("P_CARR_NM", oracleCommand.Parameters["P_CARR_NM"].Value.ToString()); LabelList.SetValue("P_AREA_NM", oracleCommand.Parameters["P_AREA_NM"].Value.ToString()); LabelList.SetValue("P_AREA_GROUP", oracleCommand.Parameters["P_AREA_GROUP"].Value.ToString()); LabelList.SetValue("P_AREA_CD", oracleCommand.Parameters["P_AREA_CD"].Value.ToString()); LabelList.SetValue("P_SHOP_CD", oracleCommand.Parameters["P_SHOP_CD"].Value.ToString()); LabelList.SetValue("P_SHOP_NM", oracleCommand.Parameters["P_SHOP_NM"].Value.ToString()); LabelList.SetValue("P_SHOP_ADDR", oracleCommand.Parameters["P_SHOP_ADDR"].Value.ToString()); LabelList.SetValue("P_SHOP_TEL", oracleCommand.Parameters["P_SHOP_TEL"].Value.ToString()); LabelList.SetValue("P_PRINT_DATE", oracleCommand.Parameters["P_PRINT_DATE"].Value.ToString()); LabelList.SetValue("P_BOX_SEQ", oracleCommand.Parameters["P_BOX_SEQ"].Value.ToString()); LabelList.SetValue("P_STYLE_CNT", oracleCommand.Parameters["P_STYLE_CNT"].Value.ToString()); LabelList.SetValue("P_STYLE_LIST", oracleCommand.Parameters["P_STYLE_LIST"].Value.ToString()); LabelList.SetValue("P_STYLE_TOTAL", oracleCommand.Parameters["P_STYLE_TOTAL"].Value.ToString()); LabelList.SetValue("P_SKU_LIST", oracleCommand.Parameters["P_SKU_LIST"].Value.ToString()); } }
/**/ /// <summary> /// 是否动态改变颜色 /// </summary> public bool IsChangeColor = false; #endregion protected void Page_Load(object sender, EventArgs e) { zedGraphControl.Width = ZGWidth; zedGraphControl.Height = ZGHeight; zedGraphControl.RenderGraph += new ZedGraph.Web.ZedGraphWebControlEventHandler(zedGraphControl_RenderGraph); //保存位置(ZedGraph/Images目录可以自定义) FilePath = "~/Admin/Controls/ZedGraph/"; zedGraphControl.RenderedImagePath = FilePath; } private void InitDefaultColors() { //以下为颜色样例 //defaultColors.Add(Color.Red); //defaultColors.Add(Color.Green); //defaultColors.Add(Color.Blue); //defaultColors.Add(Color.Yellow); //defaultColors.Add(Color.YellowGreen); //defaultColors.Add(Color.Brown); //defaultColors.Add(Color.Aqua); //defaultColors.Add(Color.Cyan); //defaultColors.Add(Color.DarkSeaGreen); //defaultColors.Add(Color.Indigo); if (IsChangeColor) { defaultColors.Add(Color.FromArgb(255, 158, 158)); //红色 defaultColors.Add(Color.FromArgb(167, 233, 145)); //绿色 defaultColors.Add(Color.FromArgb(145, 233, 255)); //蓝色 defaultColors.Add(Color.FromArgb(255, 255, 145)); //黄色 defaultColors.Add(Color.FromArgb(211, 233, 145)); //黄绿 defaultColors.Add(Color.FromArgb(255, 145, 255)); //紫色 defaultColors.Add(Color.FromArgb(0, 153, 255)); defaultColors.Add(Color.FromArgb(255, 204, 0)); defaultColors.Add(Color.FromArgb(76, 183, 255)); // defaultColors.Add(Color.FromArgb(255, 214, 51)); defaultColors.Add(Color.FromArgb(127, 204, 255)); // defaultColors.Add(Color.FromArgb(255, 224, 102)); defaultColors.Add(Color.FromArgb(166, 219, 255)); // defaultColors.Add(Color.FromArgb(255, 235, 153)); defaultColors.Add(Color.FromArgb(204, 235, 255)); // defaultColors.Add(Color.FromArgb(255, 245, 204)); } else { defaultColors.Add(Color.FromArgb(0, 153, 255)); // defaultColors.Add(Color.FromArgb(255, 204, 0)); defaultColors.Add(Color.FromArgb(76, 183, 255)); // defaultColors.Add(Color.FromArgb(255, 214, 51)); defaultColors.Add(Color.FromArgb(127, 204, 255)); // defaultColors.Add(Color.FromArgb(255, 224, 102)); defaultColors.Add(Color.FromArgb(166, 219, 255)); // defaultColors.Add(Color.FromArgb(255, 235, 153)); defaultColors.Add(Color.FromArgb(204, 235, 255)); // defaultColors.Add(Color.FromArgb(255, 245, 204)); } } /**/ /// <summary> /// 如果属性为空则初始化属性数据 /// </summary> private void InitProperty() { InitDefaultColors(); if (string.IsNullOrEmpty(Title)) { Title = string.Empty; } if (string.IsNullOrEmpty(XAxisTitle)) { XAxisTitle = "横轴"; } if (string.IsNullOrEmpty(YAxisTitle)) { YAxisTitle = "纵轴"; } if (Type == AnalyticsType.Pie) { Count = ScaleData.Count; } else { Count = DataSource.Count; } if (Colors.Count == 0 || Colors.Count != Count) { if (IsChangeColor) { for (int i = 0; i < 16; i++) { Colors.Add(defaultColors[i]); } } else { for (int i = 0; i < 10; i++) { Colors.Add(defaultColors[i]); } } } if (NameList.Count == 0) { if (Type == AnalyticsType.Bar || Type == AnalyticsType.Line) { for (int i = 0; i < DataSource[0].Count; i++) { NameList.Add((i + 1).ToString()); } } else { for (int i = 0; i < Count; i++) { NameList.Add((i + 1).ToString()); } } } if (LabelList.Count == 0) { if (Count > 5) { int k = 1; for (int i = 0; i < Count; i++) { LabelList.Add("名称 " + k.ToString()); if (i % 2 != 0) { k++; } } } else { for (int i = 0; i < Count; i++) { LabelList.Add("名称 " + (i + 1).ToString()); } } } }
public LabelList(Label head, LabelList tail) { Head = head; Tail = tail; }
private void FaceMonitoring(object sender, EventArgs e) { try { // Get the current frame form capture device CurrentFrame = Grabber.QueryFrame().Resize(320, 240, INTER.CV_INTER_CUBIC); //Video.Serve(CurrentFrame.Bytes); //System.Diagnostics.Debug.Print(Convert.ToBase64String(CurrentFrame.Bytes)); // Convert it to Grayscale Gray = CurrentFrame.Convert <Gray, byte>(); // Face Detector MCvAvgComp[][] facesDetected = Gray.DetectHaarCascade(Face, 1.2, 10, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20)); if (facesDetected == null) { return; } // Action for each element detected foreach (MCvAvgComp face in facesDetected[0]) { Result = CurrentFrame.Copy(face.rect).Convert <Gray, byte>().Resize(100, 100, INTER.CV_INTER_CUBIC); // Draw the face detected in the 0th (gray) channel with blue color CurrentFrame.Draw(face.rect, new Bgr(Color.Red), 2); // Check if there is trained images to find a match if (TrainingImages.ToArray().Length != 0) { var eigenDistanceThreshold = 3000; var eps = 0.001; // TermCriteria for face recognition with numbers of trained images like maxIteration MCvTermCriteria termCrit = new MCvTermCriteria(TrainedFacesCounter, eps); // Eigen face recognizer FaceRecognitionEngine recognizer = new FaceRecognitionEngine(TrainingImages.ToArray(), LabelList.ToArray(), eigenDistanceThreshold, ref termCrit); var imgLabel = recognizer.Recognize(Result); LogStats($"{imgLabel} - Recognized"); // Draw the label for each face detected and recognized // CurrentFrame.Draw(imgLabel, ref Font, new Point(face.rect.X - 2, face.rect.Y - 2), new Bgr(Color.White)); MethodInvoker inv = delegate { lblLabelName.Text = imgLabel.Replace("_", " ").ToUpper(); }; Invoke(inv); } } // Show the face procesed and recognized imageBoxFrameGrabber.Image = CurrentFrame; } catch { } }
private static String OptimalErrorEval(Partition clusterFile, LabelList labels, int[,] clusterMatching) { return("To Be Implemented"); }
private string parse(string originalhtml, JObject data, string rootpath, bool isList, string listitemname) { int idcounter = -1; List <DataList> datalist = new List <DataList>(); List <LabelList> labelList = new List <LabelList>(); List <EditorList> editorList = new List <EditorList>(); Regex rgx = new Regex(regexList, RegexOptions.IgnoreCase); MatchCollection matches = rgx.Matches(originalhtml); if (matches.Count > 0) { foreach (Match match in matches) { idcounter = idcounter + 1; string path = parseListPath(match.ToString()); string pt; if (isList) { if (path.Contains('.')) { pt = rootpath + path.Replace(listitemname, ""); } else { pt = rootpath; } } else { pt = rootpath + path; } DataList dl = new DataList() { id = idcounter, data = data.SelectToken(path).ToList(), htmloriginal = match.ToString(), origPath = pt, boRender = this }; datalist.Add(dl); originalhtml = originalhtml.Replace(dl.htmloriginal, "#" + idcounter + "#"); } } Regex rgxlabel = new Regex(regexLabel, RegexOptions.IgnoreCase); MatchCollection matcheslabel = rgxlabel.Matches(originalhtml); if (matcheslabel.Count > 0) { foreach (Match match in matcheslabel) { idcounter = idcounter + 1; string path = parsePath(match.ToString()); string pt; if (isList) { if (path.Contains('.')) { pt = rootpath + path.Replace(listitemname, ""); } else { pt = rootpath; } } else { pt = rootpath + path; } LabelList item = new LabelList() { id = idcounter, Path = pt, boRender = this }; labelList.Add(item); originalhtml = originalhtml.Replace(match.ToString(), "#" + idcounter + "#"); } } Regex rgxEditor = new Regex(regexEditor, RegexOptions.IgnoreCase); MatchCollection matcheseditor = rgxEditor.Matches(originalhtml); if (matcheseditor.Count > 0) { foreach (Match match in matcheseditor) { idcounter = idcounter + 1; string path = parsePath(match.ToString()); string value = "NULL"; try { value = data.SelectToken(path).ToString(); } catch (Exception e) { Console.WriteLine(e.ToString()); } string pt; if (isList) { if (path.Contains('.')) { pt = rootpath + path.Replace(listitemname, ""); } else { pt = rootpath; } } else { pt = rootpath + path; } EditorList item = new EditorList() { id = idcounter, Path = pt, Value = value, boRender = this }; editorList.Add(item); originalhtml = originalhtml.Replace(match.ToString(), "#" + idcounter + "#"); } } foreach (var i in labelList) { originalhtml = originalhtml.Replace("#" + i.id + "#", i.getHtml()); } foreach (var i in editorList) { originalhtml = originalhtml.Replace("#" + i.id + "#", i.getHtml()); } foreach (var i in datalist) { string html = ""; int cnt = 0; foreach (var item in i.data) { JObject mydata; if (!item.GetType().Equals(new JObject())) { mydata = new JObject(); mydata.Add(i.getname(), item); } else { mydata = item.Value <JObject>(); } html = html + parse(i.getHtml(), mydata, i.origPath + "[" + cnt + "]", true, i.getname()); cnt = cnt + 1; } originalhtml = originalhtml.Replace("#" + i.id + "#", html); } return(originalhtml); }
/// <summary> /// 解析 /// </summary> /// <param name="freeLabel">标签内容</param> /// <param name="currentPage">当前页(仅用于分页)</param> /// <param name="pageSize">页面大小(仅用于分页)</param> /// <returns></returns> public string Parse(FreeLabel freeLabel, int currentPage, int pageSize) { string parseResult; // 标签解析结果 FreeLabelConfig labelConfig; // 自由标签参数 bool isException; // 是否出现异常 DataTable dtDataSource; // 标签数据源 LoopLabelParseParam labelParseParam; // 标签经解析后的参数 string selSQL; // 标签数据源查询语句 labelConfig = new FreeLabelConfig(); isException = false; parseResult = string.Empty; if (string.IsNullOrEmpty(this.NodeCode)) { DataRow[] drMenu; drMenu = this.MenuList.Select("NodeCode='" + freeLabel.NodeCode + "'"); if (drMenu != null && drMenu.Length > 0) { this.CSaveType = GetContentPageSaveType(drMenu[0]["ContentPageHtmlRule"].ToString()); } } if (LabelList != null && LabelList.Contains(freeLabel.Name)) { try { labelConfig = (FreeLabelConfig)LabelList[freeLabel.Name]; } catch { isException = true; } } else { isException = true; } if (!isException && !string.IsNullOrEmpty(labelConfig.SQL) && !string.IsNullOrEmpty(labelConfig.Content)) { selSQL = labelConfig.SQL; selSQL = selSQL.Replace("{$NodeCode}", NodeCode); selSQL = selSQL.Replace("{$SiteID}", SiteID.ToString()); if (pageSize > 0) // 分页 { selSQL = Regex.Replace(selSQL, @"top\s*\d+", " ", RegexOptions.Singleline | RegexOptions.IgnoreCase); dtDataSource = dal.GetFreeLabelSplitDataSource(selSQL, currentPage, pageSize, null); } else { dtDataSource = dal.GetFreeLabelDataSource(selSQL); } labelParseParam = GetLoopLabelParam(labelConfig.Content, this.itemContentTag); parseResult = DataSourceBind(dtDataSource, labelParseParam, freeLabel); parseResult = labelParseParam.LabelTemplate.Replace(itemContentTag, parseResult); } return(parseResult); }
private string parse(string originalhtml, JObject data, string rootpath, bool isList, string listitemname) { int idcounter = -1; List<DataList> datalist = new List<DataList>(); List<LabelList> labelList = new List<LabelList>(); List<EditorList> editorList = new List<EditorList>(); Regex rgx = new Regex(regexList, RegexOptions.IgnoreCase); MatchCollection matches = rgx.Matches(originalhtml); if (matches.Count > 0) { foreach (Match match in matches) { idcounter = idcounter + 1; string path = parseListPath(match.ToString()); string pt; if (isList) { if (path.Contains('.')) { pt = rootpath + path.Replace(listitemname, ""); } else { pt = rootpath; } } else { pt = rootpath + path; } DataList dl = new DataList() { id = idcounter, data = data.SelectToken(path).ToList(), htmloriginal = match.ToString(), origPath = pt, boRender = this }; datalist.Add(dl); originalhtml = originalhtml.Replace(dl.htmloriginal, "#" + idcounter + "#"); } } Regex rgxlabel = new Regex(regexLabel, RegexOptions.IgnoreCase); MatchCollection matcheslabel = rgxlabel.Matches(originalhtml); if (matcheslabel.Count > 0) { foreach (Match match in matcheslabel) { idcounter = idcounter + 1; string path = parsePath(match.ToString()); string pt; if (isList) { if (path.Contains('.')) { pt = rootpath + path.Replace(listitemname, ""); } else { pt = rootpath; } } else { pt = rootpath + path; } LabelList item = new LabelList() { id = idcounter, Path = pt, boRender = this }; labelList.Add(item); originalhtml = originalhtml.Replace(match.ToString(), "#" + idcounter + "#"); } } Regex rgxEditor = new Regex(regexEditor, RegexOptions.IgnoreCase); MatchCollection matcheseditor = rgxEditor.Matches(originalhtml); if (matcheseditor.Count > 0) { foreach (Match match in matcheseditor) { idcounter = idcounter + 1; string path = parsePath(match.ToString()); string value = "NULL"; try { value = data.SelectToken(path).ToString(); } catch (Exception e) { Console.WriteLine(e.ToString()); } string pt; if (isList) { if (path.Contains('.')) { pt = rootpath + path.Replace(listitemname, ""); } else { pt = rootpath; } } else { pt = rootpath + path; } EditorList item = new EditorList() { id = idcounter, Path = pt, Value = value, boRender = this }; editorList.Add(item); originalhtml = originalhtml.Replace(match.ToString(), "#" + idcounter + "#"); } } foreach (var i in labelList) { originalhtml = originalhtml.Replace("#" + i.id + "#", i.getHtml()); } foreach (var i in editorList) { originalhtml = originalhtml.Replace("#" + i.id + "#", i.getHtml()); } foreach (var i in datalist) { string html = ""; int cnt = 0; foreach (var item in i.data) { JObject mydata; if (!item.GetType().Equals(new JObject())) { mydata = new JObject(); mydata.Add(i.getname(), item); } else { mydata = item.Value<JObject>(); } html = html + parse(i.getHtml(), mydata, i.origPath + "[" + cnt + "]", true, i.getname()); cnt = cnt + 1; } originalhtml = originalhtml.Replace("#" + i.id + "#", html); } return originalhtml; }