Skip to content

Commit

Permalink
ntrial2
Browse files Browse the repository at this point in the history
  • Loading branch information
SumukhSKashyap committed May 14, 2024
1 parent 2cad496 commit badd06b
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
# Define language IDs
lang_ids = ["af", "az", "bg", "cs", "da", "de", "el", "en", "es", "fi", "fr", "hr", "it", "ko", "nl", "no", "pl", "ru", "ur", "zh"]

# Check if output directory exists, create if not
output_directory = get_output_directory(str(Path(__file__).parent))
Path(output_directory).mkdir(parents=True, exist_ok=True)

# Convert text data into character n-grams
vectorizer = CountVectorizer(analyzer='char', ngram_range=(3, 3))
X = vectorizer.fit_transform(text_validation['text'])
Expand All @@ -35,8 +39,11 @@
# Create DataFrame for predictions
prediction_df = pd.DataFrame({'lang': prediction, 'id': text_validation['id']})

# saving the prediction
output_directory = get_output_directory(str(Path(__file__).parent))
prediction_df.to_json(
Path(output_directory) / "predictions.jsonl", orient="records", lines=True
)
try:
# saving the prediction
prediction_df.to_json(
Path(output_directory) / "predictions.jsonl", orient="records", lines=True
)
print("Predictions saved successfully.")
except Exception as e:
print(f"Error occurred while saving predictions: {e}")

0 comments on commit badd06b

Please sign in to comment.