public static termExploreModel getSynonymsWithSerbianWordNet(termExploreModel model, ILogBuilder response) { tokenGraph result = new tokenGraph(model.lemma.inputForm); languageManagerWordnet.manager.queryWithGraph(result, response, WordnetSource.serbian, WordnetQueryType.getSymsetCodesByWord); model.wordnetSecondarySymsets.AddRange(result.getAllLeafs().getNames()); if (response != null) { response.consoleAltColorToggle(); string rst = result.ToStringTreeview(); response.Append(rst); response.consoleAltColorToggle(); } languageManagerWordnet.manager.queryWithGraph(result, response, WordnetSource.serbian, WordnetQueryType.getWordsBySymsetCode); model.synonyms.AddRange(result.getAllLeafs().getNames()); if (response != null) { response.consoleAltColorToggle(); string rst = result.ToStringTreeview(); response.Append(rst); response.consoleAltColorToggle(); } model.graph = result; return(model); }
public static termExploreModel getSynonymsWithSerbianWordNetAndApertium(termExploreModel model, ILogBuilder response) { model = getSynonymsWithSerbianWordNet(model, response); tokenGraph result = model.graph; languageManagerApertium.manager.queryByGraphNode(model.graph, apertiumDictQueryScope.exact, apertiumDictNeedleSide.native); model.translations.AddRange(result.getAllLeafs().getNames()); languageManagerApertium.manager.queryByGraphNode(result, apertiumDictQueryScope.exact, apertiumDictNeedleSide.translated); string st = result.ToStringTreeview(); if (response != null) { response.Append(st); } model.synonyms.AddRange(result.getAllLeafs().getNames()); model.graph = result; return(model); }
public static termExploreModel getSynonymsWithApertium(termExploreModel model, ILogBuilder response) { tokenGraph result = languageManagerApertium.manager.queryForGraph(model.lemma.inputForm, apertiumDictQueryScope.exact); if (result.Count() == 0) { model.wasExploreFailed = true; } else { model.translations.AddRange(result.getAllLeafs().getNames()); languageManagerApertium.manager.queryByGraphNode(result, apertiumDictQueryScope.exact, apertiumDictNeedleSide.translated); string st = result.ToStringTreeview(); if (response != null) { response.Append(st); } model.synonyms.AddRange(result.getAllLeafs().getNames()); } model.graph = result; return(model); }
public static termExploreModel getSynonymsByCorpus(termExploreModel model, ILogBuilder response) { tokenGraph result = new tokenGraph(model.lemma.inputForm); var lines = semanticLexiconManager.manager.settings.sourceFiles.getOperater(lexiconSourceTypeEnum.corpus).Search(model.lemma.inputForm); result.Add(lines.getLineContentList(), tokenGraphNodeType.word_srb); model.synonyms.AddRange(result.getAllLeafs().getNames()); if (response != null) { response.consoleAltColorToggle(); string rst = result.ToStringTreeview(); response.Append(rst); response.consoleAltColorToggle(); } model.graph = result; return(model); }
/// <summary> /// Method: word -- translation --- synset ---- other synsets --- collecting all words --- translation --- word /// </summary> /// <param name="model">The model.</param> /// <param name="response">The response.</param> /// <param name="disableCodePrefixFilter">if set to <c>true</c> [disable code prefix filter].</param> /// <param name="disableCodeBranchFilter">if set to <c>true</c> [disable code branch filter].</param> /// <returns></returns> public static termExploreModel getSynonymsWithWordnetViaApertium(termExploreModel model, ILogBuilder response, bool disableCodePrefixFilter = false, bool disableCodeBranchFilter = false) { tokenGraph result = model.graph; result = languageManagerApertium.manager.queryForGraph(model.lemma.inputForm, apertiumDictQueryScope.exact); model.translations.AddRange(result.getAllLeafs().getNames()); if (response != null) { response.consoleAltColorToggle(); string rst = result.ToStringTreeview(); response.Append(rst); response.consoleAltColorToggle(); } languageManagerWordnet.manager.queryWithGraph(result, response, WordnetSource.english, WordnetQueryType.getSymsetCodesByWord); if (response != null) { response.consoleAltColorToggle(); string st = result.ToStringTreeview(); response.Append(st); response.consoleAltColorToggle(); } model.wordnetSecondarySymsets.AddRange(result.getAllLeafs().getDeepest().getNames()); if (!disableCodePrefixFilter) { string codeStart = model.lemma.gramSet.getPosType().GetWordNetCodeStart().ToString(); Regex codeCriteria = new Regex("^" + codeStart + ""); var badCodes = result.getAllLeafs(codeCriteria, true); if (response != null) { response.AppendHorizontalLine(); response.AppendLine("Reducing to proper codes [" + codeStart + "]->filtered-out[" + badCodes.Count() + "]"); } badCodes.removeFromParent(); if (response != null) { response.consoleAltColorToggle(); string rst = result.ToStringTreeview(); response.Append(rst); response.consoleAltColorToggle(); } } model.wordnetPrimarySymsets.AddRange(result.getAllLeafs().getDeepest().getNames()); languageManagerWordnet.manager.queryWithGraph(result, response, WordnetSource.english, WordnetQueryType.getWordsBySymsetCode); model.translationRelated.AddRange(result.getAllLeafs().getDeepest().getNames()); if (response != null) { response.AppendHorizontalLine(); response.AppendLine("Getting English words by symsetcodes via WordNet"); response.consoleAltColorToggle(); string rst = result.ToStringTreeview(); response.Append(rst); response.consoleAltColorToggle(); } languageManagerApertium.manager.queryByGraphNode(result, apertiumDictQueryScope.exact, apertiumDictNeedleSide.translated); model.wordnetSynonyms.AddRange(result.getAllLeafs().getDeepest().getNames()); if (response != null) { response.AppendHorizontalLine(); response.AppendLine("Translating back to Serbian via Apertium"); response.consoleAltColorToggle(); string rst = result.ToStringTreeview(); response.Append(rst); response.consoleAltColorToggle(); } if (!disableCodeBranchFilter) // <------ removes the symset nodes that contain none of first-level translation words { var codeLevel = result.getAllChildren().getOnLevel(3); List <IObjectWithPathAndChildren> toTakeOut = new List <IObjectWithPathAndChildren>(); foreach (var clb in codeLevel) { foreach (var clb_c in clb) { bool takeOut = true; foreach (var clb_cc in clb_c) { if (clb_cc.name == model.lemma.inputForm) { takeOut = false; break; } } if (takeOut) { if (response != null) { response.AppendLine("-- take out: " + clb.path); } toTakeOut.Add(clb); break; } } } toTakeOut.removeFromParent(); int wps = Enumerable.Count(model.wordnetSecondarySymsets); int tr = Enumerable.Count(model.translationRelated); int ws = Enumerable.Count(model.wordnetSynonyms); if (response != null) { response.AppendLine("----- Branch-node filter ----"); response.AppendLine("Symsets: " + wps); response.AppendLine("Translations: " + tr); response.AppendLine("Terms: " + ws); response.consoleAltColorToggle(); string rst = result.ToStringTreeview(); response.Append(rst); response.consoleAltColorToggle(); } model.wordnetPrimarySymsets = result.getAllChildren().getOnLevel(3).getNames(true); model.translations = result.getAllChildren().getOnLevel(4).getNames(true); model.synonyms = result.getAllChildren().getOnLevel(5).getNames(true); wps = wps - Enumerable.Count(model.wordnetPrimarySymsets); tr = tr - Enumerable.Count(model.translations); ws = ws - Enumerable.Count(model.synonyms); if (response != null) { //response.AppendLine("----- Branch-node filter ----"); response.AppendLine("Reduction of Symsets: " + wps); response.AppendLine("Reduction of Translations: " + tr); response.AppendLine("Reduction of Terms: " + ws); response.consoleAltColorToggle(); string rst = result.ToStringTreeview(); response.Append(rst); response.consoleAltColorToggle(); } } /* * String rgex_pat = "^([\\w]*\\\\[\\w]*\\\\[\\w]*\\\\[\\w]*\\\\{0}$)"; * * Regex rgex = new Regex(String.Format(rgex_pat, model.lemma.inputForm)); * * var onlyWithLemma = result.getAllLeafs().getFilterOut(rgex); */ //languageManagerApertium.manager.queryByGraphNode(result, apertiumDictQueryScope.exact, apertiumDictNeedleSide.english); model.graph = result; return(model); }