-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_dogs.py
More file actions
24 lines (20 loc) · 727 Bytes
/
Copy pathget_dogs.py
File metadata and controls
24 lines (20 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# list_functions.py
import datasets
from datasets import *
import inspect
def has_dog(column):
for row in column:
if "dog" in row:
return row
return False
# Iterate through all the names in the module
for name, obj in inspect.getmembers(datasets):
# Check if the object is a function and starts with capital letter
if inspect.isfunction(obj) and name[0].isupper():
dataset = globals()[name]() # run function with the same name
captions = dataset['caption'].dropna()
dog = has_dog(captions)
if dog:
print(f"Dataset {name} has a dog in the caption: {dog}")
else:
print(f"Dataset {name} does not have a dog in the caption")