//-------------------------------------------------------------------------
        /// <summary>
        /// Returns a full-text search-ready string with most punctuation and
        /// the words and phrases listed in the module settings removed.
        /// </summary>
        internal static string RemoveNameSearchNoiseTerms(
            string facilityNameSearchTerms,
            IEnumerable <string> nameSearchNoiseTerms)
        {
            Precondition.IsNotNull <string>(
                facilityNameSearchTerms, "facilityNameSearchTerms");

            List <string> noiseWords =
                new List <string>(nameSearchNoiseTerms);

            List <string> cleanTerms = new List <string>();

            string[] terms = StringX.SplitOnWhitespace(
                facilityNameSearchTerms.ToLower());

            foreach (string term in terms)
            {
                string cleanTerm =
                    InvalidSearchTermPattern.Replace(term, String.Empty);

                if ((cleanTerm.Length > 0) &&
                    !cleanTerms.Contains(cleanTerm) &&
                    !noiseWords.Contains(cleanTerm))
                {
                    cleanTerms.Add(cleanTerm);
                }
            }

            return(String.Join(" ", cleanTerms.ToArray()));
        }
Beispiel #2
0
        //public HObject InputImage
        //{
        //    get { return m_image; }
        //    set { m_image = value; }
        //}
        private void btn_Decode_Click(object sender, EventArgs e)
        {
            List <HObject> region       = new List <HObject>();
            List <HObject> imageReduced = new List <HObject>();

            region = hDisplay1.GetSearchRegions();
            Time_Meter time_Meter = new Time_Meter();

            foreach (var member in region)
            {
                HObject _iamge = new HObject();
                HOperatorSet.ReduceDomain(m_image, member, out _iamge);
                HOperatorSet.CropDomain(_iamge, out _iamge);
                imageReduced.Add(_iamge);
            }

            TDCode     tdcode;
            CodeResult sss = new CodeResult();

            CodeResult[] results = new CodeResult[] { };
            if (_form is FormDMCodeParam)
            {
                FormDMCodeParam form = (FormDMCodeParam)_form;
                tdcode = new DMCode();

                tdcode.SetCodeParam(form.CodeParameter);

                results          = tdcode.Decode(imageReduced);
                txt_TimeUse.Text = (time_Meter.TimePass() * 1000).ToString();
            }
            else if (_form is FormQRCodeParam)
            {
                FormQRCodeParam form = (FormQRCodeParam)_form;

                tdcode = new QRCode();
                tdcode.SetCodeParam(form.CodeParameter);
                results = tdcode.Decode(imageReduced);
            }

            List <StringX>           ss      = new List <StringX>();
            List <HalWindow.RegionX> regions = new List <HalWindow.RegionX>();

            foreach (var member in results)
            {
                if (member.code != string.Empty)
                {
                    HTuple area   = new HTuple();
                    HTuple row    = new HTuple();
                    HTuple column = new HTuple();
                    HOperatorSet.AreaCenter(member.codexld, out area, out row, out column);
                    StringX sx = new StringX(15, false, false);
                    sx.SetString(member.code, (int)row.D, (int)column.D, System.Drawing.Color.Green);
                    ss.Add(sx);
                    HalWindow.RegionX regionX = new HalWindow.RegionX(member.codexld, "green");
                    regions.Add(regionX);
                }
            }
            DelegateUIControl.GetInstance().UpdateHDisplay("FormSetHDisplay", m_image, regions, ss);
        }
Beispiel #3
0
        private static Log _getNewLog <T>(T loggedData)
        {
            var log = Log.Create <T>(loggedData);

            log.Title       = StringX.RandomLetters(50);
            log.Description = StringX.RandomLetters(500);
            log.IpAddress   = Convert.ToInt32(Number.Rnd() * 255) + "." + Convert.ToInt32(Number.Rnd() * 255) + "." + Convert.ToInt32(Number.Rnd() * 255) + "." + Convert.ToInt32(Number.Rnd() * 255);
            return(log);
        }
