Skip to content

Commit dd99189

Browse files
committed
improved search
1 parent 4cfae59 commit dd99189

File tree

6 files changed

+32
-13
lines changed

6 files changed

+32
-13
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Lei Ma
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

dataherb/core/base.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ def download(self):
117117
except Exception as e:
118118
logger.error(f"Error loading remote file: {file_path}")
119119
data = file_string_io
120-
if file_format.lower() == "json":
120+
elif file_format.lower() == "json":
121121
if isinstance(file_content, bytes):
122122
file_string_io = io.StringIO(file_content.decode(file_decode))
123123
else:
124124
file_string_io = file_content
125125

126126
try:
127-
data = pd.read_csv(file_path)
127+
data = pd.read_json(file_path)
128128
except Exception as e:
129129
logger.error(f"Error loading remote file: {file_path}")
130130
data = file_string_io
@@ -135,7 +135,8 @@ def download(self):
135135
"name": file.get("name"),
136136
"description": file.get("description"),
137137
"path": file_path,
138-
"df": data
138+
"file": file.get("path"),
139+
"data": data
139140
})
140141

141142
return data_files

dataherb/core/search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ def search_by_ids_in_flora(flora, ids):
5252
herbs = []
5353
for herb in flora:
5454
if herb.id in ids:
55-
herb_search_score = {
55+
herb_matched = {
5656
"herb": herb,
5757
"id": herb.id
5858
}
59-
herbs.append(herb_search_score)
59+
herbs.append(herb_matched)
6060

6161
return herbs

dataherb/dataherb.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ def herb(self, id):
9999
return herb.download()
100100

101101

102-
def main():
103-
104-
return
105-
106102

107103
if __name__ == "__main__":
108104

@@ -112,8 +108,7 @@ def main():
112108
print(geo_datasets)
113109

114110
print(
115-
dataherb.herb("ecb_currency_exchange")
111+
dataherb.herb("geonames_timezone")
116112
)
117113

118-
119114
logger.debug("End of Game")

environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ dependencies:
99
- pyyaml>=5.3
1010
- pip
1111
- pip:
12-
- fuzzywuzzy==0.18.0
12+
- fuzzywuzzy>=0.18.0
13+
- python-Levenshtein>=0.12

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pandas>=0.23
22
requests>=2.22.0
33
fuzzywuzzy>=0.18.0
4-
pyyaml>=1.18
4+
pyyaml>=1.18
5+
python-Levenshtein>=0.12

0 commit comments

Comments
 (0)