File size: 1,664 Bytes
bd9b5f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

import traceback
from pyabsa import download_all_available_datasets, available_checkpoints
from pyabsa import AspectTermExtraction as ATEPC

# Model Initialization

# 1. Download all required datasets for PyABSA
# This operation might take some time the first time it's run as it downloads
# various datasets used by PyABSA's models.
print("PyABSA: Starting dataset download (if not already present)...")
try:
    download_all_available_datasets()
    print("PyABSA: Datasets download complete.")
except Exception as e:
    print(f"PyABSA: Error during dataset download: {e}")
    print(traceback.format_exc())
    # Continue execution even if download fails, models might still work if data is cached.

# 2. Initialize the Aspect Term Extraction and Polarity Classification (ATEPC) model
# Using 'multilingual' checkpoint for broad language support.
print("\nPyABSA: Initializing Aspect Term Extractor (ATEPC) with 'multilingual' checkpoint...")
try:
    aspect_extractor = ATEPC.AspectExtractor(checkpoint="multilingual")
    print("PyABSA: Aspect Term Extractor initialized successfully.")
except Exception as e:
    print(f"PyABSA: FAILED to initialize Aspect Term Extractor: {e}")
    print(traceback.format_exc())
    aspect_extractor = None

# 3. No ASTE model initialization as requested.

# 4. Print available checkpoints for ATEPC for verification purposes
print("\nPyABSA: Available ATEPC checkpoints:")
try:
    available_checkpoints("ATEPC", True) # Changed to ATEPC specific checkpoints
except Exception as e:
    print(f"PyABSA: Could not retrieve ATEPC checkpoints: {e}")
    print(traceback.format_exc())