Merge pull request #665 from pangeachat/add-category-to-constructs

Add category to constructs
This commit is contained in:
ggurdin 2024-09-06 10:52:51 -04:00 committed by GitHub
commit 765d536daa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 56 additions and 61 deletions

View file

@ -201,22 +201,19 @@ class MyAnalyticsController extends BaseController {
)
.toList();
final List<String> morphs = tokens
.map((t) => t.morph.values)
.expand((m) => m)
.cast<String>()
.toList();
uses.addAll(
morphs.map(
(morph) => OneConstructUse(
useType: useType,
lemma: morph,
constructType: ConstructTypeEnum.morph,
metadata: metadata,
),
),
);
for (final token in tokens) {
for (final entry in token.morph.entries) {
uses.add(
OneConstructUse(
useType: useType,
lemma: entry.value,
categories: [entry.key],
constructType: ConstructTypeEnum.morph,
metadata: metadata,
),
);
}
}
final level = _pangeaController.analytics.level;
addLocalMessage('draft$roomID', uses).then(

View file

@ -74,8 +74,9 @@ class ConstructAnalyticsModel {
class OneConstructUse {
String? lemma;
ConstructTypeEnum? constructType;
String? form;
List<String> categories;
ConstructTypeEnum? constructType;
ConstructUseTypeEnum useType;
String? id;
ConstructUseMetaData metadata;
@ -85,6 +86,7 @@ class OneConstructUse {
required this.lemma,
required this.constructType,
required this.metadata,
this.categories = const [],
this.form,
this.id,
});
@ -100,6 +102,9 @@ class OneConstructUse {
ConstructUseTypeEnum.unk,
lemma: json['lemma'],
form: json['form'],
categories: json['categories'] != null
? List<String>.from(json['categories'])
: [],
constructType: json['constructType'] != null
? ConstructTypeUtil.fromString(json['constructType'])
: null,
@ -113,7 +118,7 @@ class OneConstructUse {
}
Map<String, dynamic> toJson([bool condensed = false]) {
final Map<String, String?> data = {
final Map<String, dynamic> data = {
'useType': useType.string,
'chatId': metadata.roomId,
'timeStamp': metadata.timeStamp.toIso8601String(),
@ -125,7 +130,7 @@ class OneConstructUse {
data['constructType'] = constructType!.string;
}
if (id != null) data['id'] = id;
data['categories'] = categories;
return data;
}

View file

@ -146,23 +146,23 @@ class PangeaRepresentation {
final List<OneConstructUse> uses = [];
final lemma = token.lemma;
final content = token.text.content;
final morphs = token.morph.values.toList();
if (choreo == null) {
final bool inUserL2 = langCode ==
MatrixState.pangeaController.languageController.activeL2Code();
final useType =
inUserL2 ? ConstructUseTypeEnum.wa : ConstructUseTypeEnum.unk;
uses.addAll(
morphs.map(
(morph) => OneConstructUse(
for (final entry in token.morph.entries) {
uses.add(
OneConstructUse(
useType: useType,
lemma: morph,
lemma: entry.value,
categories: [entry.key],
constructType: ConstructTypeEnum.morph,
metadata: metadata,
),
),
);
);
}
uses.add(
lemma.toVocabUse(
inUserL2 ? ConstructUseTypeEnum.wa : ConstructUseTypeEnum.unk,
@ -205,16 +205,17 @@ class PangeaRepresentation {
}
}
uses.addAll(
morphs.map(
(morph) => OneConstructUse(
for (final entry in token.morph.entries) {
uses.add(
OneConstructUse(
useType: ConstructUseTypeEnum.wa,
lemma: morph,
lemma: entry.value,
categories: [entry.key],
constructType: ConstructTypeEnum.morph,
metadata: metadata,
),
),
);
);
}
uses.add(
lemma.toVocabUse(
ConstructUseTypeEnum.wa,

View file

@ -61,10 +61,10 @@ packages:
dependency: "direct main"
description:
name: archive
sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d"
sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d
url: "https://pub.dev"
source: hosted
version: "3.4.10"
version: "3.6.1"
args:
dependency: transitive
description:
@ -1305,18 +1305,18 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: "7f0df31977cb2c0b88585095d168e689669a2cc9b97c309665e3386f3e9d341a"
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "10.0.4"
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "06e98f569d004c1315b991ded39924b21af84cf14cc94791b8aea337d25b57f8"
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
@ -1417,10 +1417,10 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.8.0"
version: "0.11.1"
material_symbols_icons:
dependency: "direct main"
description:
@ -1442,10 +1442,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136"
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.12.0"
version: "1.15.0"
mgrs_dart:
dependency: transitive
description:
@ -1674,10 +1674,10 @@ packages:
dependency: transitive
description:
name: platform
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65"
url: "https://pub.dev"
source: hosted
version: "3.1.4"
version: "3.1.5"
platform_detect:
dependency: transitive
description:
@ -1726,14 +1726,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.10.2"
pointycastle:
dependency: transitive
description:
name: pointycastle
sha256: "43ac87de6e10afabc85c445745a7b799e04de84cebaa4fd7bf55a5e1e9604d29"
url: "https://pub.dev"
source: hosted
version: "3.7.4"
polylabel:
dependency: transitive
description:
@ -2319,26 +2311,26 @@ packages:
dependency: transitive
description:
name: test
sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073"
sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e"
url: "https://pub.dev"
source: hosted
version: "1.25.2"
version: "1.25.7"
test_api:
dependency: transitive
description:
name: test_api
sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f"
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.7.0"
version: "0.7.2"
test_core:
dependency: transitive
description:
name: test_core
sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4"
sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.6.4"
timezone:
dependency: transitive
description:
@ -2631,10 +2623,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.1"
version: "14.2.5"
wakelock_plus:
dependency: "direct main"
description:

View file

@ -14,7 +14,7 @@ environment:
dependencies:
adaptive_dialog: ^2.1.0
animations: ^2.0.11
archive: ^3.4.10
archive: ^3.6.1
async: ^2.11.0
badges: ^3.1.2
blurhash_dart: ^1.2.1