Sina1138 commited on
Commit ·
3f33192
1
Parent(s): 60b3e47
Enhance CLI functionality across multiple scripts:
Browse files- Add argument parsing for year selection in polarity and topic scoring scripts.
- Implement auto-detection of available years from data files.
- Update dataset building process to support flexible year ranges and improve output file naming.
- Refactor data processing script to streamline execution and enhance user guidance.
- alternative_polarity/deberta/deberta_v3_base_polarity.py +19 -1
- alternative_topic/deberta/deberta_topic.py +19 -1
- alternative_topic/scideberta/scideberta_topic.py +19 -1
- config.py +35 -19
- fetch_iclr_data.py +9 -15
- interface/Demo.py +24 -13
- process_new_data.sh +17 -30
- run_scoring.py +4 -3
- scibert/scibert_polarity/scibert_polarity.py +20 -1
- scibert/scibert_topic/scibert_topic.py +19 -1
- scored_reviews_builder.py +39 -35
alternative_polarity/deberta/deberta_v3_base_polarity.py
CHANGED
|
@@ -92,4 +92,22 @@ def find_polarity(start_year=2017, end_year=2021):
|
|
| 92 |
|
| 93 |
|
| 94 |
if __name__ == "__main__":
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
|
| 94 |
if __name__ == "__main__":
|
| 95 |
+
import argparse
|
| 96 |
+
parser = argparse.ArgumentParser(description="Run polarity scoring with DeBERTa")
|
| 97 |
+
parser.add_argument("--start-year", type=int, default=None, help="Start year (default: auto-detect)")
|
| 98 |
+
parser.add_argument("--end-year", type=int, default=None, help="End year (default: auto-detect)")
|
| 99 |
+
args = parser.parse_args()
|
| 100 |
+
|
| 101 |
+
if args.start_year is not None and args.end_year is not None:
|
| 102 |
+
find_polarity(start_year=args.start_year, end_year=args.end_year)
|
| 103 |
+
else:
|
| 104 |
+
import re
|
| 105 |
+
available = sorted(
|
| 106 |
+
int(re.search(r'all_reviews_(\d{4})\.csv', f.name).group(1))
|
| 107 |
+
for f in DATA_DIR.glob("all_reviews_*.csv")
|
| 108 |
+
if re.search(r'all_reviews_(\d{4})\.csv', f.name)
|
| 109 |
+
)
|
| 110 |
+
if available:
|
| 111 |
+
find_polarity(start_year=min(available), end_year=max(available))
|
| 112 |
+
else:
|
| 113 |
+
print("No data files found in", DATA_DIR)
|
alternative_topic/deberta/deberta_topic.py
CHANGED
|
@@ -89,4 +89,22 @@ def find_topic(start_year=2017, end_year=2021):
|
|
| 89 |
|
| 90 |
|
| 91 |
if __name__ == "__main__":
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
|
| 91 |
if __name__ == "__main__":
|
| 92 |
+
import argparse
|
| 93 |
+
parser = argparse.ArgumentParser(description="Run topic scoring with DeBERTa")
|
| 94 |
+
parser.add_argument("--start-year", type=int, default=None, help="Start year (default: auto-detect)")
|
| 95 |
+
parser.add_argument("--end-year", type=int, default=None, help="End year (default: auto-detect)")
|
| 96 |
+
args = parser.parse_args()
|
| 97 |
+
|
| 98 |
+
if args.start_year is not None and args.end_year is not None:
|
| 99 |
+
find_topic(start_year=args.start_year, end_year=args.end_year)
|
| 100 |
+
else:
|
| 101 |
+
import re
|
| 102 |
+
available = sorted(
|
| 103 |
+
int(re.search(r'all_reviews_(\d{4})\.csv', f.name).group(1))
|
| 104 |
+
for f in DATA_DIR.glob("all_reviews_*.csv")
|
| 105 |
+
if re.search(r'all_reviews_(\d{4})\.csv', f.name)
|
| 106 |
+
)
|
| 107 |
+
if available:
|
| 108 |
+
find_topic(start_year=min(available), end_year=max(available))
|
| 109 |
+
else:
|
| 110 |
+
print("No data files found in", DATA_DIR)
|
alternative_topic/scideberta/scideberta_topic.py
CHANGED
|
@@ -89,4 +89,22 @@ def find_topic(start_year=2017, end_year=2021):
|
|
| 89 |
|
| 90 |
|
| 91 |
if __name__ == "__main__":
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
|
| 91 |
if __name__ == "__main__":
|
| 92 |
+
import argparse
|
| 93 |
+
parser = argparse.ArgumentParser(description="Run topic scoring with SciDeBERTa")
|
| 94 |
+
parser.add_argument("--start-year", type=int, default=None, help="Start year (default: auto-detect)")
|
| 95 |
+
parser.add_argument("--end-year", type=int, default=None, help="End year (default: auto-detect)")
|
| 96 |
+
args = parser.parse_args()
|
| 97 |
+
|
| 98 |
+
if args.start_year is not None and args.end_year is not None:
|
| 99 |
+
find_topic(start_year=args.start_year, end_year=args.end_year)
|
| 100 |
+
else:
|
| 101 |
+
import re
|
| 102 |
+
available = sorted(
|
| 103 |
+
int(re.search(r'all_reviews_(\d{4})\.csv', f.name).group(1))
|
| 104 |
+
for f in DATA_DIR.glob("all_reviews_*.csv")
|
| 105 |
+
if re.search(r'all_reviews_(\d{4})\.csv', f.name)
|
| 106 |
+
)
|
| 107 |
+
if available:
|
| 108 |
+
find_topic(start_year=min(available), end_year=max(available))
|
| 109 |
+
else:
|
| 110 |
+
print("No data files found in", DATA_DIR)
|
config.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
Centralized configuration for ReView data pipeline.
|
| 3 |
"""
|
| 4 |
|
|
|
|
| 5 |
from pathlib import Path
|
| 6 |
|
| 7 |
|
|
@@ -16,18 +17,8 @@ class Config:
|
|
| 16 |
POLARITY_DIR = OUTPUT_DIR / "polarity_scored"
|
| 17 |
TOPIC_DIR = OUTPUT_DIR / "topic_scored"
|
| 18 |
|
| 19 |
-
# Year ranges - LEGACY DATA (reference only, for documentation)
|
| 20 |
-
LEGACY_START_YEAR = 2017
|
| 21 |
-
LEGACY_END_YEAR = 2021
|
| 22 |
-
|
| 23 |
-
# Year ranges - NEW DATA (reference only, actual years are auto-detected)
|
| 24 |
-
# The system can work with any year - these are just for documentation
|
| 25 |
-
NEW_DATA_START_YEAR = 2020
|
| 26 |
-
NEW_DATA_END_YEAR = 2025
|
| 27 |
-
|
| 28 |
# Output files
|
| 29 |
LEGACY_PREPROCESSED = OUTPUT_DIR / "preprocessed_scored_reviews.csv"
|
| 30 |
-
NEW_PREPROCESSED = OUTPUT_DIR / "preprocessed_scored_reviews_2020-2025.csv"
|
| 31 |
|
| 32 |
# Feature flags
|
| 33 |
INCLUDE_REBUTTALS = True
|
|
@@ -43,16 +34,41 @@ class Config:
|
|
| 43 |
RSA_MODEL = "sshleifer/distilbart-cnn-12-3" # For GLIMPSE
|
| 44 |
|
| 45 |
@classmethod
|
| 46 |
-
def
|
| 47 |
-
"""
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
@classmethod
|
| 51 |
-
def
|
| 52 |
-
"""Get
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
@classmethod
|
| 56 |
-
def
|
| 57 |
-
"""
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
Centralized configuration for ReView data pipeline.
|
| 3 |
"""
|
| 4 |
|
| 5 |
+
import re
|
| 6 |
from pathlib import Path
|
| 7 |
|
| 8 |
|
|
|
|
| 17 |
POLARITY_DIR = OUTPUT_DIR / "polarity_scored"
|
| 18 |
TOPIC_DIR = OUTPUT_DIR / "topic_scored"
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# Output files
|
| 21 |
LEGACY_PREPROCESSED = OUTPUT_DIR / "preprocessed_scored_reviews.csv"
|
|
|
|
| 22 |
|
| 23 |
# Feature flags
|
| 24 |
INCLUDE_REBUTTALS = True
|
|
|
|
| 34 |
RSA_MODEL = "sshleifer/distilbart-cnn-12-3" # For GLIMPSE
|
| 35 |
|
| 36 |
@classmethod
|
| 37 |
+
def find_available_years(cls, data_dir: Path = None) -> list:
|
| 38 |
+
"""Auto-detect available years from all_reviews_YYYY.csv files in data_dir."""
|
| 39 |
+
if data_dir is None:
|
| 40 |
+
data_dir = cls.OUTPUT_DIR
|
| 41 |
+
years = []
|
| 42 |
+
for f in data_dir.glob("all_reviews_*.csv"):
|
| 43 |
+
match = re.search(r'all_reviews_(\d{4})\.csv', f.name)
|
| 44 |
+
if match:
|
| 45 |
+
years.append(int(match.group(1)))
|
| 46 |
+
return sorted(years)
|
| 47 |
|
| 48 |
@classmethod
|
| 49 |
+
def get_preprocessed_path(cls, years: list = None) -> Path:
|
| 50 |
+
"""Get output CSV path based on the year range.
|
| 51 |
+
|
| 52 |
+
If years is None, auto-detects from data directory.
|
| 53 |
+
Produces filenames like preprocessed_scored_reviews_2020-2025.csv
|
| 54 |
+
"""
|
| 55 |
+
if years is None:
|
| 56 |
+
years = cls.find_available_years()
|
| 57 |
+
if not years:
|
| 58 |
+
# Fallback to a generic name if no years detected
|
| 59 |
+
return cls.OUTPUT_DIR / "preprocessed_scored_reviews.csv"
|
| 60 |
+
return cls.OUTPUT_DIR / f"preprocessed_scored_reviews_{min(years)}-{max(years)}.csv"
|
| 61 |
|
| 62 |
@classmethod
|
| 63 |
+
def find_preprocessed_csv(cls) -> Path:
|
| 64 |
+
"""Find the most recent preprocessed_scored_reviews_*.csv in the output dir.
|
| 65 |
+
|
| 66 |
+
Useful for the interface to locate the dataset without knowing the year range.
|
| 67 |
+
"""
|
| 68 |
+
candidates = sorted(cls.OUTPUT_DIR.glob("preprocessed_scored_reviews_*.csv"))
|
| 69 |
+
if candidates:
|
| 70 |
+
return candidates[-1] # Last alphabetically = latest year range
|
| 71 |
+
# Fallback to legacy
|
| 72 |
+
if cls.LEGACY_PREPROCESSED.exists():
|
| 73 |
+
return cls.LEGACY_PREPROCESSED
|
| 74 |
+
return cls.OUTPUT_DIR / "preprocessed_scored_reviews.csv"
|
fetch_iclr_data.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
-
Fetch ICLR
|
| 3 |
Based on DISAPERE data_prep_lib.py patterns.
|
| 4 |
"""
|
| 5 |
|
|
@@ -46,16 +46,7 @@ class ICLRDataFetcher:
|
|
| 46 |
|
| 47 |
def get_venue_id(self, year: int) -> str:
|
| 48 |
"""Get OpenReview venue ID for ICLR in a given year."""
|
| 49 |
-
|
| 50 |
-
venue_formats = {
|
| 51 |
-
2020: 'ICLR.cc/2020/Conference',
|
| 52 |
-
2021: 'ICLR.cc/2021/Conference',
|
| 53 |
-
2022: 'ICLR.cc/2022/Conference',
|
| 54 |
-
2023: 'ICLR.cc/2023/Conference',
|
| 55 |
-
2024: 'ICLR.cc/2024/Conference',
|
| 56 |
-
2025: 'ICLR.cc/2025/Conference',
|
| 57 |
-
}
|
| 58 |
-
return venue_formats.get(year, f'ICLR.cc/{year}/Conference')
|
| 59 |
|
| 60 |
def fetch_submissions(self, venue_id: str) -> List:
|
| 61 |
"""Fetch all submissions for a venue."""
|
|
@@ -222,7 +213,7 @@ class ICLRDataFetcher:
|
|
| 222 |
Fetch all ICLR data for a given year.
|
| 223 |
|
| 224 |
Args:
|
| 225 |
-
year: Conference year
|
| 226 |
output_path: Where to save CSV (optional)
|
| 227 |
limit: Limit number of papers to process (for testing)
|
| 228 |
|
|
@@ -301,8 +292,11 @@ class ICLRDataFetcher:
|
|
| 301 |
|
| 302 |
|
| 303 |
def main():
|
| 304 |
-
"""Fetch ICLR
|
| 305 |
import argparse
|
|
|
|
|
|
|
|
|
|
| 306 |
|
| 307 |
parser = argparse.ArgumentParser(
|
| 308 |
description='Fetch ICLR review data from OpenReview API'
|
|
@@ -321,8 +315,8 @@ def main():
|
|
| 321 |
parser.add_argument(
|
| 322 |
'--end-year',
|
| 323 |
type=int,
|
| 324 |
-
default=
|
| 325 |
-
help='End year for batch fetch (default:
|
| 326 |
)
|
| 327 |
parser.add_argument(
|
| 328 |
'--output-dir',
|
|
|
|
| 1 |
"""
|
| 2 |
+
Fetch ICLR reviews and rebuttals from OpenReview API.
|
| 3 |
Based on DISAPERE data_prep_lib.py patterns.
|
| 4 |
"""
|
| 5 |
|
|
|
|
| 46 |
|
| 47 |
def get_venue_id(self, year: int) -> str:
|
| 48 |
"""Get OpenReview venue ID for ICLR in a given year."""
|
| 49 |
+
return f'ICLR.cc/{year}/Conference'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
def fetch_submissions(self, venue_id: str) -> List:
|
| 52 |
"""Fetch all submissions for a venue."""
|
|
|
|
| 213 |
Fetch all ICLR data for a given year.
|
| 214 |
|
| 215 |
Args:
|
| 216 |
+
year: Conference year
|
| 217 |
output_path: Where to save CSV (optional)
|
| 218 |
limit: Limit number of papers to process (for testing)
|
| 219 |
|
|
|
|
| 292 |
|
| 293 |
|
| 294 |
def main():
|
| 295 |
+
"""Fetch ICLR data with rebuttals."""
|
| 296 |
import argparse
|
| 297 |
+
from datetime import datetime
|
| 298 |
+
|
| 299 |
+
current_year = datetime.now().year
|
| 300 |
|
| 301 |
parser = argparse.ArgumentParser(
|
| 302 |
description='Fetch ICLR review data from OpenReview API'
|
|
|
|
| 315 |
parser.add_argument(
|
| 316 |
'--end-year',
|
| 317 |
type=int,
|
| 318 |
+
default=current_year,
|
| 319 |
+
help=f'End year for batch fetch (default: {current_year})'
|
| 320 |
)
|
| 321 |
parser.add_argument(
|
| 322 |
'--output-dir',
|
interface/Demo.py
CHANGED
|
@@ -12,13 +12,23 @@ import pandas as pd
|
|
| 12 |
import ast
|
| 13 |
from tqdm import tqdm
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
def
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
if not csv_path.exists():
|
| 21 |
-
return [], pd.DataFrame()
|
| 22 |
|
| 23 |
df = pd.read_csv(csv_path)
|
| 24 |
tqdm.pandas(desc="Parsing scored_dict")
|
|
@@ -39,11 +49,12 @@ years_new, df_new = load_scored_reviews_with_rebuttals()
|
|
| 39 |
|
| 40 |
if df_new.empty:
|
| 41 |
raise FileNotFoundError(
|
| 42 |
-
"
|
| 43 |
)
|
| 44 |
|
| 45 |
# Use new data only
|
| 46 |
years, all_scored_reviews_df = years_new, df_new
|
|
|
|
| 47 |
|
| 48 |
# -----------------------------------
|
| 49 |
# Pre-processed Tab
|
|
@@ -71,11 +82,11 @@ topic_color_map = {
|
|
| 71 |
|
| 72 |
|
| 73 |
# GLIMPSE Home/Description Page
|
| 74 |
-
glimpse_description = """
|
| 75 |
# ReView: A Tool for Visualizing and Analyzing Scientific Reviews
|
| 76 |
## **Overview**
|
| 77 |
ReView is a visualization tool designed to assist **area chairs** and **researchers** in efficiently analyzing scholarly reviews. The interface offers two main ways to explore scholarly reviews:
|
| 78 |
-
- Pre-Processed Reviews: Explore real peer reviews from ICLR (
|
| 79 |
- Interactive Tab: Enter your own reviews and view them analyzed in real time using the same NLP-powered highlighting options.
|
| 80 |
All reviews are shown in their original, unaltered form, with visual overlays to help identify key insights such as disagreements, sentiment and common themes—reducing cognitive load and scrolling effort.
|
| 81 |
---
|
|
@@ -87,12 +98,12 @@ All reviews are shown in their original, unaltered form, with visual overlays to
|
|
| 87 |
## **Highlighting Options**
|
| 88 |
- *Agreement:* Identifies both shared and conflicting points across reviews, helping to surface consensus and disagreement.
|
| 89 |
- *Polarity:* Highlights positive and negative sentiments within the reviews to reveal tone and stance.
|
| 90 |
-
- *Topic:* Organizes the review sentences by their discussed topics, ensuring coverage of diverse reviewer perspectives and improving clarity.
|
| 91 |
---
|
| 92 |
### How to Use ReView
|
| 93 |
ReView offers two main ways to explore peer reviews: using pre-processed reviews or by entering your own.
|
| 94 |
-
####
|
| 95 |
-
Use this tab to explore reviews from ICLR (
|
| 96 |
1. **Select a conference year** from the dropdown menu on the right.
|
| 97 |
2. **Navigate between submissions** using the *Next* and *Previous* buttons on the left.
|
| 98 |
3. **Choose a highlighting view** using the radio buttons:
|
|
@@ -100,7 +111,7 @@ Use this tab to explore reviews from ICLR (2017–2021):
|
|
| 100 |
- **Agreement**: Highlights consensus points in **red** and disagreements in **purple**.
|
| 101 |
- **Polarity**: Highlights **positive** sentiment in **green** and **negative** sentiment in **red**.
|
| 102 |
- **Topic**: Highlights comments by discussion topic using color-coded labels.
|
| 103 |
-
####
|
| 104 |
Use this tab to analyze your own review text:
|
| 105 |
1. **Enter up to three reviews** in the input fields labeled *Review 1*, *Review 2*, and *Review 3*.
|
| 106 |
2. **Click "Process"** to analyze the input (average processing time: ~42 seconds).
|
|
|
|
| 12 |
import ast
|
| 13 |
from tqdm import tqdm
|
| 14 |
|
| 15 |
+
# Auto-detect the preprocessed dataset CSV
|
| 16 |
+
def _find_preprocessed_csv() -> Path:
|
| 17 |
+
"""Find the most recent preprocessed_scored_reviews_*.csv in the data dir."""
|
| 18 |
+
data_dir = BASE_DIR / "data"
|
| 19 |
+
candidates = sorted(data_dir.glob("preprocessed_scored_reviews_*.csv"))
|
| 20 |
+
if candidates:
|
| 21 |
+
return candidates[-1] # Last alphabetically = latest year range
|
| 22 |
+
return data_dir / "preprocessed_scored_reviews.csv"
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def load_scored_reviews_with_rebuttals(csv_path: Path = None):
|
| 26 |
+
"""Load dataset with rebuttal metadata. Auto-detects CSV if no path given."""
|
| 27 |
+
if csv_path is None:
|
| 28 |
+
csv_path = _find_preprocessed_csv()
|
| 29 |
+
|
| 30 |
if not csv_path.exists():
|
| 31 |
+
return [], pd.DataFrame()
|
| 32 |
|
| 33 |
df = pd.read_csv(csv_path)
|
| 34 |
tqdm.pandas(desc="Parsing scored_dict")
|
|
|
|
| 49 |
|
| 50 |
if df_new.empty:
|
| 51 |
raise FileNotFoundError(
|
| 52 |
+
f"No preprocessed dataset found. Run the pipeline first (process_new_data.sh)."
|
| 53 |
)
|
| 54 |
|
| 55 |
# Use new data only
|
| 56 |
years, all_scored_reviews_df = years_new, df_new
|
| 57 |
+
year_range_str = f"{min(years)}–{max(years)}" if years else "N/A"
|
| 58 |
|
| 59 |
# -----------------------------------
|
| 60 |
# Pre-processed Tab
|
|
|
|
| 82 |
|
| 83 |
|
| 84 |
# GLIMPSE Home/Description Page
|
| 85 |
+
glimpse_description = f"""
|
| 86 |
# ReView: A Tool for Visualizing and Analyzing Scientific Reviews
|
| 87 |
## **Overview**
|
| 88 |
ReView is a visualization tool designed to assist **area chairs** and **researchers** in efficiently analyzing scholarly reviews. The interface offers two main ways to explore scholarly reviews:
|
| 89 |
+
- Pre-Processed Reviews: Explore real peer reviews from ICLR ({year_range_str}) with structured visualizations of sentiment, topics, and reviewer agreement.
|
| 90 |
- Interactive Tab: Enter your own reviews and view them analyzed in real time using the same NLP-powered highlighting options.
|
| 91 |
All reviews are shown in their original, unaltered form, with visual overlays to help identify key insights such as disagreements, sentiment and common themes—reducing cognitive load and scrolling effort.
|
| 92 |
---
|
|
|
|
| 98 |
## **Highlighting Options**
|
| 99 |
- *Agreement:* Identifies both shared and conflicting points across reviews, helping to surface consensus and disagreement.
|
| 100 |
- *Polarity:* Highlights positive and negative sentiments within the reviews to reveal tone and stance.
|
| 101 |
+
- *Topic:* Organizes the review sentences by their discussed topics, ensuring coverage of diverse reviewer perspectives and improving clarity.
|
| 102 |
---
|
| 103 |
### How to Use ReView
|
| 104 |
ReView offers two main ways to explore peer reviews: using pre-processed reviews or by entering your own.
|
| 105 |
+
#### Pre-Processed Reviews Tab
|
| 106 |
+
Use this tab to explore reviews from ICLR ({year_range_str}):
|
| 107 |
1. **Select a conference year** from the dropdown menu on the right.
|
| 108 |
2. **Navigate between submissions** using the *Next* and *Previous* buttons on the left.
|
| 109 |
3. **Choose a highlighting view** using the radio buttons:
|
|
|
|
| 111 |
- **Agreement**: Highlights consensus points in **red** and disagreements in **purple**.
|
| 112 |
- **Polarity**: Highlights **positive** sentiment in **green** and **negative** sentiment in **red**.
|
| 113 |
- **Topic**: Highlights comments by discussion topic using color-coded labels.
|
| 114 |
+
#### Interactive Tab
|
| 115 |
Use this tab to analyze your own review text:
|
| 116 |
1. **Enter up to three reviews** in the input fields labeled *Review 1*, *Review 2*, and *Review 3*.
|
| 117 |
2. **Click "Process"** to analyze the input (average processing time: ~42 seconds).
|
process_new_data.sh
CHANGED
|
@@ -1,36 +1,23 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e # Exit on error
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
echo "========================================"
|
| 5 |
-
echo "
|
| 6 |
echo "========================================"
|
| 7 |
|
| 8 |
-
#
|
| 9 |
-
|
| 10 |
-
python preprocess_data.py
|
| 11 |
-
|
| 12 |
-
# Step 2: GLIMPSE scoring (RSA consensuality)
|
| 13 |
-
echo "Step 2: Running GLIMPSE consensuality scoring..."
|
| 14 |
-
python run_glimpse_scoring.py
|
| 15 |
-
|
| 16 |
-
# Step 3: Polarity scoring
|
| 17 |
-
echo "Step 3: Running polarity classification..."
|
| 18 |
-
cd scibert/scibert_polarity
|
| 19 |
-
# Note: May need to modify the year range in the script
|
| 20 |
-
echo "⚠ Polarity scoring may need year range adjustment in scibert_polarity.py"
|
| 21 |
-
# python scibert_polarity.py --start-year 2022 --end-year 2025
|
| 22 |
-
cd ../..
|
| 23 |
-
|
| 24 |
-
# Step 4: Topic scoring
|
| 25 |
-
echo "Step 4: Running topic classification..."
|
| 26 |
-
cd scibert/scibert_topic
|
| 27 |
-
# Note: May need to modify the year range in the script
|
| 28 |
-
echo "⚠ Topic scoring may need year range adjustment in scibert_topic.py"
|
| 29 |
-
# python scibert_topic.py --start-year 2022 --end-year 2025
|
| 30 |
-
cd ../..
|
| 31 |
-
|
| 32 |
-
# Step 5: Build final preprocessed file
|
| 33 |
-
echo "Step 5: Building preprocessed dataset..."
|
| 34 |
-
python scored_reviews_builder.py --new-data
|
| 35 |
-
|
| 36 |
-
echo "✓ Pipeline complete! Check data/preprocessed_scored_reviews_2020-2025.csv"
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -e # Exit on error
|
| 3 |
|
| 4 |
+
# ============================================================
|
| 5 |
+
# ReView Data Processing Pipeline
|
| 6 |
+
# ============================================================
|
| 7 |
+
# Processes ICLR review data through the full scoring pipeline.
|
| 8 |
+
# Auto-detects available years from data/ directory by default,
|
| 9 |
+
# or accepts explicit year arguments.
|
| 10 |
+
#
|
| 11 |
+
# Usage:
|
| 12 |
+
# ./process_new_data.sh # Auto-detect all available years
|
| 13 |
+
# ./process_new_data.sh --year 2026 # Process a single year
|
| 14 |
+
# ./process_new_data.sh --year 2026 --force # Reprocess even if results exist
|
| 15 |
+
# ./process_new_data.sh --help # Show all options
|
| 16 |
+
# ============================================================
|
| 17 |
+
|
| 18 |
echo "========================================"
|
| 19 |
+
echo "ReView Data Processing Pipeline"
|
| 20 |
echo "========================================"
|
| 21 |
|
| 22 |
+
# Forward all arguments to the unified scoring pipeline
|
| 23 |
+
python run_scoring.py "$@"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
run_scoring.py
CHANGED
|
@@ -35,7 +35,7 @@ from preprocess_data import preprocess_reviews_with_rebuttals
|
|
| 35 |
from run_glimpse_scoring import run_glimpse_pipeline
|
| 36 |
from run_polarity_scoring import score_reviews_polarity
|
| 37 |
from run_topic_scoring import score_reviews_topic
|
| 38 |
-
from scored_reviews_builder import
|
| 39 |
|
| 40 |
|
| 41 |
def run_full_pipeline(
|
|
@@ -112,7 +112,7 @@ def run_full_pipeline(
|
|
| 112 |
|
| 113 |
# Step 4: Build Final Dataset (always rebuild to ensure latest data)
|
| 114 |
print(f"\n[4/5] Building Final Integrated Dataset...")
|
| 115 |
-
|
| 116 |
|
| 117 |
print(f"\n[5/5] ✓ Pipeline Complete")
|
| 118 |
|
|
@@ -248,7 +248,8 @@ def main():
|
|
| 248 |
print(f"✓ Successful: {success_count}/{len(years)} years")
|
| 249 |
if failed_years:
|
| 250 |
print(f"✗ Failed: {failed_years}")
|
| 251 |
-
|
|
|
|
| 252 |
print(f" Ready for interface: python interface/Demo.py")
|
| 253 |
print(f"{'='*60}\n")
|
| 254 |
|
|
|
|
| 35 |
from run_glimpse_scoring import run_glimpse_pipeline
|
| 36 |
from run_polarity_scoring import score_reviews_polarity
|
| 37 |
from run_topic_scoring import score_reviews_topic
|
| 38 |
+
from scored_reviews_builder import build_dataset
|
| 39 |
|
| 40 |
|
| 41 |
def run_full_pipeline(
|
|
|
|
| 112 |
|
| 113 |
# Step 4: Build Final Dataset (always rebuild to ensure latest data)
|
| 114 |
print(f"\n[4/5] Building Final Integrated Dataset...")
|
| 115 |
+
build_dataset()
|
| 116 |
|
| 117 |
print(f"\n[5/5] ✓ Pipeline Complete")
|
| 118 |
|
|
|
|
| 248 |
print(f"✓ Successful: {success_count}/{len(years)} years")
|
| 249 |
if failed_years:
|
| 250 |
print(f"✗ Failed: {failed_years}")
|
| 251 |
+
output_path = Config.find_preprocessed_csv()
|
| 252 |
+
print(f"\n📊 Final dataset: {output_path.relative_to(Config.BASE_DIR)}")
|
| 253 |
print(f" Ready for interface: python interface/Demo.py")
|
| 254 |
print(f"{'='*60}\n")
|
| 255 |
|
scibert/scibert_polarity/scibert_polarity.py
CHANGED
|
@@ -69,4 +69,23 @@ def find_polarity(start_year=2017, end_year=2021):
|
|
| 69 |
|
| 70 |
|
| 71 |
if __name__ == "__main__":
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
|
| 71 |
if __name__ == "__main__":
|
| 72 |
+
import argparse
|
| 73 |
+
parser = argparse.ArgumentParser(description="Run polarity scoring with SciBERT")
|
| 74 |
+
parser.add_argument("--start-year", type=int, default=None, help="Start year (default: auto-detect)")
|
| 75 |
+
parser.add_argument("--end-year", type=int, default=None, help="End year (default: auto-detect)")
|
| 76 |
+
args = parser.parse_args()
|
| 77 |
+
|
| 78 |
+
if args.start_year is not None and args.end_year is not None:
|
| 79 |
+
find_polarity(start_year=args.start_year, end_year=args.end_year)
|
| 80 |
+
else:
|
| 81 |
+
# Auto-detect from available processed data files
|
| 82 |
+
import re
|
| 83 |
+
available = sorted(
|
| 84 |
+
int(re.search(r'all_reviews_(\d{4})\.csv', f.name).group(1))
|
| 85 |
+
for f in DATA_DIR.glob("all_reviews_*.csv")
|
| 86 |
+
if re.search(r'all_reviews_(\d{4})\.csv', f.name)
|
| 87 |
+
)
|
| 88 |
+
if available:
|
| 89 |
+
find_polarity(start_year=min(available), end_year=max(available))
|
| 90 |
+
else:
|
| 91 |
+
print("No data files found in", DATA_DIR)
|
scibert/scibert_topic/scibert_topic.py
CHANGED
|
@@ -89,4 +89,22 @@ def find_topic(start_year=2017, end_year=2021):
|
|
| 89 |
|
| 90 |
|
| 91 |
if __name__ == "__main__":
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
|
| 91 |
if __name__ == "__main__":
|
| 92 |
+
import argparse
|
| 93 |
+
parser = argparse.ArgumentParser(description="Run topic scoring with SciBERT")
|
| 94 |
+
parser.add_argument("--start-year", type=int, default=None, help="Start year (default: auto-detect)")
|
| 95 |
+
parser.add_argument("--end-year", type=int, default=None, help="End year (default: auto-detect)")
|
| 96 |
+
args = parser.parse_args()
|
| 97 |
+
|
| 98 |
+
if args.start_year is not None and args.end_year is not None:
|
| 99 |
+
find_topic(start_year=args.start_year, end_year=args.end_year)
|
| 100 |
+
else:
|
| 101 |
+
import re
|
| 102 |
+
available = sorted(
|
| 103 |
+
int(re.search(r'all_reviews_(\d{4})\.csv', f.name).group(1))
|
| 104 |
+
for f in DATA_DIR.glob("all_reviews_*.csv")
|
| 105 |
+
if re.search(r'all_reviews_(\d{4})\.csv', f.name)
|
| 106 |
+
)
|
| 107 |
+
if available:
|
| 108 |
+
find_topic(start_year=min(available), end_year=max(available))
|
| 109 |
+
else:
|
| 110 |
+
print("No data files found in", DATA_DIR)
|
scored_reviews_builder.py
CHANGED
|
@@ -121,22 +121,36 @@ def load_scored_reviews(csv_path: Path = BASE_DIR / "data" / "preprocessed_score
|
|
| 121 |
return years, df
|
| 122 |
|
| 123 |
|
| 124 |
-
def
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
input_dir: Path = BASE_DIR / "data" / "processed", # Independent from glimpse!
|
| 128 |
scored_csv_dir: Path = BASE_DIR / "data",
|
| 129 |
polarity_dir: Path = BASE_DIR / "data" / "polarity_scored",
|
| 130 |
topic_dir: Path = BASE_DIR / "data" / "topic_scored",
|
| 131 |
-
output_csv_path: Path =
|
| 132 |
):
|
| 133 |
"""
|
| 134 |
-
Build preprocessed dataset for
|
| 135 |
-
|
| 136 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
all_scored_reviews = []
|
| 138 |
|
| 139 |
-
for year in
|
| 140 |
print(f"Processing {year}...")
|
| 141 |
try:
|
| 142 |
original_csv_path = input_dir / f"all_reviews_{year}.csv"
|
|
@@ -170,7 +184,7 @@ def build_2020_2025_dataset(
|
|
| 170 |
if pd.isna(rebuttal):
|
| 171 |
rebuttal = ''
|
| 172 |
rebuttal_str = str(rebuttal) if rebuttal else ''
|
| 173 |
-
|
| 174 |
review_metadata[review_id] = {
|
| 175 |
'rebuttal': rebuttal_str,
|
| 176 |
'paper_title': row.get('paper_title', '') if 'paper_title' in original_df.columns else '',
|
|
@@ -188,40 +202,30 @@ def build_2020_2025_dataset(
|
|
| 188 |
import traceback
|
| 189 |
traceback.print_exc()
|
| 190 |
|
| 191 |
-
# Save to
|
| 192 |
df = pd.DataFrame(all_scored_reviews)
|
| 193 |
df.to_csv(output_csv_path, index=False)
|
| 194 |
-
print(f"\n✓
|
| 195 |
-
print(f" Years included: {
|
| 196 |
print(f" File size: {output_csv_path.stat().st_size / 1024 / 1024:.1f} MB")
|
| 197 |
|
| 198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
if __name__ == "__main__":
|
| 200 |
-
|
| 201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
-
if
|
| 204 |
-
|
| 205 |
else:
|
| 206 |
# Original behavior for legacy data
|
| 207 |
-
# save_all_scored_reviews()
|
| 208 |
years, all_scored_reviews_df = load_scored_reviews()
|
| 209 |
-
print
|
| 210 |
-
|
| 211 |
-
# Debugging sample output
|
| 212 |
-
sample_year = 2021
|
| 213 |
-
|
| 214 |
-
sample_df = all_scored_reviews_df[all_scored_reviews_df["year"] == sample_year]
|
| 215 |
-
review_dict = sample_df["scored_dict"].iloc[0]
|
| 216 |
-
|
| 217 |
-
print(f"\n=== Sample Review from {sample_year} ===")
|
| 218 |
-
for review_id, sentence_data_list in review_dict.items():
|
| 219 |
-
print(f"\nReview ID: {review_id}")
|
| 220 |
-
for sentence_dict in sentence_data_list:
|
| 221 |
-
for sentence, data in sentence_dict.items():
|
| 222 |
-
print(f" Sentence: {sentence}")
|
| 223 |
-
for key, value in data.items():
|
| 224 |
-
print(f" → {key}: {value}")
|
| 225 |
-
break # print only the first review's sentences
|
| 226 |
-
break # only one review
|
| 227 |
|
|
|
|
| 121 |
return years, df
|
| 122 |
|
| 123 |
|
| 124 |
+
def build_dataset(
|
| 125 |
+
years: list = None,
|
| 126 |
+
input_dir: Path = BASE_DIR / "data" / "processed",
|
|
|
|
| 127 |
scored_csv_dir: Path = BASE_DIR / "data",
|
| 128 |
polarity_dir: Path = BASE_DIR / "data" / "polarity_scored",
|
| 129 |
topic_dir: Path = BASE_DIR / "data" / "topic_scored",
|
| 130 |
+
output_csv_path: Path = None,
|
| 131 |
):
|
| 132 |
"""
|
| 133 |
+
Build preprocessed dataset with rebuttals for any set of years.
|
| 134 |
+
Auto-detects available years if none specified.
|
| 135 |
"""
|
| 136 |
+
if years is None:
|
| 137 |
+
# Auto-detect from processed data directory
|
| 138 |
+
import re
|
| 139 |
+
years = sorted(
|
| 140 |
+
int(re.search(r'all_reviews_(\d{4})\.csv', f.name).group(1))
|
| 141 |
+
for f in input_dir.glob("all_reviews_*.csv")
|
| 142 |
+
if re.search(r'all_reviews_(\d{4})\.csv', f.name)
|
| 143 |
+
)
|
| 144 |
+
if not years:
|
| 145 |
+
print("⚠ No processed data files found to build dataset from")
|
| 146 |
+
return
|
| 147 |
+
|
| 148 |
+
if output_csv_path is None:
|
| 149 |
+
output_csv_path = BASE_DIR / "data" / f"preprocessed_scored_reviews_{min(years)}-{max(years)}.csv"
|
| 150 |
+
|
| 151 |
all_scored_reviews = []
|
| 152 |
|
| 153 |
+
for year in years:
|
| 154 |
print(f"Processing {year}...")
|
| 155 |
try:
|
| 156 |
original_csv_path = input_dir / f"all_reviews_{year}.csv"
|
|
|
|
| 184 |
if pd.isna(rebuttal):
|
| 185 |
rebuttal = ''
|
| 186 |
rebuttal_str = str(rebuttal) if rebuttal else ''
|
| 187 |
+
|
| 188 |
review_metadata[review_id] = {
|
| 189 |
'rebuttal': rebuttal_str,
|
| 190 |
'paper_title': row.get('paper_title', '') if 'paper_title' in original_df.columns else '',
|
|
|
|
| 202 |
import traceback
|
| 203 |
traceback.print_exc()
|
| 204 |
|
| 205 |
+
# Save to CSV
|
| 206 |
df = pd.DataFrame(all_scored_reviews)
|
| 207 |
df.to_csv(output_csv_path, index=False)
|
| 208 |
+
print(f"\n✓ Dataset saved to: {output_csv_path}")
|
| 209 |
+
print(f" Years included: {min(years)}-{max(years)}")
|
| 210 |
print(f" File size: {output_csv_path.stat().st_size / 1024 / 1024:.1f} MB")
|
| 211 |
|
| 212 |
|
| 213 |
+
# Backwards-compatible alias
|
| 214 |
+
build_2020_2025_dataset = build_dataset
|
| 215 |
+
|
| 216 |
+
|
| 217 |
if __name__ == "__main__":
|
| 218 |
+
import argparse
|
| 219 |
+
|
| 220 |
+
parser = argparse.ArgumentParser(description="Build preprocessed scored reviews dataset")
|
| 221 |
+
parser.add_argument("--new-data", action="store_true", help="Build dataset (auto-detects years)")
|
| 222 |
+
parser.add_argument("--years", type=int, nargs="+", help="Specific years to include (default: auto-detect)")
|
| 223 |
+
args = parser.parse_args()
|
| 224 |
|
| 225 |
+
if args.new_data or args.years:
|
| 226 |
+
build_dataset(years=args.years)
|
| 227 |
else:
|
| 228 |
# Original behavior for legacy data
|
|
|
|
| 229 |
years, all_scored_reviews_df = load_scored_reviews()
|
| 230 |
+
print(years)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
|