feat: complete academic symbol lexicon heal, 2-column Cooper extraction, and updated assets
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
class ExternalSymbolSource {
|
||||
final String author;
|
||||
final String work;
|
||||
final String excerpt;
|
||||
final String fullText;
|
||||
|
||||
const ExternalSymbolSource({
|
||||
required this.author,
|
||||
required this.work,
|
||||
this.excerpt = '',
|
||||
this.fullText = '',
|
||||
});
|
||||
|
||||
factory ExternalSymbolSource.fromMap(Map<String, dynamic> map) {
|
||||
return ExternalSymbolSource(
|
||||
author: map['author'] as String? ?? '',
|
||||
work: map['work'] as String? ?? '',
|
||||
excerpt: map['excerpt'] as String? ?? '',
|
||||
fullText: map['full_text'] as String? ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
'author': author,
|
||||
'work': work,
|
||||
'excerpt': excerpt,
|
||||
'full_text': fullText,
|
||||
};
|
||||
}
|
||||
|
||||
class ExternalSymbol {
|
||||
final String term;
|
||||
final String normalized;
|
||||
final String categoryGuess;
|
||||
final List<ExternalSymbolSource> sources;
|
||||
final List<Map<String, dynamic>> illustrations;
|
||||
|
||||
const ExternalSymbol({
|
||||
required this.term,
|
||||
required this.normalized,
|
||||
this.categoryGuess = 'Внешний академический символ',
|
||||
this.sources = const [],
|
||||
this.illustrations = const [],
|
||||
});
|
||||
|
||||
bool get hasIllustrations => illustrations.isNotEmpty;
|
||||
|
||||
String get primaryAuthor => sources.isNotEmpty ? sources.first.author : '';
|
||||
String get primaryWork => sources.isNotEmpty ? sources.first.work : '';
|
||||
String get primaryExcerpt => sources.isNotEmpty ? sources.first.excerpt : '';
|
||||
|
||||
factory ExternalSymbol.fromMap(Map<String, dynamic> map) {
|
||||
final rawSources = map['sources'] as List<dynamic>? ?? [];
|
||||
final rawIlls = map['illustrations'] as List<dynamic>? ?? [];
|
||||
|
||||
return ExternalSymbol(
|
||||
term: map['term'] as String? ?? '',
|
||||
normalized: map['normalized'] as String? ?? '',
|
||||
categoryGuess: map['category_guess'] as String? ?? 'Внешний символ',
|
||||
sources: rawSources
|
||||
.map((s) => ExternalSymbolSource.fromMap(Map<String, dynamic>.from(s as Map)))
|
||||
.toList(),
|
||||
illustrations: rawIlls
|
||||
.map((i) => Map<String, dynamic>.from(i as Map))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toMap() => {
|
||||
'term': term,
|
||||
'normalized': normalized,
|
||||
'category_guess': categoryGuess,
|
||||
'sources': sources.map((s) => s.toMap()).toList(),
|
||||
'illustrations': illustrations,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user