Beispiel #4
0
        public static Player Create()
        {
            Player ret = new Player();

            ret.Age         = Convert.ToInt32(Number.Rnd() * 30);
            ret.Name        = StringX.RandomLetters(7).ToSentenceCase() + " " + StringX.RandomLetters(5).ToSentenceCase();
            ret.ShirtNumber = Convert.ToInt32(Number.Rnd() * 100);
            return(ret);
        }
        public int Compare(object x, object y)
        {
            // On récupère les 2 objets en "ListViewItem"
            ListViewItem ItemX = x as ListViewItem;
            ListViewItem ItemY = y as ListViewItem;

            // On récupère les sub-items
            string StringX;

            if (ItemX.SubItems.Count <= ColumnNumber)
            {
                StringX = "";
            }
            else
            {
                StringX = ItemX.SubItems[ColumnNumber].Text;
            }

            string StringY;

            if (ItemY.SubItems.Count <= ColumnNumber)
            {
                StringY = "";
            }
            else
            {
                StringY = ItemY.SubItems[ColumnNumber].Text;
            }

            // On les compare
            int    Result;
            double DoubleX, DoubleY;

            // Si on essaye de comparer les prix ou la quanité
            if (double.TryParse(StringX, out DoubleX) && double.TryParse(StringY, out DoubleY))
            {
                Result = DoubleX.CompareTo(DoubleY);
            }
            // Sinon (c'est des strings)
            else
            {
                Result = StringX.CompareTo(StringY);
            }

            // Retourne le bon résultat en fonction du SortOrder
            if (SortOrder == SortOrder.Ascending)
            {
                return(Result);
            }
            else
            {
                return(-Result);
            }
        }
Beispiel #6
0
        public void FirstNotEmpty_WhenCalled_ReturnFirstNotEmpty()
        {
            //Arrange
            var          emptyValues = new[] { null, string.Empty, "" };
            const string expected    = "1";
            var          values      = emptyValues.Append(expected).Concat(emptyValues);

            //Act
            var result = StringX.FirstNotEmpty(values);

            //Assert
            result.Should().Be(expected);
        }
Beispiel #7
0
        // Manipulation
        public Label AddLabel(string labelName)
        {
            var newString = new StringX();

            TXT2.Strings.Add(newString);
            TXT2.NumberOfStrings += 1;

            Label newLabel;

            if (HasLabels)
            {
                newLabel = new Label
                {
                    Name     = labelName.Trim(),
                    Index    = (uint)TXT2.Strings.IndexOf(newString),
                    Checksum = SimpleHash.Create(labelName.Trim(), LabelHashMagic, LBL1.NumberOfGroups),
                    String   = newString
                };
                LBL1.Labels.Add(newLabel);
                LBL1.Groups[(int)newLabel.Checksum].NumberOfLabels += 1;
                //ATR1.NumberOfAttributes += 1;
            }
            else if (HasIDs)
            {
                var key = uint.Parse(labelName.Trim());
                newLabel = new Label
                {
                    Name   = key.ToString(),
                    Index  = (uint)TXT2.Strings.IndexOf(newString),
                    String = newString
                };
                NLI1.NumberOfIDs++;
                NLI1.GlobalIDs.Add(newLabel.Index, key);
            }
            else
            {
                newLabel = new Label
                {
                    Index  = (uint)TXT2.Strings.IndexOf(newString),
                    String = newString
                };
            }

            return(newLabel);
        }
Beispiel #8
0
        //----------------------------------------------------------------------
        private static ResultSet FinalizeResultSet(
            Timer t,
            Comparison <Result> sortOrder,
            int desiredResultCount,
            ResultSet matches,
            string featuredProfileTemplateLabel)
        {
            // KLUDGE: Ed V. is not confident that this is the right place for
            // this code.  Would it be better to make this a ResultSet method?
            // Would you ever *not* want to call all of these methods in exactly
            // this order?  If so, it should not be a ResultSet method.  If not,
            // it should be.

            t.Measure("Find summaries for each matching Party", delegate() {
                matches.LoadSummaries();
            });

            if (StringX.IsNotEmpty(featuredProfileTemplateLabel))
            {
                t.Measure("Find featured-since dates for each matching Party", delegate() {
                    matches.LoadFeaturedSinceDates(featuredProfileTemplateLabel);
                });
            }

            t.Measure("Sort matching Parties", delegate() {
                matches.OrderBy(sortOrder);
            });

            t.Measure("Trim results to desiredResultCount", delegate() {
                matches.TrimToDesiredResultCount(desiredResultCount);
            });

            t.Measure("Find EPMTs associated with matching Parties", delegate() {
                // BUG: Since the "trim" step above doesn't actually discard the
                // Party IDs from the ResultSet, we may find a EPMT here that
                // isn't actually represented in the *visible* results.  Arrg!
                // In practice, this is *very* rare, so we'll live with the
                // slight chance that an extra license type will be included for
                // now.
                matches.LoadExternalPartyMembershipTypes();
            });

            return(matches);
        }
