Merge pull request #957 from pangeachat/949-grammar-analytics
guess grammar category when missing, saving form when available
This commit is contained in:
commit
bf738ebc98
10 changed files with 345 additions and 148 deletions
|
|
@ -4158,7 +4158,9 @@
|
|||
"goToSpace": "Go to space: {space}",
|
||||
"@goToSpace": {
|
||||
"type": "text",
|
||||
"space": {}
|
||||
"placeholders": {
|
||||
"space": {}
|
||||
}
|
||||
},
|
||||
"markAsUnread": "Mark as unread",
|
||||
"userLevel": "{level} - User",
|
||||
|
|
@ -4245,7 +4247,7 @@
|
|||
"grammarCopyPUNCTTYPEqest": "Question",
|
||||
"grammarCopyASPECTperf": "Perfect",
|
||||
"grammarCopyCASEaccnom": "Accusative, Nominative",
|
||||
"grammarCopyCASEobl": "Oblique Case",
|
||||
"grammarCopyCASEobl": "Oblique",
|
||||
"grammarCopyVOICEact": "Active",
|
||||
"grammarCopyPUNCTTYPEbrck": "Bracket",
|
||||
"grammarCopyNOUNTYPEart": "Article",
|
||||
|
|
@ -4288,7 +4290,7 @@
|
|||
"grammarCopyPRONTYPErel": "Relative",
|
||||
"grammarCopyVERBFORMfinalEnding": "Final Ending",
|
||||
"grammarCopyPRONTYPEdem": "Demonstrative",
|
||||
"grammarCopyPREPCASEpre": "Preposition",
|
||||
"grammarCopyPREPCASEpre": "Prepositional",
|
||||
"grammarCopyVERBFORMfin": "Finite",
|
||||
"grammarCopyDEGREEpos": "Positive",
|
||||
"grammarCopyPUNCTTYPEquot": "Quotation",
|
||||
|
|
@ -4304,36 +4306,36 @@
|
|||
"grammarCopyCASEloc": "Locative",
|
||||
"grammarCopyMOODind": "Indicative",
|
||||
"grammarCopyDEGREEcmp": "Comparative",
|
||||
"grammarCopyCASErelativeCase": "Relative Case",
|
||||
"grammarCopyCASErelativeCase": "Relative",
|
||||
"grammarCopyPUNCTTYPEexcl": "Exclamative",
|
||||
"grammarCopyPERSON1": "First Person",
|
||||
"grammarCopyPUNCTSIDEini": "Initial",
|
||||
"grammarCopyGENDERperson": "Person",
|
||||
"grammarCopyFOREIGNyes": "Foreign",
|
||||
"grammarCopyVOICEvoice": "Voice",
|
||||
"grammarCopyVERBTYPEverbType": "Verb Type",
|
||||
"grammarCopyVERBTYPEverbType": "Verb",
|
||||
"grammarCopyPOSSpass": "Possessive",
|
||||
"grammarCopyPREPCASEprepCase": "Prepositional Case",
|
||||
"grammarCopyNUMTYPEnumType": "Numeral Type",
|
||||
"grammarCopyNOUNTYPEnounType": "Noun Type",
|
||||
"grammarCopyPREPCASEprepCase": "Prepositional",
|
||||
"grammarCopyNUMTYPEnumType": "Numeral",
|
||||
"grammarCopyNOUNTYPEnounType": "Noun",
|
||||
"grammarCopyREFLEXreflex": "Reflexive",
|
||||
"grammarCopyPRONTYPEpronType": "Pronoun Type",
|
||||
"grammarCopyPRONTYPEpronType": "Pronoun",
|
||||
"grammarCopyPUNCTSIDEpunctSide": "Punctuation Side",
|
||||
"grammarCopyVERBFORMverbForm": "Verb Form",
|
||||
"grammarCopyVERBFORMverbForm": "Verb",
|
||||
"grammarCopyGENDERgender": "Gender",
|
||||
"grammarCopyMOODmood": "Mood",
|
||||
"grammarCopyASPECTaspect": "Aspect",
|
||||
"grammarCopyPUNCTTYPEpunctType": "Punctuation Type",
|
||||
"grammarCopyPUNCTTYPEpunctType": "Punctuation",
|
||||
"grammarCopyTENSEtense": "Tense",
|
||||
"grammarCopyDEGREEdegree": "Degree",
|
||||
"grammarCopyPOLITEpolite": "Politeness",
|
||||
"grammarCopyADVTYPEadvType": "Adverb Type",
|
||||
"grammarCopyADVTYPEadvType": "Adverb",
|
||||
"grammarCopyNUMFORMnumber": "Number",
|
||||
"grammarCopyCONJTYPEconjType": "Conjunction Type",
|
||||
"grammarCopyCONJTYPEconjType": "Conjunction",
|
||||
"grammarCopyPOLARITYpolarity": "Polarity",
|
||||
"grammarCopyCASEcase": "Case",
|
||||
"grammarCopyDEFINITEdefinite": "Definiteness",
|
||||
"grammarCopyNUMFORMnumForm": "Numeral Form",
|
||||
"grammarCopyNUMFORMnumForm": "Numeral",
|
||||
"grammarCopyPRONTYPEadn": "Adnominal",
|
||||
"grammarCopyVOCvoc": "Vocative",
|
||||
"grammarCopyCMPLcmpl": "Complementizer",
|
||||
|
|
@ -4344,74 +4346,74 @@
|
|||
"grammarCopyPARTTYPEpar": "Partitive",
|
||||
"grammarCopySPCspc": "Specific",
|
||||
"grammarCopyTENSEpqp": "Pluperfect",
|
||||
"grammarCopyREFLEXref": "Reflexive Case",
|
||||
"grammarCopyREFLEXref": "Reflexive",
|
||||
"grammarCopyPUNCTTYPEnshrt": "Short",
|
||||
"grammarCopyNUMBERdual": "Dual",
|
||||
"grammarCopyNUMFORMlng": "Long",
|
||||
"grammarCopyVOICEmid": "Middle Voice",
|
||||
"grammarCopyVOICEmid": "Middle",
|
||||
"grammarCopyINTRELintRel": "Interrogative, Relative",
|
||||
"grammarCopyINTint": "Interrogative",
|
||||
"grammarCopyVOICEcaus": "Causative Voice",
|
||||
"grammarCopyVOICEcaus": "Causative",
|
||||
"grammarCopyUnknown": "Unknown",
|
||||
"grammarCopyEVIDENTevident": "Evidentiality",
|
||||
"grammarCopyNUMFORMnumberPsor": "Possessor's Number",
|
||||
"grammarCopyASPECThab": "Habitual",
|
||||
"grammarCopyCASEabl": "Ablative Case",
|
||||
"grammarCopyCASEall": "Allative Case",
|
||||
"grammarCopyCASEess": "Essive Case",
|
||||
"grammarCopyCASEtra": "Translative Case",
|
||||
"grammarCopyCASEequ": "Equative Case",
|
||||
"grammarCopyCASEdis": "Distributive Case",
|
||||
"grammarCopyCASEabs": "Absolutive Case",
|
||||
"grammarCopyCASEerg": "Ergative Case",
|
||||
"grammarCopyCASEcau": "Causal Case",
|
||||
"grammarCopyCASEben": "Benefactive Case",
|
||||
"grammarCopyCASEtem": "Temporal Case",
|
||||
"grammarCopyCONJTYPEcoord": "Coordinating Conjunction",
|
||||
"grammarCopyCASEabl": "Ablative",
|
||||
"grammarCopyCASEall": "Allative",
|
||||
"grammarCopyCASEess": "Essive",
|
||||
"grammarCopyCASEtra": "Translative",
|
||||
"grammarCopyCASEequ": "Equative",
|
||||
"grammarCopyCASEdis": "Distributive",
|
||||
"grammarCopyCASEabs": "Absolutive",
|
||||
"grammarCopyCASEerg": "Ergative",
|
||||
"grammarCopyCASEcau": "Causal",
|
||||
"grammarCopyCASEben": "Benefactive",
|
||||
"grammarCopyCASEtem": "Temporal",
|
||||
"grammarCopyCONJTYPEcoord": "Coordinating",
|
||||
"grammarCopyDEFINITEcons": "Construct State",
|
||||
"grammarCopyDEGREEabs": "Absolute Degree",
|
||||
"grammarCopyEVIDENTfh": "Factual Evidentiality",
|
||||
"grammarCopyEVIDENTnfh": "Non-factual Evidentiality",
|
||||
"grammarCopyMOODopt": "Optative Mood",
|
||||
"grammarCopyMOODadm": "Admirative Mood",
|
||||
"grammarCopyMOODdes": "Desiderative Mood",
|
||||
"grammarCopyMOODnec": "Necessitative Mood",
|
||||
"grammarCopyMOODpot": "Potential Mood",
|
||||
"grammarCopyMOODprp": "Propositive Mood",
|
||||
"grammarCopyMOODqot": "Quotative Mood",
|
||||
"grammarCopyMOODopt": "Optative",
|
||||
"grammarCopyMOODadm": "Admirative",
|
||||
"grammarCopyMOODdes": "Desiderative",
|
||||
"grammarCopyMOODnec": "Necessitative",
|
||||
"grammarCopyMOODpot": "Potential",
|
||||
"grammarCopyMOODprp": "Propositive",
|
||||
"grammarCopyMOODqot": "Quotative",
|
||||
"grammarCopyNUMFORMword": "Word Form",
|
||||
"grammarCopyNUMFORMroman": "Roman Numeral",
|
||||
"grammarCopyNUMFORMletter": "Letter Form",
|
||||
"grammarCopyNUMTYPEmult": "Multiplicative Numeral",
|
||||
"grammarCopyNUMTYPEfrac": "Fractional Numeral",
|
||||
"grammarCopyNUMTYPEsets": "Set Numeral",
|
||||
"grammarCopyNUMTYPErange": "Range Numeral",
|
||||
"grammarCopyNUMTYPEdist": "Distributive Numeral",
|
||||
"grammarCopyNUMBERtri": "Trial Number",
|
||||
"grammarCopyNUMBERpauc": "Paucal Number",
|
||||
"grammarCopyNUMBERgrpa": "Greater Paucal Number",
|
||||
"grammarCopyNUMBERgrpl": "Greater Plural Number",
|
||||
"grammarCopyNUMBERinv": "Inverse Number",
|
||||
"grammarCopyPERSON0": "Zero Person",
|
||||
"grammarCopyPERSON4": "Fourth Person",
|
||||
"grammarCopyPOLITEform": "Formal Politeness",
|
||||
"grammarCopyPOLITEelev": "Elevated Politeness",
|
||||
"grammarCopyPOLITEhumb": "Humble Politeness",
|
||||
"grammarCopyPRONTYPEemp": "Emphatic Pronoun",
|
||||
"grammarCopyPRONTYPEexc": "Exclamative Pronoun",
|
||||
"grammarCopyPRONTYPErcp": "Reciprocal Pronoun",
|
||||
"grammarCopyPRONTYPEintRelPronType": "Interrogative-Relative Pronoun",
|
||||
"grammarCopyTENSEaor": "Aorist Tense",
|
||||
"grammarCopyTENSEeps": "Epistemic Tense",
|
||||
"grammarCopyTENSEprosp": "Prospective Tense",
|
||||
"grammarCopyVERBFORMpart": "Participle Form",
|
||||
"grammarCopyVERBFORMconv": "Converb Form",
|
||||
"grammarCopyNUMTYPEmult": "Multiplicative",
|
||||
"grammarCopyNUMTYPEfrac": "Fractional",
|
||||
"grammarCopyNUMTYPEsets": "Set",
|
||||
"grammarCopyNUMTYPErange": "Range",
|
||||
"grammarCopyNUMTYPEdist": "Distributive",
|
||||
"grammarCopyNUMBERtri": "Trial",
|
||||
"grammarCopyNUMBERpauc": "Paucal",
|
||||
"grammarCopyNUMBERgrpa": "Greater Paucal",
|
||||
"grammarCopyNUMBERgrpl": "Greater Plural",
|
||||
"grammarCopyNUMBERinv": "Inverse",
|
||||
"grammarCopyPERSON0": "Zero",
|
||||
"grammarCopyPERSON4": "Fourth",
|
||||
"grammarCopyPOLITEform": "Formal",
|
||||
"grammarCopyPOLITEelev": "Elevated",
|
||||
"grammarCopyPOLITEhumb": "Humble",
|
||||
"grammarCopyPRONTYPEemp": "Emphatic",
|
||||
"grammarCopyPRONTYPEexc": "Exclamative",
|
||||
"grammarCopyPRONTYPErcp": "Reciprocal",
|
||||
"grammarCopyPRONTYPEintRelPronType": "Interrogative-Relative",
|
||||
"grammarCopyTENSEaor": "Aorist",
|
||||
"grammarCopyTENSEeps": "Epistemic",
|
||||
"grammarCopyTENSEprosp": "Prospective",
|
||||
"grammarCopyVERBFORMpart": "Participle",
|
||||
"grammarCopyVERBFORMconv": "Converb",
|
||||
"grammarCopyVERBFORMvnoun": "Verbal Noun",
|
||||
"grammarCopyVOICEantip": "Antipassive Voice",
|
||||
"grammarCopyVOICEcauVoice": "Causative Voice",
|
||||
"grammarCopyVOICedir": "Direct Voice",
|
||||
"grammarCopyVOICEinvVoice": "Inverse Voice",
|
||||
"grammarCopyVOICErcpVoice": "Reciprocal Voice",
|
||||
"grammarCopyVOICEantip": "Antipassive",
|
||||
"grammarCopyVOICEcauVoice": "Causative",
|
||||
"grammarCopyVOICedir": "Direct",
|
||||
"grammarCopyVOICEinvVoice": "Inverse",
|
||||
"grammarCopyVOICErcpVoice": "Reciprocal",
|
||||
"grammarCopyPOS": "Part of Speech",
|
||||
"grammarCopyGENDER": "Gender",
|
||||
"grammarCopyPERSON": "Person",
|
||||
|
|
@ -4447,18 +4449,18 @@
|
|||
"grammarCopyNUMBERPSOR": "Possessor's Number",
|
||||
"grammarCopyPOSS": "Possessive",
|
||||
"grammarCopyASPECTimp": "Imperfective Aspect",
|
||||
"grammarCopyCASEvoc": "Vocative Case",
|
||||
"grammarCopyCASEcom": "Comitative Case",
|
||||
"grammarCopyCASEpar": "Partitive Case",
|
||||
"grammarCopyCASEadv": "Adverbial Case",
|
||||
"grammarCopyCASEref": "Referential Case",
|
||||
"grammarCopyCASErel": "Relative Case",
|
||||
"grammarCopyCASEsub": "Subessive Case",
|
||||
"grammarCopyCASEsup": "Superessive Case",
|
||||
"grammarCopyCASEaccdat": "Accusative-Dative Case",
|
||||
"grammarCopyCASEpre": "Prepositional Case",
|
||||
"grammarCopyCONJTYPEsub": "Subordinating Conjunction",
|
||||
"grammarCopyCONJTYPEcmp": "Comparative Conjunction",
|
||||
"grammarCopyCASEvoc": "Vocative",
|
||||
"grammarCopyCASEcom": "Comitative",
|
||||
"grammarCopyCASEpar": "Partitive",
|
||||
"grammarCopyCASEadv": "Adverbial",
|
||||
"grammarCopyCASEref": "Referential",
|
||||
"grammarCopyCASErel": "Relative",
|
||||
"grammarCopyCASEsub": "Subessive",
|
||||
"grammarCopyCASEsup": "Superessive",
|
||||
"grammarCopyCASEaccdat": "Accusative-Dative",
|
||||
"grammarCopyCASEpre": "Prepositional",
|
||||
"grammarCopyCONJTYPEsub": "Subordinating",
|
||||
"grammarCopyCONJTYPEcmp": "Comparative",
|
||||
"grammarCopyDEFINITEind": "Indefinite",
|
||||
"grammarCopyMOODint": "Interrogative Mood",
|
||||
"grammarCopyNOUNTYPEcomm": "Common Noun",
|
||||
|
|
@ -4468,25 +4470,26 @@
|
|||
"grammarCopyPOLARITYpos": "Positive Polarity",
|
||||
"grammarCopyPOSSyes": "Possessive",
|
||||
"grammarCopyPREPCASEnpr": "Non-prepositional",
|
||||
"grammarCopyPRONTYPEprs": "Personal Pronoun",
|
||||
"grammarCopyPRONTYPEint": "Interrogative Pronoun",
|
||||
"grammarCopyPRONTYPEtot": "Total Pronoun",
|
||||
"grammarCopyPRONTYPEneg": "Negative Pronoun",
|
||||
"grammarCopyPRONTYPEart": "Article Pronoun",
|
||||
"grammarCopyPRONTYPEind": "Indefinite Pronoun",
|
||||
"grammarCopyPRONTYPEintrel": "Interrogative-Relative Pronoun",
|
||||
"grammarCopyPRONTYPEprs": "Personal",
|
||||
"grammarCopyPRONTYPEint": "Interrogative",
|
||||
"grammarCopyPRONTYPEtot": "Total",
|
||||
"grammarCopyPRONTYPEneg": "Negative",
|
||||
"grammarCopyPRONTYPEart": "Article",
|
||||
"grammarCopyPRONTYPEind": "Indefinite",
|
||||
"grammarCopyPRONTYPEintrel": "Interrogative-Relative",
|
||||
"grammarCopyPRONTYPEint": "Interrogative",
|
||||
"grammarCopyPUNCTSIDEfin": "Final Punctuation",
|
||||
"grammarCopyPUNCTTYPEperi": "Period",
|
||||
"grammarCopyREFLEXyes": "Reflexive",
|
||||
"grammarCopyTENSEimp": "Imperfect Tense",
|
||||
"grammarCopyVERBFORMsup": "Supine Form",
|
||||
"grammarCopyVERBFORMadn": "Adnominal Form",
|
||||
"grammarCopyVERBFORMlng": "Long Form",
|
||||
"grammarCopyTENSEimp": "Imperfect",
|
||||
"grammarCopyVERBFORMsup": "SuApine",
|
||||
"grammarCopyVERBFORMadn": "Adnominal",
|
||||
"grammarCopyVERBFORMlng": "Long",
|
||||
"grammarCopyVERBTYPEcaus": "Causative Verb",
|
||||
"grammarCopyVOICEcau": "Causative Voice",
|
||||
"grammarCopyVOICEdir": "Direct Voice",
|
||||
"grammarCopyVOICEinv": "Inverse Voice",
|
||||
"grammarCopyVOICErcp": "Reciprocal Voice",
|
||||
"grammarCopyVOICEcau": "Causative",
|
||||
"grammarCopyVOICEdir": "Direct",
|
||||
"grammarCopyVOICEinv": "Inverse",
|
||||
"grammarCopyVOICErcp": "Reciprocal",
|
||||
"enterPrompt": "Please enter a system prompt",
|
||||
"selectBotLanguage": "Select bot language",
|
||||
"chooseVoice": "Choose a voice",
|
||||
|
|
|
|||
167
lib/pangea/constants/morph_categories_and_labels.dart
Normal file
167
lib/pangea/constants/morph_categories_and_labels.dart
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
const Map<String, List<String>> morphCategoriesAndLabels = {
|
||||
"Pos": [
|
||||
"ADJ",
|
||||
"ADP",
|
||||
"ADV",
|
||||
"AFFIX",
|
||||
"AUX",
|
||||
"CCONJ",
|
||||
"DET",
|
||||
"INTJ",
|
||||
"NOUN",
|
||||
"NUM",
|
||||
"PART",
|
||||
"PRON",
|
||||
"PROPN",
|
||||
"PUNCT",
|
||||
"SCONJ",
|
||||
"SPACE",
|
||||
"SYM",
|
||||
"VERB",
|
||||
"X",
|
||||
],
|
||||
"AdvType": ["Adverbial", "Tim"],
|
||||
"Aspect": [
|
||||
"Imp",
|
||||
"Perf",
|
||||
"Prog",
|
||||
"Hab",
|
||||
],
|
||||
"Case": [
|
||||
"Nom",
|
||||
"Acc",
|
||||
"Dat",
|
||||
"Gen",
|
||||
"Voc",
|
||||
"Abl",
|
||||
"Loc",
|
||||
"All",
|
||||
"Ins",
|
||||
"Ess",
|
||||
"Tra",
|
||||
"Com",
|
||||
"Par",
|
||||
"Adv",
|
||||
"Ref",
|
||||
"Rel",
|
||||
"Equ",
|
||||
"Dis",
|
||||
"Abs",
|
||||
"Erg",
|
||||
"Cau",
|
||||
"Ben",
|
||||
"Sub",
|
||||
"Sup",
|
||||
"Tem",
|
||||
"Obl",
|
||||
"Acc,Dat",
|
||||
"Acc,Nom",
|
||||
"Pre",
|
||||
],
|
||||
"ConjType": ["Coord", "Sub", "Cmp"],
|
||||
"Definite": ["Def", "Ind", "Cons"],
|
||||
"Degree": [
|
||||
"Pos",
|
||||
"Cmp",
|
||||
"Sup",
|
||||
"Abs",
|
||||
],
|
||||
"Evident": ["Fh", "Nfh"],
|
||||
"Foreign": ["Yes"],
|
||||
"Gender": ["Masc", "Fem", "Neut", "Com"],
|
||||
"Mood": [
|
||||
"Ind",
|
||||
"Imp",
|
||||
"Sub",
|
||||
"Cnd",
|
||||
"Opt",
|
||||
"Jus",
|
||||
"Adm",
|
||||
"Des",
|
||||
"Nec",
|
||||
"Pot",
|
||||
"Prp",
|
||||
"Qot",
|
||||
"Int",
|
||||
],
|
||||
"NounType": ["Prop", "Comm", "Not_proper"],
|
||||
"NumForm": [
|
||||
"Digit",
|
||||
"Word",
|
||||
"Roman",
|
||||
"Letter",
|
||||
],
|
||||
"NumType": [
|
||||
"Card",
|
||||
"Ord",
|
||||
"Mult",
|
||||
"Frac",
|
||||
"Sets",
|
||||
"Range",
|
||||
"Dist",
|
||||
],
|
||||
"Number": [
|
||||
"Sing",
|
||||
"Plur",
|
||||
"Dual",
|
||||
"Tri",
|
||||
"Pauc",
|
||||
"Grpa",
|
||||
"Grpl",
|
||||
"Inv",
|
||||
],
|
||||
"Number[psor]": ["Sing", "Plur", "Dual"],
|
||||
"Person": [
|
||||
"0",
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4",
|
||||
],
|
||||
"Polarity": ["Pos", "Neg"],
|
||||
"Polite": ["Infm", "Form", "Elev", "Humb"],
|
||||
"Poss": ["Yes"],
|
||||
"PrepCase": ["Npr"],
|
||||
"PronType": [
|
||||
"Prs",
|
||||
"Int",
|
||||
"Rel",
|
||||
"Dem",
|
||||
"Tot",
|
||||
"Neg",
|
||||
"Art",
|
||||
"Emp",
|
||||
"Exc",
|
||||
"Ind",
|
||||
"Rcp",
|
||||
"Int,Rel",
|
||||
],
|
||||
"PunctSide": ["Ini", "Fin"],
|
||||
"PunctType": [
|
||||
"Brck",
|
||||
"Dash",
|
||||
"Excl",
|
||||
"Peri",
|
||||
"Qest",
|
||||
"Quot",
|
||||
"Semi",
|
||||
"Colo",
|
||||
"Comm",
|
||||
],
|
||||
"Reflex": ["Yes"],
|
||||
"Tense": ["Pres", "Past", "Fut", "Imp", "Pqp", "Aor", "Eps", "Prosp"],
|
||||
"VerbForm": [
|
||||
"Fin",
|
||||
"Inf",
|
||||
"Sup",
|
||||
"Part",
|
||||
"Conv",
|
||||
"Vnoun",
|
||||
"Ger",
|
||||
"Adn",
|
||||
"Lng",
|
||||
],
|
||||
"VerbType": ["Mod", "Caus"],
|
||||
"Voice": ["Act", "Mid", "Pass", "Antip", "Cau", "Dir", "Inv", "Rcp", "Caus"],
|
||||
"X": ["X"],
|
||||
};
|
||||
|
|
@ -189,6 +189,7 @@ class PutAnalyticsController extends BaseController<AnalyticsStream> {
|
|||
OneConstructUse(
|
||||
useType: useType,
|
||||
lemma: entry.value,
|
||||
form: token.text.content,
|
||||
category: entry.key,
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata,
|
||||
|
|
|
|||
|
|
@ -52,16 +52,21 @@ class ConstructListModel {
|
|||
_updateMetrics();
|
||||
}
|
||||
|
||||
int _sortConstructs(ConstructUses a, ConstructUses b) {
|
||||
final comp = b.points.compareTo(a.points);
|
||||
if (comp != 0) return comp;
|
||||
return a.lemma.compareTo(b.lemma);
|
||||
}
|
||||
|
||||
/// A map of lemmas to ConstructUses, each of which contains a lemma
|
||||
/// key = lemmma + constructType.string, value = ConstructUses
|
||||
void _updateConstructMap(final List<OneConstructUse> newUses) {
|
||||
for (final use in newUses) {
|
||||
if (use.lemma == null) continue;
|
||||
final currentUses = _constructMap[use.identifier.string] ??
|
||||
ConstructUses(
|
||||
uses: [],
|
||||
constructType: use.constructType,
|
||||
lemma: use.lemma!,
|
||||
lemma: use.lemma,
|
||||
category: use.category,
|
||||
);
|
||||
currentUses.uses.add(use);
|
||||
|
|
@ -75,11 +80,7 @@ class ConstructListModel {
|
|||
void _updateConstructList() {
|
||||
// TODO check how expensive this is
|
||||
_constructList = _constructMap.values.toList();
|
||||
_constructList.sort((a, b) {
|
||||
final comp = b.uses.length.compareTo(a.uses.length);
|
||||
if (comp != 0) return comp;
|
||||
return a.lemma.compareTo(b.lemma);
|
||||
});
|
||||
_constructList.sort(_sortConstructs);
|
||||
}
|
||||
|
||||
void _updateCategoriesToUses() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:fluffychat/pangea/constants/morph_categories_and_labels.dart';
|
||||
import 'package:fluffychat/pangea/enum/construct_use_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/models/practice_activities.dart/practice_activity_model.dart';
|
||||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
|
|
@ -49,20 +50,15 @@ class ConstructAnalyticsModel {
|
|||
}
|
||||
|
||||
class OneConstructUse {
|
||||
/// the lemma of vocab or the text of a morph tag
|
||||
/// e.g. "be" or "Present"
|
||||
String? lemma;
|
||||
String lemma;
|
||||
|
||||
/// exact text as it appeared in the text
|
||||
// practice activities do not currently include form in the target_construct info
|
||||
// for that, this is nullable
|
||||
String? form;
|
||||
|
||||
/// For vocab constructs, this is the POS. For morph
|
||||
/// constructs, this is the morphological category.
|
||||
/// e.g. "are" or "Tense"
|
||||
/// TODO - for old uses without category, we should
|
||||
/// try guessing the category from the lemma as best we can
|
||||
/// while it's not 1-to-1, most morph tags are unique
|
||||
String? category;
|
||||
String category;
|
||||
|
||||
ConstructTypeEnum constructType;
|
||||
ConstructUseTypeEnum useType;
|
||||
|
|
@ -78,8 +74,8 @@ class OneConstructUse {
|
|||
required this.lemma,
|
||||
required this.constructType,
|
||||
required this.metadata,
|
||||
this.category,
|
||||
this.form,
|
||||
required this.category,
|
||||
required this.form,
|
||||
this.id,
|
||||
});
|
||||
|
||||
|
|
@ -88,27 +84,20 @@ class OneConstructUse {
|
|||
DateTime get timeStamp => metadata.timeStamp;
|
||||
|
||||
factory OneConstructUse.fromJson(Map<String, dynamic> json) {
|
||||
final constructType = json['constructType'] != null
|
||||
? ConstructTypeUtil.fromString(json['constructType'])
|
||||
: null;
|
||||
debugger(when: kDebugMode && constructType == null);
|
||||
debugger(when: kDebugMode && json['constructType'] == null);
|
||||
|
||||
final categoryEntry = json['cat'] ?? json['categories'];
|
||||
String? category;
|
||||
if (categoryEntry != null) {
|
||||
if ((categoryEntry is List) && categoryEntry.isNotEmpty) {
|
||||
category = categoryEntry.first;
|
||||
} else if (categoryEntry is String) {
|
||||
category = categoryEntry;
|
||||
}
|
||||
}
|
||||
final ConstructTypeEnum constructType = json['constructType'] != null
|
||||
? ConstructTypeUtil.fromString(json['constructType'])
|
||||
: ConstructTypeEnum.vocab;
|
||||
|
||||
return OneConstructUse(
|
||||
useType: ConstructUseTypeUtil.fromString(json['useType']),
|
||||
lemma: json['lemma'],
|
||||
form: json['form'],
|
||||
category: category,
|
||||
constructType: constructType ?? ConstructTypeEnum.vocab,
|
||||
category: constructType == ConstructTypeEnum.morph
|
||||
? getCategory(json)
|
||||
: "Other",
|
||||
constructType: constructType,
|
||||
id: json['id'],
|
||||
metadata: ConstructUseMetaData(
|
||||
eventId: json['msgId'],
|
||||
|
|
@ -118,21 +107,53 @@ class OneConstructUse {
|
|||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = {
|
||||
'useType': useType.string,
|
||||
'chatId': metadata.roomId,
|
||||
'timeStamp': metadata.timeStamp.toIso8601String(),
|
||||
'form': form,
|
||||
'msgId': metadata.eventId,
|
||||
};
|
||||
Map<String, dynamic> toJson() => {
|
||||
'useType': useType.string,
|
||||
'chatId': metadata.roomId,
|
||||
'timeStamp': metadata.timeStamp.toIso8601String(),
|
||||
'form': form,
|
||||
'msgId': metadata.eventId,
|
||||
'lemma': lemma,
|
||||
'constructType': constructType.string,
|
||||
'categories': category,
|
||||
'id': id,
|
||||
};
|
||||
|
||||
data['lemma'] = lemma!;
|
||||
data['constructType'] = constructType.string;
|
||||
static String getCategory(Map<String, dynamic> json) {
|
||||
final categoryEntry = json['cat'] ?? json['categories'];
|
||||
|
||||
if (id != null) data['id'] = id;
|
||||
data['categories'] = category;
|
||||
return data;
|
||||
if (categoryEntry == null) {
|
||||
return _guessGrammarCategory(json["lemma"]);
|
||||
}
|
||||
|
||||
if ((categoryEntry is List)) {
|
||||
if (categoryEntry.isEmpty) {
|
||||
return _guessGrammarCategory(json["lemma"]);
|
||||
}
|
||||
return categoryEntry.first;
|
||||
} else if (categoryEntry is String) {
|
||||
return categoryEntry;
|
||||
}
|
||||
|
||||
debugPrint(
|
||||
"Category entry is not a list or string -${json['cat'] ?? json['categories']}-",
|
||||
);
|
||||
return _guessGrammarCategory(json["lemma"]);
|
||||
}
|
||||
|
||||
static String _guessGrammarCategory(String morphLemma) {
|
||||
for (final String category in morphCategoriesAndLabels.keys) {
|
||||
if (morphCategoriesAndLabels[category]!.contains(morphLemma)) {
|
||||
debugPrint(
|
||||
"found missing construct category for $morphLemma: $category",
|
||||
);
|
||||
return category;
|
||||
}
|
||||
}
|
||||
ErrorHandler.logError(
|
||||
m: "Morph construct lemma $morphLemma not found in morph categories and labels",
|
||||
);
|
||||
return "Other";
|
||||
}
|
||||
|
||||
Room? getRoom(Client client) {
|
||||
|
|
@ -148,9 +169,9 @@ class OneConstructUse {
|
|||
int get pointValue => useType.pointValue;
|
||||
|
||||
ConstructIdentifier get identifier => ConstructIdentifier(
|
||||
lemma: lemma!,
|
||||
lemma: lemma,
|
||||
type: constructType,
|
||||
category: category ?? "",
|
||||
category: category,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -158,6 +158,8 @@ class ActivityRecordResponse {
|
|||
.map(
|
||||
(construct) => OneConstructUse(
|
||||
lemma: construct.lemma,
|
||||
// TODO - add form to practiceActivity target_construct data somehow
|
||||
form: null,
|
||||
constructType: construct.type,
|
||||
useType: useType(practiceActivity.activityType),
|
||||
metadata: metadata,
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ class PangeaRepresentation {
|
|||
OneConstructUse(
|
||||
useType: useType,
|
||||
lemma: entry.value,
|
||||
form: token.text.content,
|
||||
category: entry.key,
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata,
|
||||
|
|
@ -210,6 +211,7 @@ class PangeaRepresentation {
|
|||
OneConstructUse(
|
||||
useType: ConstructUseTypeEnum.ga,
|
||||
lemma: entry.value,
|
||||
form: token.text.content,
|
||||
category: entry.key,
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata,
|
||||
|
|
@ -227,6 +229,7 @@ class PangeaRepresentation {
|
|||
OneConstructUse(
|
||||
useType: ConstructUseTypeEnum.wa,
|
||||
lemma: entry.value,
|
||||
form: token.text.content,
|
||||
category: entry.key,
|
||||
constructType: ConstructTypeEnum.morph,
|
||||
metadata: metadata,
|
||||
|
|
|
|||
|
|
@ -411,6 +411,8 @@ String? getGrammarCopy({
|
|||
return L10n.of(context)!.grammarCopyPRONTYPEexc;
|
||||
case 'grammarCopyPRONTYPErcp':
|
||||
return L10n.of(context)!.grammarCopyPRONTYPErcp;
|
||||
case 'grammarCopyPRONTYPEint':
|
||||
return L10n.of(context)!.grammarCopyPRONTYPEint;
|
||||
case 'grammarCopyPRONTYPEintrel':
|
||||
return L10n.of(context)!.grammarCopyPRONTYPEintrel;
|
||||
case 'grammarCopyPRONTYPEintRelPronType':
|
||||
|
|
@ -439,6 +441,8 @@ String? getGrammarCopy({
|
|||
return L10n.of(context)!.grammarCopyVOICEinvVoice;
|
||||
case 'grammarCopyVOICErcpVoice':
|
||||
return L10n.of(context)!.grammarCopyVOICErcpVoice;
|
||||
case "grammarCopyCASEaccdat":
|
||||
return L10n.of(context)!.grammarCopyCASEaccdat;
|
||||
// Handle empty tag
|
||||
case '':
|
||||
ErrorHandler.logError(
|
||||
|
|
@ -458,6 +462,6 @@ String? getGrammarCopy({
|
|||
'context': context,
|
||||
},
|
||||
);
|
||||
return key; // Fallback to the key itself if no match is found
|
||||
return lemma; // Fallback to the lemma itself if no match is found
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
import 'package:collection/collection.dart';
|
||||
import 'package:fluffychat/pangea/enum/construct_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/enum/progress_indicators_enum.dart';
|
||||
import 'package:fluffychat/pangea/models/analytics/construct_list_model.dart';
|
||||
|
|
@ -94,11 +93,7 @@ class AnalyticsPopupState extends State<AnalyticsPopup> {
|
|||
dialogContent = Center(child: Text(L10n.of(context)!.noDataFound));
|
||||
} else if (hasNoCategories || !widget.showGroups) {
|
||||
dialogContent = ConstructsTileList(
|
||||
_constructsModel.constructList(type: widget.type).sorted((a, b) {
|
||||
final comp = b.points.compareTo(a.points);
|
||||
if (comp != 0) return comp;
|
||||
return a.lemma.compareTo(b.lemma);
|
||||
}),
|
||||
_constructsModel.constructList(type: widget.type),
|
||||
);
|
||||
} else {
|
||||
dialogContent = ListView.builder(
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import 'package:fluffychat/config/app_config.dart';
|
|||
import 'package:fluffychat/pangea/enum/construct_type_enum.dart';
|
||||
import 'package:fluffychat/pangea/enum/progress_indicators_enum.dart';
|
||||
import 'package:fluffychat/pangea/models/analytics/construct_use_model.dart';
|
||||
import 'package:fluffychat/pangea/utils/get_grammar_copy.dart';
|
||||
import 'package:fluffychat/pangea/utils/grammar/get_grammar_copy.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ConstructUsesXPTile extends StatelessWidget {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue