adding pos and morph to lemmas
This commit is contained in:
parent
a28b43d922
commit
1163c1d5cd
3 changed files with 24 additions and 10 deletions
|
|
@ -723,7 +723,7 @@ class PangeaMessageEvent {
|
|||
|
||||
// missing vital info so return
|
||||
if (event.roomId == null || originalSent?.tokens == null) {
|
||||
debugger(when: kDebugMode);
|
||||
// debugger(when: kDebugMode);
|
||||
return uses;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,22 +10,41 @@ class Lemma {
|
|||
/// vocab that are not saved: emails, urls, numbers, punctuation, etc.
|
||||
final bool saveVocab;
|
||||
|
||||
Lemma({required this.text, required this.saveVocab, required this.form});
|
||||
/// [pos] ex "v" - part of speech of the lemma
|
||||
/// https://universaldependencies.org/u/pos/
|
||||
final String pos;
|
||||
|
||||
/// [morph] ex {} - morphological features of the lemma
|
||||
/// https://universaldependencies.org/u/feat/
|
||||
final Map<String, String> morph;
|
||||
|
||||
Lemma(
|
||||
{required this.text,
|
||||
required this.saveVocab,
|
||||
required this.form,
|
||||
this.pos = '',
|
||||
this.morph = const {}});
|
||||
|
||||
factory Lemma.fromJson(Map<String, dynamic> json) {
|
||||
return Lemma(
|
||||
text: json['text'],
|
||||
saveVocab: json['save_vocab'] ?? json['saveVocab'] ?? false,
|
||||
form: json["form"] ?? json['text'],
|
||||
pos: json['pos'] ?? '',
|
||||
morph: json['morph'] ?? {},
|
||||
);
|
||||
}
|
||||
|
||||
toJson() {
|
||||
return {'text': text, 'save_vocab': saveVocab, 'form': form};
|
||||
return {
|
||||
'text': text,
|
||||
'save_vocab': saveVocab,
|
||||
'form': form,
|
||||
'pos': pos,
|
||||
'morph': morph
|
||||
};
|
||||
}
|
||||
|
||||
static Lemma get empty => Lemma(text: '', saveVocab: true, form: '');
|
||||
|
||||
static Lemma create(String form) =>
|
||||
Lemma(text: '', saveVocab: true, form: form);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,10 @@ import 'lemma.dart';
|
|||
|
||||
class PangeaToken {
|
||||
PangeaTokenText text;
|
||||
bool hasInfo;
|
||||
List<Lemma> lemmas;
|
||||
|
||||
PangeaToken({
|
||||
required this.text,
|
||||
required this.hasInfo,
|
||||
required this.lemmas,
|
||||
});
|
||||
|
||||
|
|
@ -37,7 +35,6 @@ class PangeaToken {
|
|||
PangeaTokenText.fromJson(json[_textKey] as Map<String, dynamic>);
|
||||
return PangeaToken(
|
||||
text: text,
|
||||
hasInfo: json[_hasInfoKey] ?? text.length > 2,
|
||||
lemmas: getLemmas(text.content, json[_lemmaKey]),
|
||||
);
|
||||
} catch (err, s) {
|
||||
|
|
@ -56,12 +53,10 @@ class PangeaToken {
|
|||
}
|
||||
|
||||
static const String _textKey = "text";
|
||||
static const String _hasInfoKey = "has_info";
|
||||
static const String _lemmaKey = ModelKey.lemma;
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
_textKey: text.toJson(),
|
||||
_hasInfoKey: hasInfo,
|
||||
_lemmaKey: lemmas.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue