File size: 9,301 Bytes
e448c28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
import streamlit as st
import pandas as pd
import time
from scholarly import scholarly
import plotly.express as px

# Set layout to wide
st.set_page_config(
    page_title="Automatic Faculty Research & Publication Inspector",
    layout="wide",
    initial_sidebar_state="expanded"
)

# Known Scopus publishers or identifiers
SCOPUS_PUBLISHERS = ["Elsevier", "Springer", "IEEE", "Wiley", "Taylor & Francis", "SAGE"]

# CSS for dark theme styling
dark_theme_css = """
<style>
body {
    background-color: #121212;
    color: #E0E0E0;
}
h1, h2, h3, h4, h5, h6 {
    color: #BB86FC;
}
.stApp {
    background-color: #121212;
    color: #E0E0E0;
}
.stMetric {
    background-color: #1F1B24;
    border: 1px solid #BB86FC;
    border-radius: 8px;
    padding: 10px;
    color: #E0E0E0;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.5);
}
.stButton > button {
    background-color: #BB86FC;
    color: #121212;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    transition: transform 0.2s ease;
}
.stButton > button:hover {
    transform: scale(1.1);
    background-color: #3700B3;
}
.stDataFrame {
    background-color: #1F1B24;
    border: 1px solid #BB86FC;
    border-radius: 8px;
    color: #E0E0E0;
}
.stMarkdown {
    color: #E0E0E0;
}
</style>
"""

# Apply the CSS
st.markdown(dark_theme_css, unsafe_allow_html=True)

# Function to classify publications
def classify_publications(publications):
    scopus_count, non_scopus_count, ieee_count, springer_count, patent_count = 0, 0, 0, 0, 0
    yearly_publications = {year: 0 for year in range(2019, 2025)}  # Years 2019–2024

    for pub in publications:
        try:
            pub_details = scholarly.fill(pub)
            time.sleep(1)
            source = pub_details.get("bib", {}).get("source", "").lower()
            publisher = pub_details.get("bib", {}).get("publisher", "").lower()
            title = pub_details.get("bib", {}).get("title", "").lower()
            pub_year = pub_details.get("bib", {}).get("pub_year", None)

            if pub_year in yearly_publications:
                yearly_publications[pub_year] += 1

            if "ieee" in source or "ieee" in publisher:
                ieee_count += 1

            if "springer" in source or "springer" in publisher:
                springer_count += 1

            if any(publisher_keyword.lower() in publisher for publisher_keyword in SCOPUS_PUBLISHERS):
                scopus_count += 1
            elif "journal" in source or "conference" in source:
                scopus_count += 1
            else:
                non_scopus_count += 1

            if "patent" in title:
                patent_count += 1
        except Exception as e:
            st.warning(f"Skipping publication due to error: {e}")

    return scopus_count, non_scopus_count, ieee_count, springer_count, patent_count, yearly_publications

# Function to extract scholar data
def extract_scholar_data_by_name(scholar_name):
    try:
        search_results = scholarly.search_author(scholar_name)
        scholar_data = None

        for result in search_results:
            scholar_data = scholarly.fill(result)
            time.sleep(1)
            break

        if not scholar_data:
            return None

        metrics = scholar_data.get("cites_per_year", {})
        area_of_interest = scholar_data.get("interests", [])
        h_index = scholar_data.get("hindex", 0)
        i10_index = scholar_data.get("i10index", 0)

        scopus_pubs, non_scopus_pubs, ieee_pubs, springer_pubs, patent_count, yearly_publications = classify_publications(
            scholar_data.get("publications", [])
        )

        return {
            "Scholar Name": scholar_data.get("name", "N/A"),
            "Citations": sum(metrics.values()),
            "h-index": h_index,
            "i10-index": i10_index,
            "Citation Impact": round(sum(metrics.values()) / len(metrics), 2) if metrics else 0,
            "Publications": yearly_publications,
            "Metrics": metrics,
            "Area of Interest": area_of_interest,
            "Scopus Publications": scopus_pubs,
            "Non-Scopus Publications": non_scopus_pubs,
            "IEEE Publications": ieee_pubs,
            "Springer Publications": springer_pubs,
            "Patents": patent_count,
            "Publications Data": scholar_data.get("publications", []),
        }
    except Exception as e:
        st.error(f"Error occurred: {e}")
        return None

