convert choreo record into morph GA uses on send
This commit is contained in:
parent
1f5d66e203
commit
4a2a8bf7bd
4 changed files with 67 additions and 7 deletions
|
|
@ -683,11 +683,18 @@ class ChatController extends State<ChatPageWithRoom>
|
|||
AnalyticsStream(
|
||||
eventId: msgEventId,
|
||||
roomId: room.id,
|
||||
constructs: originalSent!.vocabUses(
|
||||
choreo: choreo,
|
||||
tokens: tokensSent!.tokens,
|
||||
metadata: metadata,
|
||||
),
|
||||
constructs: [
|
||||
...originalSent!.vocabUses(
|
||||
choreo: choreo,
|
||||
tokens: tokensSent!.tokens,
|
||||
metadata: metadata,
|
||||
),
|
||||
...originalSent.morphConstructUses(
|
||||
choreo: choreo,
|
||||
tokens: tokensSent.tokens,
|
||||
metadata: metadata,
|
||||
),
|
||||
],
|
||||
origin: AnalyticsUpdateOrigin.sendMessage,
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@ extension ConstructUseTypeExtension on ConstructUseTypeEnum {
|
|||
case ConstructUseTypeEnum.corWL:
|
||||
return 3;
|
||||
|
||||
case ConstructUseTypeEnum.ga:
|
||||
case ConstructUseTypeEnum.corIGC:
|
||||
return 2;
|
||||
|
||||
|
|
@ -115,6 +114,9 @@ extension ConstructUseTypeExtension on ConstructUseTypeEnum {
|
|||
case ConstructUseTypeEnum.nan:
|
||||
return 0;
|
||||
|
||||
case ConstructUseTypeEnum.ga:
|
||||
return -1;
|
||||
|
||||
case ConstructUseTypeEnum.incIt:
|
||||
case ConstructUseTypeEnum.incIGC:
|
||||
return -2;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class PangeaMatch {
|
|||
}
|
||||
|
||||
bool isOffsetInMatchSpan(int offset) =>
|
||||
offset >= match.offset && offset <= match.offset + match.length;
|
||||
offset >= match.offset && offset < match.offset + match.length;
|
||||
|
||||
Color get underlineColor {
|
||||
switch (match.rule?.id ?? "unknown") {
|
||||
|
|
|
|||
|
|
@ -131,6 +131,57 @@ class PangeaRepresentation {
|
|||
return uses;
|
||||
}
|
||||
|
||||
List<OneConstructUse> morphConstructUses({
|
||||
required List<PangeaToken> tokens,
|
||||
Event? event,
|
||||
ConstructUseMetaData? metadata,
|
||||
ChoreoRecord? choreo,
|
||||
}) {
|
||||
final List<OneConstructUse> uses = [];
|
||||
|
||||
if (event?.roomId == null && metadata?.roomId == null) {
|
||||
return uses;
|
||||
}
|
||||
|
||||
if (choreo == null) {
|
||||
return uses;
|
||||
}
|
||||
|
||||
metadata ??= ConstructUseMetaData(
|
||||
roomId: event!.roomId!,
|
||||
eventId: event.eventId,
|
||||
timeStamp: event.originServerTs,
|
||||
);
|
||||
|
||||
for (final step in choreo.choreoSteps) {
|
||||
if (step.acceptedOrIgnoredMatch?.status == PangeaMatchStatus.accepted) {
|
||||
final List<PangeaToken> tokensForMatch = [];
|
||||
for (final token in tokens) {
|
||||
if (step.acceptedOrIgnoredMatch!.isOffsetInMatchSpan(
|
||||
token.text.offset,
|
||||
)) {
|
||||
tokensForMatch.add(token);
|
||||
}
|
||||
}
|
||||
|
||||
for (final token in tokensForMatch) {
|
||||
token.morph.forEach((key, value) {
|
||||
uses.add(
|
||||
OneConstructUse(
|
||||
useType: ConstructUseTypeEnum.ga,
|
||||
lemma: value,
|
||||
categories: [key],
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata!,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return uses;
|
||||
}
|
||||
|
||||
/// Returns a [OneConstructUse] for the given [token]
|
||||
/// If there is no [choreo], the [token] is
|
||||
/// considered to be a [ConstructUseTypeEnum.wa] as long as it matches the target language.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue