private void btMakeSynAn_Click(object sender, EventArgs e) { var sentlistRep = store.MorphMakeSyntan(memoInp.Text); if (sentlistRep == null || sentlistRep.Count == 0) { return; } sent = sentlistRep[0]; this.para.AddSentStruct(5, sent); var sb = new StringBuilder(); for (int i = 0; i < sent.Capasity; i++) { var word = sent.GetWordByOrder(i); sb.Append(word.EntryName + " " + word.RealWord + "\r\n"); } // Отображение синт связей var ordlist = sent.GetTreeList(); foreach (var x in ordlist) { sb.Append(new String('\t', x.Level) + String.Format("{0} Level {1} link {2} \r\n", sent.GetWordByOrder(x.index).EntryName, x.Level, x.linktype)); } memoOut.Text = sb.ToString(); }
private void btReadPara_Click(object sender, EventArgs e) { var ParagraphID = 1; var sentlist = store.ReadParagraphDB(ParagraphID); // прочитался параграф из БД - надо его ресторить и выдать на просмотр var sb = new StringBuilder(); var reparedsents = store.MorphGetReparedSentsList(sentlist); foreach (var sentrep in reparedsents) { sb.Append(sentrep + "\r\n"); } // Отображение синт связей foreach (var sent in sentlist) { var ordlist = sent.GetTreeList(); foreach (var x in ordlist) { sb.Append(new String('\t', x.Level) + String.Format("{0} Level {1} link {2} \r\n", sent.GetWordByOrder(x.index).EntryName, x.Level, x.linktype)); } } memoOut.Text = sb.ToString(); }
public static SentenceAsm Convert(SentenceMap smap) { var asm = new SentenceAsm(); for (int i = 0; i < smap.Capasity; i++) { var wmap = smap.GetWordByOrder(i); var wasm = new WordAsm(wmap.ID_Entry, wmap.ID_PartOfSpeech); wasm.xPart = wmap.xPart; wasm.EntryName = wmap.EntryName; wasm.Order = wmap.order; wasm.RealWord = wmap.RealWord; wasm.rcind = wmap.rcind; // Чтение граммем var Grammems = wmap.GetPairs(); foreach (var g in Grammems) { var asmgramm = new GrammemAsm(g.Key, g.Value); wasm.AddGrammem(asmgramm); } asm.AddWord(i, wasm); } var mapNodes = smap.GetTreeList(); foreach (var node in mapNodes) { var asmgsynt = new SyntNodeAsm(-1, node.linktype, node.Level, -1, node.index, node.parentind); asm.AddNode(asmgsynt); } return(asm); }
/// <summary> /// Восстановление предложения из грамматических характеристик каждого слова /// с использованием обобщённой функции sol_GenerateWordformsFX. /// </summary> public string RestoreSentenceOnePass(SentenceMap sentence) { if (sentence == null) { return(""); } // Перечень характеристик, нужных для восстановления слова по словоформе var props = new GrenProperty[] { GrenProperty.NUMBER_ru, GrenProperty.CASE_ru, GrenProperty.GENDER_ru, GrenProperty.TENSE_ru, GrenProperty.PERSON_ru, GrenProperty.FORM_ru, GrenProperty.SHORTNESS_ru, GrenProperty.COMPAR_FORM_ru }; var sb = new StringBuilder(); var coords = new ArrayList(); var states = new ArrayList(); for (int i = 0; i < sentence.Capasity; i++) { var wmap = sentence.GetWordByOrder(i); coords.Clear(); states.Clear(); foreach (var prop in props) { var val = wmap.GetPropertyValue(prop); if (val > -1) { coords.Add((int)prop); states.Add((int)val); } } // Проверка ID_Entry (В БД не хранится ID_Entry) int entry_id = GrammarEngine.sol_FindEntry(hEngine, wmap.EntryName, wmap.ID_PartOfSpeech, GrammarEngineAPI.RUSSIAN_LANGUAGE); //if( entry_id==-1 ) string word = ""; ArrayList fx = GrammarEngine.sol_GenerateWordformsFX(hEngine, entry_id, coords, states); //ArrayList fx = GrammarEngine.sol_GenerateWordformsFX(hEngine, wmap.ID_Entry, coords, states); if (fx != null && fx.Count > 0) { word = (fx[0] as String).ToLower(); } if (word != "") { if (i == 0) { word = char.ToUpper(word[0]) + word.Substring(1); } if (i > 0 && i < sentence.Capasity && wmap.ID_PartOfSpeech != GrammarEngineAPI.PUNCTUATION_class) { sb.Append(" "); } sb.Append(word); } } return(sb.ToString()); }
/// <summary> /// Восстановление предложения по формам слов, хранящимся в структурах WordMap /// </summary> private string RestorePhrase(SentenceMap sentstruct) { var sb = new StringBuilder(); for (int i = 0; i < sentstruct.Capasity; i++) { var wmap = sentstruct.GetWordByOrder(i); if (i > 0 && i < sentstruct.Capasity && wmap.ID_PartOfSpeech != PUNCTUATION_class) { sb.Append(" "); } sb.Append(wmap.RealWord); } return(sb.ToString()); }
private string PrintGraf(SentenceMap sent) { StringBuilder sb = new StringBuilder(); var ordlist = sent.GetTreeList(); foreach (tNode x in ordlist) { sb.Append(new String('\t', x.Level) + String.Format("{0} Level {1} link {2} \r\n", sent.GetWordByOrder(x.index).EntryName, x.Level, Gren.sgAPI.GetLinkTypeStr(x.linktype))); } return(sb.ToString()); }
private void btMakeDoc_Click(object sender, EventArgs e) { var sb = new StringBuilder(); // Tockenize var sents = store.MorphGetSeparatedSentsList(memoInp.Text); int i = 0; foreach (var sentstr in sents) { sb.Append(sentstr + "\r\n"); // SynAn var sentlistRep = store.MorphMakeSyntan(sentstr); if (sentlistRep == null || sentlistRep.Count == 0) { sb.Append("SynAn error" + "\r\n"); continue; } this.sent = sentlistRep[0]; this.para.AddSentStruct(i, this.sent); // Отображение синт связей var ordlist = sent.GetTreeList(); foreach (var x in ordlist) { sb.Append(new String('\t', x.Level) + String.Format("{0} Level {1} link {2} \r\n", sent.GetWordByOrder(x.index).EntryName, x.Level, x.linktype)); } i++; } var ContID = 2; var DocumentID = store.SaveDocumentBD("tDoc", ContID); this.para.DocumentID = Convert.ToInt64(DocumentID[0].Value); var paramlist = store.SaveParagraphBD(this.para); memoOut.Text = sb.ToString(); }