Beispiel #9
0
        private static void _createLogsAndRelationships()
        {
            var logs = new List <Log>();

            for (int i = 1; i <= 5; i++)
            {
                string loggedData = StringX.RandomLetters(50);
                Log    log        = _getNewLog <string>(loggedData);
                Manager.Add(log);
                logs.Add(log);
                Console.WriteLine("Logging Data: " + log.Title);
                for (int j = 1; j <= 5; j++)
                {
                    var newLog = _getNewLog <Guid>(Guid.NewGuid());
                    newLog = log.AddChild(newLog);
                    Console.WriteLine("\tLogging Child for [" + log.ID + "] Data: " + newLog.Title);
                }
            }
        }
        public override void AddHeader(StringBuilder sb)
        {
            // drawangles()
            // drawangles(angle)
            // drawangles(angle, local)

            sb.Append(" drawangles( ");

            if (!string.IsNullOrEmpty(AngleProperty))
            {
                sb.Append($"{StringX.QuoteSafe( AngleProperty )}");

                if (!string.IsNullOrEmpty(LocalProperty))
                {
                    sb.Append($", {StringX.QuoteSafe( LocalProperty )}");
                }
            }

            sb.Append(" ) ");
        }
Beispiel #11
0
        //----------------------------------------------------------------------
        private static ResultSet SearchByParty <ProfileType>(
            Timer t,
            IEnumerable <string> nameSearchNoiseWords,
            AddressParserResult searchLocale,
            int desiredResultCount,
            int maxResultCount,
            IntSet <PartyId> externalPartyMembershipTypeMatches,
            IntSet <PartyId> profileSpecificParties,
            double nonGeoMatchAbsDensity,
            ref Comparison <Result> sortOrder)
            where ProfileType : ISearch, new()
        {
            IntSet <PartyId> nameMatches      = null;
            IntSet <PartyId> locationMatches  = null;
            IntSet <PartyId> geoOrNameMatches = null;
            Location         centroid         = null;
            double?          maxRadiusMi      = null;
            ResultSet        rs = null;


            if (StringX.IsNotEmpty(searchLocale.PartyName))
            {
                nameMatches = SearchByName(t, searchLocale, nameSearchNoiseWords);
            }


            if (searchLocale.Type == Snap.Data.Controller.SearchType.PartyName)
            {
                geoOrNameMatches = nameMatches;
                sortOrder        = Result.NameAscending;
            }
            else
            {
                switch (new ProfileType().GeoSearch)
                {
                case GeoSearchType.Point:

                    locationMatches = SearchForLocations(
                        t, nameSearchNoiseWords, searchLocale, desiredResultCount,
                        maxResultCount, nonGeoMatchAbsDensity,
                        out centroid, out maxRadiusMi);
                    break;

                case GeoSearchType.ServiceArea:
                    locationMatches = SearchForServiceArea(t, searchLocale);
                    break;

                case GeoSearchType.All:
                    var pointMatches = SearchForLocations(
                        t, nameSearchNoiseWords, searchLocale, desiredResultCount,
                        maxResultCount, nonGeoMatchAbsDensity, out centroid, out maxRadiusMi);
                    var svcAreaMatches = SearchForServiceArea(t, searchLocale);
                    locationMatches = IntSet <PartyId> .Union(pointMatches, svcAreaMatches);

                    sortOrder = Result.ShowServiceAreaMatchesFirst(svcAreaMatches, sortOrder);
                    break;

                default:
                    throw new ArgumentException(String.Format(
                                                    "Unexpected value of 'ISearch.GeoSearch': {0}",
                                                    new ProfileType().GeoSearch.ToString()));
                }
                geoOrNameMatches = StringX.IsNotEmpty(searchLocale.PartyName) ? IntSet <PartyId> .Intersection(nameMatches, locationMatches) : locationMatches;
            }



            rs = ResultSet.From(
                centroid,
                maxRadiusMi,
                IntSet <PartyId> .IntersectionOfMany(
                    geoOrNameMatches,
                    externalPartyMembershipTypeMatches,
                    profileSpecificParties));

            if (Snap.Data.Controller.SearchType.Membership == searchLocale.Type)
            {
                rs.UnfilteredMatchCount = externalPartyMembershipTypeMatches.Count;
            }
            else if (IntSet <PartyId> .IsEmpty(geoOrNameMatches))
            {
                rs.UnfilteredMatchCount = 0;
            }
            else
            {
                rs.UnfilteredMatchCount = geoOrNameMatches.Count;
            }


            return(rs);
        }
Beispiel #12
0
 public void CountIsExact(
     [UsingFactories("Counters")] ICountX counter,
     [UsingFactories("Strings")] StringX s)
 {
     Assert.AreEqual(s.XCount, counter.Count(s.Value));
 }
Beispiel #13
0
 public void StringXTest_xabxxxcdx_result_xabcdx()
 {
     Assert.AreEqual("xabcdx", StringX.ShowAnswer("xabxxxcdx"));
 }
Beispiel #14
0
 public void StringXTest_abxxxcd_result_abcd()
 {
     Assert.AreEqual("abcd", StringX.ShowAnswer("abxxxcd"));
 }
Beispiel #15
0
 public void StringXTest_xxHxix_result_xHix()
 {
     Assert.AreEqual("xHix", StringX.ShowAnswer("xxHxix"));
 }