-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update Leva gem to the latest version
Update the Leva gem to the latest stable version to ensure compatibility with the latest dependencies and take advantage of any bug fixes or new features. This update will improve the overall performance and functionality of the application.
- Loading branch information
1 parent
bc1acec
commit 55b934e
Showing
5 changed files
with
32 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class SentimentAccuracyEval < Leva::BaseEval | ||
# @param prediction [String] The prediction to evaluate | ||
# @param record [TextContent] The record to evaluate | ||
# @return [Leva::Result] The result of the evaluation | ||
def evaluate(prediction, text_content) | ||
score = prediction == text_content.expected_label ? 1.0 : 0.0 | ||
|
||
Leva::Result.new( | ||
label: "sentiment_accuracy", | ||
score: score | ||
) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
class SentimentRun < Leva::BaseRun | ||
# @param text [String] The text to analyze | ||
# @return [String] The sentiment analysis result | ||
def execute(record) | ||
# Your model execution logic here | ||
# This could involve calling an API, running a local model, etc. | ||
# Return the model's output | ||
# Executes sentiment analysis on the given text content. | ||
# | ||
# @param text_content [TextContent] The text to analyze | ||
# @return [String] The sentiment analysis result (Positive, Neutral, or Negative) | ||
def execute(text_content) | ||
text = text_content.text.downcase | ||
|
||
case | ||
when text.match?(/\b(love|great|excellent|awesome|fantastic)\b/) | ||
"Positive" | ||
when text.match?(/\b(hate|terrible|awful|horrible|bad)\b/) | ||
"Negative" | ||
else | ||
"Neutral" | ||
end | ||
end | ||
end |