Spaces:
Sleeping
Sleeping
Update
Browse files- paper_list.py +28 -1
- papers.csv +2 -2
paper_list.py
CHANGED
@@ -1,10 +1,14 @@
|
|
1 |
from __future__ import annotations
|
2 |
|
|
|
3 |
import pandas as pd
|
|
|
|
|
4 |
|
5 |
|
6 |
class PaperList:
|
7 |
def __init__(self):
|
|
|
8 |
self.table = pd.read_csv('papers.csv')
|
9 |
self._preprcess_table()
|
10 |
|
@@ -20,7 +24,30 @@ class PaperList:
|
|
20 |
<td width="4%">HF Datasets</td>
|
21 |
</tr>'''
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
def _preprcess_table(self) -> None:
|
|
|
|
|
24 |
self.table['title_lowercase'] = self.table.title.str.lower()
|
25 |
|
26 |
rows = []
|
@@ -53,7 +80,7 @@ class PaperList:
|
|
53 |
|
54 |
def render(self, search_query: str, case_sensitive: bool,
|
55 |
filter_names: list[str]) -> tuple[int, str]:
|
56 |
-
df = self.table
|
57 |
if search_query:
|
58 |
if case_sensitive:
|
59 |
df = df[df.title.str.contains(search_query)]
|
|
|
1 |
from __future__ import annotations
|
2 |
|
3 |
+
import numpy as np
|
4 |
import pandas as pd
|
5 |
+
import requests
|
6 |
+
from huggingface_hub.hf_api import SpaceInfo
|
7 |
|
8 |
|
9 |
class PaperList:
|
10 |
def __init__(self):
|
11 |
+
self.organization_name = 'ICML2022'
|
12 |
self.table = pd.read_csv('papers.csv')
|
13 |
self._preprcess_table()
|
14 |
|
|
|
24 |
<td width="4%">HF Datasets</td>
|
25 |
</tr>'''
|
26 |
|
27 |
+
@staticmethod
|
28 |
+
def load_space_info(author: str) -> list[SpaceInfo]:
|
29 |
+
path = 'https://huggingface.co/api/spaces'
|
30 |
+
r = requests.get(path, params={'author': author})
|
31 |
+
d = r.json()
|
32 |
+
return [SpaceInfo(**x) for x in d]
|
33 |
+
|
34 |
+
def add_spaces_to_table(self, organization_name: str,
|
35 |
+
df: pd.DataFrame) -> pd.DataFrame:
|
36 |
+
spaces = self.load_space_info(organization_name)
|
37 |
+
name2space = {
|
38 |
+
s.id.split('/')[1].lower(): f'https://huggingface.co/spaces/{s.id}'
|
39 |
+
for s in spaces
|
40 |
+
}
|
41 |
+
df['hf_space'] = df.loc[:, ['hf_space', 'github']].apply(
|
42 |
+
lambda x: x[0] if isinstance(x[0], str) else name2space.get(
|
43 |
+
x[1].split('/')[-1].lower()
|
44 |
+
if isinstance(x[1], str) else '', np.nan),
|
45 |
+
axis=1)
|
46 |
+
return df
|
47 |
+
|
48 |
def _preprcess_table(self) -> None:
|
49 |
+
self.table = self.add_spaces_to_table(self.organization_name,
|
50 |
+
self.table)
|
51 |
self.table['title_lowercase'] = self.table.title.str.lower()
|
52 |
|
53 |
rows = []
|
|
|
80 |
|
81 |
def render(self, search_query: str, case_sensitive: bool,
|
82 |
filter_names: list[str]) -> tuple[int, str]:
|
83 |
+
df = self.add_spaces_to_table(self.organization_name, self.table)
|
84 |
if search_query:
|
85 |
if case_sensitive:
|
86 |
df = df[df.title.str.contains(search_query)]
|
papers.csv
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8264ef7763719ee8f8aeebc99926f97e8338eaeb70864242171c4cdb21930ac2
|
3 |
+
size 335399
|