//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ private void InsertFactors(ISession pSess, WordNetEngine.SynSetRelation pRel, DescriptorTypeId pDescTypeId, int?pDescTypeRefineWordId = null, bool pIsDef = false) { Console.WriteLine("Loading " + pRel + " Lexicals..."); IList <Lexical> lexList = pSess.QueryOver <Lexical>() .Where(x => x.RelationId == (byte)pRel) .List(); Console.WriteLine("Found " + lexList.Count + " " + pRel + " Lexicals" + TimerString()); using (ITransaction tx = pSess.BeginTransaction()) { Console.WriteLine("Building Factors..."); var oppMap = new HashSet <string>(); int oppSkips = 0; foreach (Lexical lex in lexList) { Artifact art = (vArtSet.WordIdMap.ContainsKey(lex.Word.Id) ? vArtSet.WordIdMap[lex.Word.Id] : vArtSet.SynsetIdMap[lex.Synset.Id]); Artifact targArt = (vArtSet.WordIdMap.ContainsKey(lex.TargetWord.Id) ? vArtSet.WordIdMap[lex.TargetWord.Id] :vArtSet.SynsetIdMap[lex.TargetSynset.Id]); if (oppMap.Contains(targArt.Id + "|" + art.Id)) { oppSkips++; continue; //avoid creating a B->A "duplicate" of an existing A->B Factor } oppMap.Add(art.Id + "|" + targArt.Id); var f = new Factor(); f.Lexical = lex; f.PrimaryArtifact = art; f.RelatedArtifact = targArt; f.IsDefining = pIsDef; f.DescriptorTypeId = (byte)pDescTypeId; f.AssertionId = (byte)FactorAssertionId.Fact; f.Note = "[" + art.Name + "] " + pDescTypeId + " [" + targArt.Name + "] {LEX." + pRel + "}"; if (pDescTypeRefineWordId != null) { f.DescriptorTypeRefine = vArtSet.WordIdMap[(int)pDescTypeRefineWordId]; } pSess.Save(f); } Console.WriteLine("Skipped " + oppSkips + " reversed Factors..." + TimerString()); Console.WriteLine("Comitting Factors..." + TimerString()); tx.Commit(); Console.WriteLine("Finished Factors" + TimerString()); Console.WriteLine(""); } }
/*--------------------------------------------------------------------------------------------*/ private void InsertFactors(ISession pSess, WordNetEngine.SynSetRelation pRel, DescriptorTypeId pDescTypeId, int?pDescTypeRefineWordId = null, bool pIsDef = false) { Console.WriteLine("Loading " + pRel + " Semantics..."); IList <Semantic> semList = pSess.QueryOver <Semantic>() .Where(x => x.RelationId == (byte)pRel) .List(); Console.WriteLine("Found " + semList.Count + " " + pRel + " Semantics" + TimerString()); using (ITransaction tx = pSess.BeginTransaction()) { Console.WriteLine("Building Factors..."); foreach (Semantic sem in semList) { Artifact art = vArtSet.SynsetIdMap[sem.Synset.Id]; Artifact targArt = vArtSet.SynsetIdMap[sem.TargetSynset.Id]; var f = new Factor(); f.Semantic = sem; f.PrimaryArtifact = art; f.RelatedArtifact = targArt; f.IsDefining = pIsDef; f.DescriptorTypeId = (byte)pDescTypeId; f.AssertionId = (byte)FactorAssertionId.Fact; f.Note = "[" + art.Name + "] " + pDescTypeId + " [" + targArt.Name + "] {" + pRel + "}"; if (pDescTypeRefineWordId != null) { f.DescriptorTypeRefine = vArtSet.WordIdMap[(int)pDescTypeRefineWordId]; } pSess.Save(f); } Console.WriteLine("Comitting Factors..." + TimerString()); tx.Commit(); Console.WriteLine("Finished Factors" + TimerString()); Console.WriteLine(""); } }