# Streamlit App
st.title("πŸ” **Automatic Faculty Research & Publication Inspector**")
st.markdown("---")

# Input field for faculty name
st.subheader("**Input Faculty Name**")
scholar_name = st.text_input("Enter Faculty Name:")

if st.button("Fetch Data"):
    if scholar_name:
        st.info("Fetching data... Please wait.")
        scholar_data = extract_scholar_data_by_name(scholar_name)

        if scholar_data:
            # Display Key Metrics
            st.markdown("### **πŸ“Š Key Metrics**")
            col1, col2, col3, col4 = st.columns(4)
            col1.metric("πŸ“Œ Total Citations", scholar_data["Citations"])
            col2.metric("πŸ“Œ h-index", scholar_data["h-index"])
            col3.metric("πŸ“Œ i10-index", scholar_data["i10-index"])
            col4.metric("πŸ“Œ Citation Impact", scholar_data["Citation Impact"])

            # Display Trends
            st.markdown("### **πŸ“ˆ Trends**")
            trend_col1, trend_col2 = st.columns(2)
            with trend_col1:
                st.markdown("**Citations Over the Years**")
                citation_trend = pd.DataFrame(scholar_data["Metrics"].items(), columns=["Year", "Citations"])
                st.bar_chart(citation_trend.set_index("Year"))
            with trend_col2:
                st.markdown("**Publications Over the Years**")
                publication_trend = pd.DataFrame(scholar_data["Publications"].items(), columns=["Year", "Publications"])
                st.bar_chart(publication_trend.set_index("Year"))

            # Scholar Detailed Metrics
            st.markdown("### **πŸ“‹ Scholar Metrics**")
            scholar_details_df = pd.DataFrame([{
                "Scholar Name": scholar_data["Scholar Name"],
                "Total Citations": scholar_data["Citations"],
                "h-index": scholar_data["h-index"],
                "i10-index": scholar_data["i10-index"],
                "Citation Impact": scholar_data["Citation Impact"],
                "Scopus Publications": scholar_data["Scopus Publications"],
                "Non-Scopus Publications": scholar_data["Non-Scopus Publications"],
                "IEEE Publications": scholar_data["IEEE Publications"],
                "Springer Publications": scholar_data["Springer Publications"],
                "Patents": scholar_data["Patents"],
            }])
            st.dataframe(scholar_details_df)

            # Area of Interest & Pie Charts
            st.markdown("### **πŸ“Œ Insights**")
            left, middle, right = st.columns([1, 1.5, 1.5])

            with left:
                st.markdown("**Areas of Interest**")
                if scholar_data["Area of Interest"]:
                    for interest in scholar_data["Area of Interest"]:
                        st.button(interest)
                else:
                    st.info("No areas of interest available.")

            with middle:
                st.markdown("**Scopus vs Non-Scopus Publications**")
                scopus_data = {
                    "Type": ["Scopus", "Non-Scopus"],
                    "Count": [scholar_data["Scopus Publications"], scholar_data["Non-Scopus Publications"]],
                }
                fig1 = px.pie(scopus_data, names="Type", values="Count", title="Scopus vs Non-Scopus")
                st.plotly_chart(fig1)

            with right:
                st.markdown("**IEEE vs Springer Publications**")
                ieee_data = {
                    "Type": ["IEEE", "Springer"],
                    "Count": [scholar_data["IEEE Publications"], scholar_data["Springer Publications"]],
                }
                fig2 = px.pie(ieee_data, names="Type", values="Count", title="IEEE vs Springer")
                st.plotly_chart(fig2)

            # Display Publications Table
            st.markdown("### **πŸ“š Publications**")
            pub_data = []
            for pub in scholar_data["Publications Data"][:5]:
                pub_details = scholarly.fill(pub)
                pub_data.append({
                    "Publication": pub_details.get("bib", {}).get("title", "N/A"),
                    "Citations": pub_details.get("num_citations", 0),
                    "Year": pub_details.get("bib", {}).get("pub_year", "N/A"),
                })
                time.sleep(1)

            if pub_data:
                pub_df = pd.DataFrame(pub_data)
                st.dataframe(pub_df)

                st.download_button(
                    label="Download Publications Data as CSV",
                    data=pub_df.to_csv(index=False),
                    file_name="publications.csv",
                    mime="text/csv",
                )
        else:
            st.warning("No data found for the provided faculty name.")


    else:
        st.error("Please enter a valid faculty name.")