Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added table and code to filter possible locations
- Loading branch information
1 parent
d822122
commit 93d83ec
Showing
6 changed files
with
112 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#This file compares the "places" table with "geonames" table with plain old contains. | ||
from database.database import Database | ||
from difflib import SequenceMatcher | ||
|
||
def similar(a, b): | ||
return SequenceMatcher(None, a, b).ratio() | ||
|
||
|
||
db = Database("twitter-geo") | ||
|
||
#user_id, userlocations (in an array) | ||
user_locations = db.select_user_locations() | ||
#geonameid, name, asciiname, latitude, longitude(in an array) | ||
db_locations = db.select_database_locations() | ||
#userlocation, db_location(either name or asciiname), latitude, longitude | ||
found_locations = [] | ||
for user_location in user_locations: | ||
print ("Parsing: ", user_location) | ||
max = 0 | ||
max_geoid = 0 | ||
for db_location in db_locations: | ||
#if not(db_location[0] == None) and user_location in db_location[0]: | ||
if not(db_location[1] == None): | ||
ratio = similar(user_location[1], db_location[1]) | ||
if ratio == 1: | ||
db.set_filtered_location(user_location[0], db_location[0], ratio) | ||
break | ||
elif ratio > max: | ||
max = ratio | ||
max_geoid = db_location[0] | ||
|
||
#elif not(db_location[1] == None) and user_location in db_location[1]: | ||
elif not(db_location[2] == None): | ||
ratio = similar(user_location[1], db_location[2]) | ||
if ratio == 1: | ||
db.set_filtered_location(user_location[0], db_location[0], ratio) | ||
break | ||
elif ratio > max: | ||
max = ratio | ||
max_geoid = db_location[0] | ||
|
||
if (max_geoid != 0): | ||
db.set_filtered_location(user_location[0], max_geoid, max) | ||
|
||
print ("WE ARE DONE") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters