Пример #1
0
        public void CanParseAddressWithCardinalStreetName()
        {
            var parser = new USAddressParser(
            TestUtility.CreateParserContext("500 SOUTH STREET VIRGINIA BEACH VIRGINIA 23452", ParserPattern.NorthAmerica));
            ParseResultCollection prc = parser.Parse(0);
            Assert.AreEqual(1, prc.Count);
            var address = prc[0].Value as Address;

            Assert.AreEqual("VIRGINIA BEACH", address.City);
            Assert.AreEqual("500", address.Number);
            Assert.AreEqual(null, address.Postdirectional);
            Assert.AreEqual(null, address.Predirectional);
            Assert.AreEqual(null, address.SecondaryNumber);
            Assert.AreEqual(null, address.SecondaryUnit);
            Assert.AreEqual("VA", address.State);
            Assert.AreEqual("SOUTH", address.Street);
            Assert.AreEqual("500 SOUTH ST", address.StreetLine);
            Assert.AreEqual("ST", address.Suffix);
            Assert.AreEqual("23452", address.Zip);
        }
Пример #2
0
        public void CanParseAddressWithoutPunctuation()
        {
            var parser = new USAddressParser(
            TestUtility.CreateParserContext("999 West 89th Street Apt A New York NY 10024", ParserPattern.NorthAmerica));
            ParseResultCollection prc = parser.Parse(0);
            Assert.AreEqual(1, prc.Count);
            var address = prc[0].Value as Address;

            Assert.AreEqual("NEW YORK", address.City);
            Assert.AreEqual("999", address.Number);
            Assert.AreEqual(null, address.Postdirectional);
            Assert.AreEqual("W", address.Predirectional);
            Assert.AreEqual("A", address.SecondaryNumber);
            Assert.AreEqual("APT", address.SecondaryUnit);
            Assert.AreEqual("NY", address.State);
            Assert.AreEqual("89TH", address.Street);
            Assert.AreEqual("999 W 89TH ST APT A", address.StreetLine);
            Assert.AreEqual("ST", address.Suffix);
            Assert.AreEqual("10024", address.Zip);
        }
Пример #3
0
        public void CanParseAddressWithAlphanumericRange()
        {
            var parser = new USAddressParser(
            TestUtility.CreateParserContext("N6W23001 BLUEMOUND ROAD, ROLLING MEADOWS, IL, 12345", ParserPattern.NorthAmerica));
            ParseResultCollection prc = parser.Parse(0);
            Assert.AreEqual(1, prc.Count);
            var address = prc[0].Value as Address;

            Assert.AreEqual("ROLLING MEADOWS", address.City);
            Assert.AreEqual("N6W23001", address.Number);
            Assert.AreEqual(null, address.Postdirectional);
            Assert.AreEqual(null, address.Predirectional);
            Assert.AreEqual(null, address.SecondaryNumber);
            Assert.AreEqual(null, address.SecondaryUnit);
            Assert.AreEqual("IL", address.State);
            Assert.AreEqual("BLUEMOUND", address.Street);
            Assert.AreEqual("N6W23001 BLUEMOUND RD", address.StreetLine);
            Assert.AreEqual("RD", address.Suffix);
            Assert.AreEqual("12345", address.Zip);
        }
Пример #4
0
        public void CanParseTypicalAddressWithPunctuation()
        {
            var parser = new USAddressParser(
                TestUtility.CreateParserContext("1005 N Gravenstein Highway, Sebastopol, CA 95472", ParserPattern.NorthAmerica));
            ParseResultCollection prc = parser.Parse(0);
            Assert.AreEqual(1, prc.Count);
            var address = prc[0].Value as Address;

            Assert.AreEqual("SEBASTOPOL", address.City);
            Assert.AreEqual("1005", address.Number);
            Assert.AreEqual(null, address.Postdirectional);
            Assert.AreEqual("N", address.Predirectional);
            Assert.AreEqual(null, address.SecondaryNumber);
            Assert.AreEqual(null, address.SecondaryUnit);
            Assert.AreEqual("CA", address.State);
            Assert.AreEqual("GRAVENSTEIN", address.Street);
            Assert.AreEqual("1005 N GRAVENSTEIN HWY", address.StreetLine);
            Assert.AreEqual("HWY", address.Suffix);
            Assert.AreEqual("95472", address.Zip);
        }
Пример #5
0
        public void CanParseQueensStyleAddress()
        {
            var parser = new USAddressParser(
            TestUtility.CreateParserContext("123-465 34th St New York NY 12345", ParserPattern.NorthAmerica));
            ParseResultCollection prc = parser.Parse(0);
            Assert.AreEqual(1, prc.Count);
            var address = prc[0].Value as Address;

            Assert.AreEqual("NEW YORK", address.City);
            Assert.AreEqual("123-465", address.Number);
            Assert.AreEqual(null, address.Postdirectional);
            Assert.AreEqual(null, address.Predirectional);
            Assert.AreEqual(null, address.SecondaryNumber);
            Assert.AreEqual(null, address.SecondaryUnit);
            Assert.AreEqual("NY", address.State);
            Assert.AreEqual("34TH", address.Street);
            Assert.AreEqual("123-465 34TH ST", address.StreetLine);
            Assert.AreEqual("ST", address.Suffix);
            Assert.AreEqual("12345", address.Zip);
        }
