Exemplo n.º 1
0
        public List <int[]> SurroundCoord(Surround neighbor, int x, int y)
        {
            List <int[]> surround = new List <int[]>();
            List <int[]> temp     = new List <int[]>();

            for (int i = -1; i < 2; i++)
            {
                for (int j = -1; j < 2; j++)
                {
                    surround.Add(new int[] { x + i, y + j });
                }
            }

            if (neighbor == Surround.Cardinal)
            {
                foreach (var coord in surround)
                {
                    if ((x == coord[0]) || (y == coord[1]))
                    {
                        temp.Add(coord);
                    }
                }
                surround = temp;
            }
            return(surround);
        }
Exemplo n.º 2
0
        public List <int[]> SurroundCoord(Surround neighbor, int[] position)
        {
            int x = position[0];
            int y = position[1];

            return(SurroundCoord(neighbor, x, y));
        }
Exemplo n.º 3
0
 public void VerifyDefaults()
 {
     surround = new Surround();
     Assert.AreEqual("127.0.0.1:4900", surround.ServerConnect);
     Assert.AreEqual("Administrator:", surround.ServerLogin);
     Assert.AreEqual(0, surround.SearchRegExp);
     Assert.AreEqual(0, surround.Recursive);
 }
Exemplo n.º 4
0
    public static void AnlayzeEntitySurroundWords()
    {
        var         ContractPath_TRAIN      = Program.DocBase + @"\FDDC_announcements_round1_train_20180518\重大合同";
        Surround    JiaFangSurround         = new Surround();
        Surround    YiFangSurround          = new Surround();
        Surround    ProjectNameSurround     = new Surround();
        Surround    ContractNameSurround    = new Surround();
        LeadingWord JiaFangNameLeadingWord  = new LeadingWord();
        LeadingWord YiFangNameLeadingWord   = new LeadingWord();
        LeadingWord ProjectNameLeadingWord  = new LeadingWord();
        LeadingWord ContractNameLeadingWord = new LeadingWord();

        foreach (var filename in System.IO.Directory.GetFiles(ContractPath_TRAIN + @"\html\"))
        {
            var fi = new System.IO.FileInfo(filename);
            var Id = fi.Name.Replace(".html", String.Empty);
            if (TraningDataset.GetContractById(Id).Count == 0)
            {
                continue;
            }
            var contract = TraningDataset.GetContractById(Id).First();
            var doc      = new AnnouceDocument(filename);
            //if (!string.IsNullOrEmpty(contract.JiaFang)) JiaFangSurround.AnlayzeEntitySurroundWords(doc, contract.JiaFang);
            //if (!string.IsNullOrEmpty(contract.YiFang)) YiFangSurround.AnlayzeEntitySurroundWords(doc, contract.YiFang);
            //if (!string.IsNullOrEmpty(contract.ProjectName)) ProjectNameSurround.AnlayzeEntitySurroundWords(doc, contract.ProjectName);
            //if (!string.IsNullOrEmpty(contract.ContractName)) ContractNameSurround.AnlayzeEntitySurroundWords(doc, contract.ContractName);
            if (!string.IsNullOrEmpty(contract.JiaFang))
            {
                JiaFangNameLeadingWord.AnlayzeLeadingWord(doc, contract.JiaFang);
            }
            if (!string.IsNullOrEmpty(contract.YiFang))
            {
                YiFangNameLeadingWord.AnlayzeLeadingWord(doc, contract.YiFang);
            }
            if (!string.IsNullOrEmpty(contract.ProjectName))
            {
                ProjectNameLeadingWord.AnlayzeLeadingWord(doc, contract.ProjectName);
            }
            if (!string.IsNullOrEmpty(contract.ContractName))
            {
                ContractNameLeadingWord.AnlayzeLeadingWord(doc, contract.ContractName);
            }
        }
        //JiaFangSurround.GetTop(10);
        //YiFangSurround.GetTop(10);
        //ProjectNameSurround.GetTop(10);
        //ContractNameSurround.GetTop(10);

        JiaFangLeadingDict      = JiaFangNameLeadingWord.GetTop(5);
        YiFangLeadingDict       = YiFangNameLeadingWord.GetTop(5);
        ProjectNameLeadingDict  = ProjectNameLeadingWord.GetTop(5);
        ContractNameLeadingDict = ContractNameLeadingWord.GetTop(5);
    }
Exemplo n.º 5
0
 protected void SetUp()
 {
     surround = new Surround();
     NetReflector.Read(SSCM_XML, surround);
 }
Exemplo n.º 6
0
    /// <summary>
    /// 分析实体周边词语
    /// </summary>
    public static void AnlayzeEntitySurroundWords()
    {
        var      ContractPath_TRAIN   = Program.DocBase + @"\FDDC_announcements_round1_train_20180518\重大合同";
        Surround JiaFangSurround      = new Surround();
        Surround YiFangSurround       = new Surround();
        Surround ProjectNameSurround  = new Surround();
        Surround ContractNameSurround = new Surround();

        LeadingColonWord JiaFangLeadingColonWord      = new LeadingColonWord();
        LeadingColonWord YiFangLeadingColonWord       = new LeadingColonWord();
        LeadingColonWord ProjectNameLeadingColonWord  = new LeadingColonWord();
        LeadingColonWord ContractNameLeadingColonWord = new LeadingColonWord();

        foreach (var filename in System.IO.Directory.GetFiles(ContractPath_TRAIN + @"\html\"))
        {
            var fi = new System.IO.FileInfo(filename);
            var Id = fi.Name.Replace(".html", String.Empty);
            if (TraningDataset.GetContractById(Id).Count == 0)
            {
                continue;
            }
            var contract = TraningDataset.GetContractById(Id).First();
            var doc      = new Contract();
            doc.Init(filename);
            if (!string.IsNullOrEmpty(contract.JiaFang))
            {
                JiaFangSurround.AnlayzeEntitySurroundWords(doc, contract.JiaFang);
            }
            if (!string.IsNullOrEmpty(contract.YiFang))
            {
                YiFangSurround.AnlayzeEntitySurroundWords(doc, contract.YiFang);
            }
            if (!string.IsNullOrEmpty(contract.ProjectName))
            {
                ProjectNameSurround.AnlayzeEntitySurroundWords(doc, contract.ProjectName);
            }
            if (!string.IsNullOrEmpty(contract.ContractName))
            {
                ContractNameSurround.AnlayzeEntitySurroundWords(doc, contract.ContractName);
            }

            if (!string.IsNullOrEmpty(contract.JiaFang))
            {
                JiaFangLeadingColonWord.AnlayzeLeadingWord(doc, contract.JiaFang);
            }
            if (!string.IsNullOrEmpty(contract.YiFang))
            {
                YiFangLeadingColonWord.AnlayzeLeadingWord(doc, contract.YiFang);
            }
            if (!string.IsNullOrEmpty(contract.ProjectName))
            {
                ProjectNameLeadingColonWord.AnlayzeLeadingWord(doc, contract.ProjectName);
            }
            if (!string.IsNullOrEmpty(contract.ContractName))
            {
                ContractNameLeadingColonWord.AnlayzeLeadingWord(doc, contract.ContractName);
            }
        }

        JiaFangSurround.WriteToLog(Program.Training);
        Program.Training.WriteLine("甲方:冒号前导词");
        JiaFangLeadingColonWord.WriteToLog(Program.Training);
        JiaFangLeadingDict = Utility.ConvertRankToCIDict(Utility.FindTop(5, JiaFangLeadingColonWord.LeadingWordDict));

        YiFangSurround.WriteToLog(Program.Training);
        Program.Training.WriteLine("乙方:冒号前导词");
        YiFangLeadingColonWord.WriteToLog(Program.Training);
        YiFangLeadingDict = Utility.ConvertRankToCIDict(Utility.FindTop(5, YiFangLeadingColonWord.LeadingWordDict));

        ProjectNameSurround.WriteToLog(Program.Training);
        Program.Training.WriteLine("工程名:冒号前导词");
        ProjectNameLeadingColonWord.WriteToLog(Program.Training);
        ProjectNameLeadingDict = Utility.ConvertRankToCIDict(Utility.FindTop(5, ProjectNameLeadingColonWord.LeadingWordDict));

        ContractNameSurround.WriteToLog(Program.Training);
        Program.Training.WriteLine("合同名:冒号前导词");
        ContractNameLeadingColonWord.WriteToLog(Program.Training);
        ContractNameLeadingDict = Utility.ConvertRankToCIDict(Utility.FindTop(5, ContractNameLeadingColonWord.LeadingWordDict));
    }
Exemplo n.º 7
0
        private void SetSelectedColor(UniColor?selc = null)
        {
            UniColor clr;

            if (selc != null)
            {
                clr           = (UniColor)selc;
                SelectedColor = Color.FromArgb(clr.A, clr.R, clr.G, clr.B);

                return;
            }
            else if (SelectedColor == null)
            {
                SelectedColorName    = null;
                Point.Visibility     = Surround.Visibility = Visibility.Hidden;
                HuePicker.Visibility = Visibility.Hidden;
                return;
            }

            clr = ((Color)SelectedColor).GetUniColor();

            var nc = NamedColor.FindColor(clr, NameResolution == ColorNameResolution.Closest);

            if (nc != null)
            {
                SelectedColorName = nc.Name;
            }
            else
            {
                SelectedColorName = clr.ToString(UniColorFormatOptions.HexRgbWebFormat);
            }

            if (cpRender == null)
            {
                return;
            }

            HSVDATA  hsv1 = ColorToHSV(clr);
            HSVDATA  hsv2;
            HSVDATA  hsv3;
            HSVDATA? hsv4 = null;
            HSVDATA? hsv5 = null;
            UniColor uc;

            ColorPickerElement cel = new ColorPickerElement();

            foreach (var c in cpRender.Elements)
            {
                uc = c.Color;

                hsv2 = ColorToHSV(uc);
                hsv3 = (hsv1 - hsv2).Abs();

                if (hsv4 == null)
                {
                    hsv4 = hsv3;
                }
                else if (hsv3 < hsv4)
                {
                    hsv5 = hsv2;
                    hsv4 = hsv3;
                    cel  = c;
                }

                if (selc == uc)
                {
                    cel = c;
                    break;
                }
            }

            if (Mode == ColorPickerMode.HueWheel && !double.IsNaN(ActualWidth) && !double.IsNaN(ActualHeight) && ActualWidth != -1 && ActualHeight != -1)
            {
                if (hsv5 is HSVDATA hsv)
                {
                    Point.Visibility     = Surround.Visibility = Visibility.Hidden;
                    HuePicker.Visibility = Visibility.Visible;
                    int hp = HuePointerSize;

                    PolarCoordinates pc = new PolarCoordinates();

                    double arc = hsv.Hue - HueOffset;
                    if (arc < 0)
                    {
                        arc += 360;
                    }

                    int rad;
                    int h = (int)ActualHeight, w = (int)ActualWidth;

                    if (h < w)
                    {
                        rad = h / 2;
                        w   = h;
                    }
                    else
                    {
                        rad = w / 2;
                        h   = w;
                    }

                    pc.Arc    = arc;
                    pc.Radius = rad;

                    var lc = pc.ToScreenCoordinates(new Rect(0, 0, w, h));

                    if (lc.X < (w / 2))
                    {
                        lc.X -= hp;
                    }

                    if (lc.Y < (h / 2))
                    {
                        lc.Y -= hp;
                    }

                    HuePicker.SetValue(Canvas.LeftProperty, lc.X);
                    HuePicker.SetValue(Canvas.TopProperty, lc.Y);

                    HueSize.ScaleX = (HuePointerSize / 5);
                    HueSize.ScaleY = (HuePointerSize / 5);

                    HueAngle.Angle = pc.Arc;
                }
            }
            else
            {
                Point.Visibility     = Surround.Visibility = Visibility.Visible;
                HuePicker.Visibility = Visibility.Hidden;

                Point.SetValue(Canvas.LeftProperty, (double)cel.Center.X);
                Point.SetValue(Canvas.TopProperty, (double)cel.Center.Y);

                Surround.SetValue(Canvas.LeftProperty, (double)cel.Center.X - 8);
                Surround.SetValue(Canvas.TopProperty, (double)cel.Center.Y - 8);

                Surround.Stroke = Point.Stroke = new SolidColorBrush((Color)SelectedColor);
                selectedElement = cel;
            }
        }