improve topic predictions
This commit is contained in:
@@ -33,6 +33,8 @@ import 'package:weblibre/utils/lru_cache.dart';
|
|||||||
|
|
||||||
part 'gecko_inference.g.dart';
|
part 'gecko_inference.g.dart';
|
||||||
|
|
||||||
|
typedef SuggestedContainer = ({List<String> tabIds, String? topic});
|
||||||
|
|
||||||
@Riverpod(keepAlive: true)
|
@Riverpod(keepAlive: true)
|
||||||
class GeckoInferenceRepository extends _$GeckoInferenceRepository {
|
class GeckoInferenceRepository extends _$GeckoInferenceRepository {
|
||||||
final _service = GeckoMlService();
|
final _service = GeckoMlService();
|
||||||
@@ -134,7 +136,7 @@ class GeckoInferenceRepository extends _$GeckoInferenceRepository {
|
|||||||
return neighbors;
|
return neighbors;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<({String? topic, List<String> tabIds})>?> suggestClusters({
|
Future<List<SuggestedContainer>?> suggestClusters({
|
||||||
required Map<String, String> unassignedDocumentsInput,
|
required Map<String, String> unassignedDocumentsInput,
|
||||||
}) async {
|
}) async {
|
||||||
if (!ref.read(
|
if (!ref.read(
|
||||||
@@ -173,16 +175,21 @@ class GeckoInferenceRepository extends _$GeckoInferenceRepository {
|
|||||||
final clusterResult = await clusters.mapNotNull(
|
final clusterResult = await clusters.mapNotNull(
|
||||||
(cluster) => Future.wait(
|
(cluster) => Future.wait(
|
||||||
cluster.map((clusterTitles) async {
|
cluster.map((clusterTitles) async {
|
||||||
final topic = await predictDocumentTopic(clusterTitles.toSet());
|
final originalTitles = clusterTitles
|
||||||
|
.map((title) => processedDocuments[title] ?? title)
|
||||||
|
.toSet();
|
||||||
|
|
||||||
|
final topic = await predictDocumentTopic(originalTitles);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
topic: topic,
|
topic: topic,
|
||||||
tabIds: clusterTitles.map((title) {
|
tabIds: originalTitles
|
||||||
final originalTitle = processedDocuments[title] ?? title;
|
.map(
|
||||||
return unassignedDocumentsInput.entries
|
(title) => unassignedDocumentsInput.entries
|
||||||
.firstWhere((entry) => entry.value == originalTitle)
|
.firstWhere((entry) => entry.value == title)
|
||||||
.key;
|
.key,
|
||||||
}).toList(),
|
)
|
||||||
|
.toList(),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
@@ -254,9 +261,7 @@ Future<String?> containerTopic(Ref ref, String containerId) async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Riverpod()
|
@Riverpod()
|
||||||
Future<List<({List<String> tabIds, String? topic})>?> suggestClusters(
|
Future<List<SuggestedContainer>?> suggestClusters(Ref ref) async {
|
||||||
Ref ref,
|
|
||||||
) async {
|
|
||||||
final unassignedTitles = await ref.watch(
|
final unassignedTitles = await ref.watch(
|
||||||
containerTabsDataProvider(null).selectAsync(
|
containerTabsDataProvider(null).selectAsync(
|
||||||
(tabData) => EquatableValue(
|
(tabData) => EquatableValue(
|
||||||
|
|||||||
Reference in New Issue
Block a user