Instructions to use openpecha/aligner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openpecha/aligner with Transformers:
# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("openpecha/aligner") model = AutoModelForSeq2SeqLM.from_pretrained("openpecha/aligner") - Notebooks
- Google Colab
- Kaggle
Update handler.py
Browse files- handler.py +18 -4
handler.py
CHANGED
|
@@ -105,9 +105,24 @@ def convert_raw_align_to_tm(align_fn: Path, tm_path: Path):
|
|
| 105 |
logging.debug("[INFO] Conerting raw alignment to TM repo...")
|
| 106 |
|
| 107 |
def load_alignment(fn: Path):
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
if not content:
|
| 112 |
return []
|
| 113 |
|
|
@@ -136,7 +151,6 @@ def convert_raw_align_to_tm(align_fn: Path, tm_path: Path):
|
|
| 136 |
for bo_seg, en_seg in load_alignment(align_fn):
|
| 137 |
bo_file.write(bo_seg + "\n")
|
| 138 |
en_file.write(en_seg + "\n")
|
| 139 |
-
logging.info(f"BO !!! {bo_seg}")
|
| 140 |
return tm_path
|
| 141 |
|
| 142 |
|
|
|
|
| 105 |
logging.debug("[INFO] Conerting raw alignment to TM repo...")
|
| 106 |
|
| 107 |
def load_alignment(fn: Path):
|
| 108 |
+
try:
|
| 109 |
+
# Ensure fn is a Path object
|
| 110 |
+
fn = Path(fn)
|
| 111 |
+
|
| 112 |
+
# Check if the file exists
|
| 113 |
+
if not fn.exists():
|
| 114 |
+
logging.error(f"File does not exist: {fn}")
|
| 115 |
+
return
|
| 116 |
+
|
| 117 |
+
# Read and log the content of the file
|
| 118 |
+
content = fn.read_text()
|
| 119 |
+
if content:
|
| 120 |
+
logging.info(f"Content of {fn.name}: {content[:10]}...") # Log first 100 characters
|
| 121 |
+
else:
|
| 122 |
+
logging.warning(f"File is empty: {fn}")
|
| 123 |
+
|
| 124 |
+
except Exception as e:
|
| 125 |
+
logging.error(f"Error while reading file {fn}: {e}")
|
| 126 |
if not content:
|
| 127 |
return []
|
| 128 |
|
|
|
|
| 151 |
for bo_seg, en_seg in load_alignment(align_fn):
|
| 152 |
bo_file.write(bo_seg + "\n")
|
| 153 |
en_file.write(en_seg + "\n")
|
|
|
|
| 154 |
return tm_path
|
| 155 |
|
| 156 |
|