Пример #6
0
        public void CanParsePostOfficeBoxAddress()
        {
            var parser = new USAddressParser(
                TestUtility.CreateParserContext("P.O. BOX 4857, New York, NY 10001", ParserPattern.NorthAmerica));
            ParseResultCollection prc = parser.Parse(0);
            Assert.AreEqual(1, prc.Count);
            var address = prc[0].Value as Address;

            Assert.AreEqual("NEW YORK", address.City);
            Assert.AreEqual(null, address.Number);
            Assert.AreEqual(null, address.Postdirectional);
            Assert.AreEqual(null, address.Predirectional);
            Assert.AreEqual(null, address.SecondaryNumber);
            Assert.AreEqual(null, address.SecondaryUnit);
            Assert.AreEqual("NY", address.State);
            Assert.AreEqual(null, address.Street);
            Assert.AreEqual("PO BOX 4857", address.StreetLine);
            Assert.AreEqual(null, address.Suffix);
            Assert.AreEqual("10001", address.Zip);
        }
Пример #7
0
 public void CanParseMilitaryAddress()
 {
     var parser = new USAddressParser(
     TestUtility.CreateParserContext("PSC BOX 453, APO AE 99969", ParserPattern.NorthAmerica));
     ParseResultCollection prc = parser.Parse(0);
     Assert.AreEqual(1, prc.Count);
     var address = prc[0].Value as Address;
     Assert.AreEqual("APO", address.City);
     Assert.AreEqual(null, address.Number);
     Assert.AreEqual(null, address.Postdirectional);
     Assert.AreEqual(null, address.Predirectional);
     Assert.AreEqual(null, address.SecondaryNumber);
     Assert.AreEqual(null, address.SecondaryUnit);
     Assert.AreEqual("AE", address.State);
     Assert.AreEqual(null, address.Street);
     Assert.AreEqual("PSC BOX 453", address.StreetLine);
     Assert.AreEqual(null, address.Suffix);
     Assert.AreEqual("99969", address.Zip);
 }
Пример #8
0
        public void CanParseGridStyleAddress()
        {
            var parser = new USAddressParser(
            TestUtility.CreateParserContext("842 E 1700 S, Salt Lake City, UT 84105", ParserPattern.NorthAmerica));
            ParseResultCollection prc = parser.Parse(0);
            Assert.AreEqual(1, prc.Count);
            var address = prc[0].Value as Address;

            Assert.AreEqual("SALT LAKE CITY", address.City);
            Assert.AreEqual("842", address.Number);
            Assert.AreEqual("S", address.Postdirectional);
            Assert.AreEqual("E", address.Predirectional);
            Assert.AreEqual(null, address.SecondaryNumber);
            Assert.AreEqual(null, address.SecondaryUnit);
            Assert.AreEqual("UT", address.State);
            Assert.AreEqual("1700", address.Street);
            Assert.AreEqual("842 E 1700 S", address.StreetLine);
            Assert.AreEqual(null, address.Suffix);
            Assert.AreEqual("84105", address.Zip);
        }
Пример #9
0
        public void CanParseFractionalAddress()
        {
            var parser = new USAddressParser(
            TestUtility.CreateParserContext("123 1/2 MAIN ST, RICHMOND, VA 23221", ParserPattern.NorthAmerica));
            ParseResultCollection prc = parser.Parse(0);
            Assert.AreEqual(1, prc.Count);
            var address = prc[0].Value as Address;

            Assert.AreEqual("RICHMOND", address.City);
            Assert.AreEqual("123 1/2", address.Number);
            Assert.AreEqual(null, address.Postdirectional);
            Assert.AreEqual(null, address.Predirectional);
            Assert.AreEqual(null, address.SecondaryNumber);
            Assert.AreEqual(null, address.SecondaryUnit);
            Assert.AreEqual("VA", address.State);
            Assert.AreEqual("MAIN", address.Street);
            Assert.AreEqual("123 1/2 MAIN ST", address.StreetLine);
            Assert.AreEqual("ST", address.Suffix);
            Assert.AreEqual("23221", address.Zip);
        }
Пример #10
0
        public void CanParseAddressWithRangelessSecondaryUnit()
        {
            var parser = new USAddressParser(
            TestUtility.CreateParserContext("1050 Broadway Penthouse, New York, NY 10001", ParserPattern.NorthAmerica));
            ParseResultCollection prc = parser.Parse(0);
            Assert.AreEqual(1, prc.Count);
            var address = prc[0].Value as Address;

            Assert.AreEqual("NEW YORK", address.City);
            Assert.AreEqual("1050", address.Number);
            Assert.AreEqual(null, address.Postdirectional);
            Assert.AreEqual(null, address.Predirectional);
            Assert.AreEqual(null, address.SecondaryNumber);
            Assert.AreEqual("PH", address.SecondaryUnit);
            Assert.AreEqual("NY", address.State);
            Assert.AreEqual("BROADWAY", address.Street);
            Assert.AreEqual("1050 BROADWAY PH", address.StreetLine);
            Assert.AreEqual(null, address.Suffix);
            Assert.AreEqual("10001", address.Zip);
        }
Пример #11
0
        public void CanParseAddressWithRangedUnitAttachedToNumber()
        {
            var parser = new USAddressParser(
            TestUtility.CreateParserContext("403D BERRYFIELD LANE CHESAPEAKE VA 23224", ParserPattern.NorthAmerica));
            ParseResultCollection prc = parser.Parse(0);
            Assert.AreEqual(1, prc.Count);
            var address = prc[0].Value as Address;

            Assert.AreEqual("CHESAPEAKE", address.City);
            Assert.AreEqual("403", address.Number);
            Assert.AreEqual(null, address.Postdirectional);
            Assert.AreEqual(null, address.Predirectional);
            Assert.AreEqual("D", address.SecondaryNumber);
            Assert.AreEqual("APT", address.SecondaryUnit);
            Assert.AreEqual("VA", address.State);
            Assert.AreEqual("BERRYFIELD", address.Street);
            Assert.AreEqual("403 BERRYFIELD LN APT D", address.StreetLine);
            Assert.AreEqual("LN", address.Suffix);
            Assert.AreEqual("23224", address.Zip);
        }