<commit_before>from geosupport import Geocode
import unittest
import csv
from os import path

g = Geocode()

here = path.abspath(path.dirname(__file__))

address_data = path.join(here,'data','addresses.csv')


class TestGeocodeObject(unittest.TestCase):

    def test_bin(self):
        with open(address_data) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.bin(row['Bin'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_bbl(self):
        with open(address_data) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.bbl(row['BoroCode'], row['Block'], row['Lot'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_parser(self):
        with open(address_data) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                in_data = row['SingleAddress'] + ', ' + row['City'] + ', ' + row['ZipCode']
                r = g.address(address=in_data)
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_parser_with_borocode(self):
        with open(address_data) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.address(address=row['SingleAddress'], boro=row['BoroCode'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)


    def test_address_parser_with_boroname(self):
        with open(address_data) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.address(address=row['SingleAddress'], boro=row['BoroName'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_parser_with_zipcode(self):
        with open(address_data) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.address(address=row['SingleAddress'], zip_code=row['ZipCode'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_with_borocode(self):
        with open(address_data) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.address(house_number=row['BuildingNumber'], street_name=row['Street'], boro=row['BoroCode'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_with_boroname(self):
        with open(address_data) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.address(house_number=row['BuildingNumber'], street_name=row['Street'], boro=row['BoroName'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_with_zipcode(self):
        with open(address_data) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.address(house_number=row['BuildingNumber'], street_name=row['Street'], zip_code=row['ZipCode'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)


if __name__ == "__main__":
    unittest.main()<commit_msg>add place method and new data<commit_after>from geosupport import Geocode
import unittest
import csv
from os import path

g = Geocode()

here = path.abspath(path.dirname(__file__))

address_parsed = path.join(here, 'data', 'addresses_parsed.csv')

address_unparsed = path.join(here, 'data', 'addresses_unparsed.csv')

bbl_bin = path.join(here, 'data', 'BBL_BIN.csv')

placenames = path.join(here, 'data', 'placenames.csv')

# cross_streets = path.join(here, 'data', 'cross_streets.csv')


class TestGeocodeObject(unittest.TestCase):

    def test_place(self):
        with open(placenames) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.place(row['Landmark'], row['Borough'])
                self.assertTrue(len(r['Latitude']) > 1 or len(r['Longitude']))

    def test_bin(self):
        with open(bbl_bin) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.bin(row['BIN'])
                self.assertTrue(len(r['Latitude']) > 1 or len(r['Longitude']))

    def test_bbl(self):
        with open(bbl_bin) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.bbl(row['BORO CODE'], row['BLOCK'], row['LOT'])
                print(r['Message'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_parser(self):
        with open(address_unparsed) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                in_data = row['ADDRESS'] + ', ' + row['CITY'] + ', ' + row['ZIPCODE']
                r = g.address(address=in_data)
                print(r['Message'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_parser_with_boroname(self):
        with open(address_unparsed) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.address(address=row['ADDRESS'], boro=row['BORO NAME'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_parser_with_zipcode(self):
        with open(address_unparsed) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.address(address=row['ADDRESS'], zip_code=row['ZIPCODE'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_with_borocode(self):
        with open(address_parsed) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.address(house_number=row['BUILDING'], street_name=row['STREET'], boro=row['BORO CODE'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_with_boroname(self):
        with open(address_parsed) as csvfile:
            reader = csv.DictReader(csvfile)
            for row in reader:
                r = g.address(house_number=row['BUILDING'], street_name=row['STREET'], boro=row['BORO'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)

    def test_address_with_zipcode(self):
        with open(address_parsed) as csvfile:
            reader = csv.DictReader(csvfile)

            for row in reader:
                r = g.address(house_number=row['BUILDING'], street_name=row['STREET'], zip_code=row['ZIPCODE'])
                print(r['Message'])
                self.assertFalse(len(r['Latitude']) < 1 or len(r['Longitude']) < 1)


if __name__ == "__main__":
    unittest.main()
{'fraction_non_alphanumeric': 0.1369217589948601, 'fraction_numerical': 0.0048543689320388345, 'mean_word_length': 2.554033485540335, 'pattern_counts': {'":': 2, '<': 35, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6501010', 'n_tokens_mistral': 2296, 'n_tokens_neox': 2160, 'n_words': 446}