forked from krille-chan/fluffychat
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: moving to lemma def over contextual translation
- Loading branch information
Showing
14 changed files
with
302 additions
and
302 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// this should be an enum eventually though we're using a class for now | ||
|
||
class Morphs {} |
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
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
47 changes: 47 additions & 0 deletions
47
lib/pangea/repo/practice/word_meaning_activity_generator.dart
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,47 @@ | ||
import 'package:fluffychat/pangea/enum/activity_type_enum.dart'; | ||
import 'package:fluffychat/pangea/enum/construct_type_enum.dart'; | ||
import 'package:fluffychat/pangea/models/practice_activities.dart/message_activity_request.dart'; | ||
import 'package:fluffychat/pangea/models/practice_activities.dart/multiple_choice_activity_model.dart'; | ||
import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_model.dart'; | ||
import 'package:fluffychat/pangea/repo/lemma_definition_repo.dart'; | ||
|
||
class WordMeaningActivityGenerator { | ||
Future<MessageActivityResponse> get( | ||
MessageActivityRequest req, | ||
) async { | ||
final ConstructIdentifier lemmaId = ConstructIdentifier( | ||
lemma: req.targetTokens[0].lemma.text, | ||
type: ConstructTypeEnum.vocab, | ||
category: req.targetTokens[0].pos, | ||
); | ||
|
||
final LemmaDefinitionRequest lemmaDefReq = LemmaDefinitionRequest( | ||
lemma: lemmaId.lemma, | ||
partOfSpeech: lemmaId.category, | ||
|
||
/// This assumes that the user's L2 is the language of the lemma | ||
lemmaLang: req.userL2, | ||
userL1: req.userL1, | ||
); | ||
|
||
final res = await LemmaDictionaryRepo.get(lemmaDefReq); | ||
|
||
final choices = | ||
LemmaDictionaryRepo.getDistractorDefinitions(lemmaDefReq, 3); | ||
|
||
return MessageActivityResponse( | ||
activity: PracticeActivityModel( | ||
tgtConstructs: [lemmaId], | ||
targetTokens: req.targetTokens, | ||
langCode: req.userL2, | ||
activityType: ActivityTypeEnum.wordMeaning, | ||
content: ActivityContent( | ||
question: "?", | ||
choices: choices, | ||
answers: [res.definition], | ||
spanDisplayDetails: null, | ||
), | ||
), | ||
); | ||
} | ||
} |
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
Oops, something went wrong.