Esempio n. 1
0
 public FrmAddEditFrame(VerbFrame verb)
 {
     this.txtFrameText.Text        = verb.VerbName;
     this.cmbConcepts.SelectedItem = verb.Predicate.Name;
     this.Text  = "Edit " + verb.VerbName;
     verbResult = verb;
 }
Esempio n. 2
0
        public void AddVerbFrameEntity(VerbFrame verbFrame, Point point)
        {
            VerbFrameEntity VF_entity = new VerbFrameEntity(point.X, point.Y, verbFrame, _TMR, GImSearch, SizeMode);

            Add(VF_entity);
            _dicVerbFrame.Add(verbFrame, VF_entity);
            Control.Invalidate();
        }
Esempio n. 3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            MindMapConcept c = this._ontology.Concepts[this.cmbConcepts.SelectedItem.ToString()];

            this.nounResult   = new NounFrame(this.txtFrameText.Text, c);
            this.verbResult   = new VerbFrame(this.txtFrameText.Text, c);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Esempio n. 4
0
 public FrmAddEditFrame()
 {
     _ontology = new MindMapOntology("1.owl");
     InitializeComponent();
     LoadComboBox();
     //this.cmbConcepts.Items.AddRange(LoadConcepts.LoadGetFile());
     nounResult = null;
     verbResult = null;
 }
Esempio n. 5
0
        public static List <Frame> GetNeighbors(this VerbFrame vf, MindMapTMR tmr)
        {
            List <Frame> frames         = new List <Frame>();
            int          verbFrameIndex = tmr.VerbFrames.IndexOf(vf);
            double       weight         = 0;

            foreach (CaseRole cr in tmr.VerbFrames[verbFrameIndex].CaseRoles.Keys)
            {
                List <NounFrame> nfs = tmr.VerbFrames[verbFrameIndex].CaseRoles[cr];
                foreach (NounFrame NF in nfs)
                {
                    frames.Add(NF);
                }
            }

            foreach (TemporalRelationType trt in tmr.VerbFrames[verbFrameIndex].TemporalRelations.Keys)
            {
                List <VerbFrame> vfs = tmr.VerbFrames[verbFrameIndex].TemporalRelations[trt];
                foreach (VerbFrame VF in vfs)
                {
                    //weight += temporalRelationWeights[trt];
                    frames.Add(VF);
                }
            }

            foreach (DomainRelationType drt in tmr.VerbFrames[verbFrameIndex].DomainRelations.Keys)
            {
                List <VerbFrame> vfs = tmr.VerbFrames[verbFrameIndex].DomainRelations[drt];
                foreach (VerbFrame VF in vfs)
                {
                    //weight += domainRelationWeights[drt];
                    frames.Add(VF);
                }
            }

            foreach (TemporalRelationType trt in tmr.VerbFrames[verbFrameIndex].TemporalRelations_n.Keys)
            {
                List <NounFrame> nfs = tmr.VerbFrames[verbFrameIndex].TemporalRelations_n[trt];
                foreach (NounFrame NF in nfs)
                {
                    frames.Add(NF);
                }
            }

            foreach (DomainRelationType drt in tmr.VerbFrames[verbFrameIndex].DomainRelations_n.Keys)
            {
                List <NounFrame> nfs = tmr.VerbFrames[verbFrameIndex].DomainRelations_n[drt];
                foreach (NounFrame NF in nfs)
                {
                    frames.Add(NF);
                }
            }
            return(frames);
        }
Esempio n. 6
0
        public VerbFrameEntity(int x, int y, VerbFrame verbFrame)
            : base(0, 0, 70, 40, verbFrame.VerbName, "")

        {
            _verbFrame = verbFrame;
            if (IsGoogleImage())
            {
                _bitmap    = GoogleSearch.GetImage(verbFrame.VerbName);
                _rectangle = new Rectangle(x, y, _bitmap.Width, _bitmap.Height);
                _position  = new PointF(x + _bitmap.Width / 2, y + _bitmap.Height / 2);
            }
        }
Esempio n. 7
0
 private void GetConceptCombinationText(Frame currConcept, int maxLevel, int currLevel, List <double> nfWeights, double frameWeight, ref List <Frame> visitedNodes, ref Frame maxConcept, ref double RelWeight)
 {
     visitedNodes.Add(currConcept);
     if (currConcept is NounFrame)
     {
         NounFrame nf = (NounFrame)currConcept;
         if (currLevel != maxLevel)
         {
             List <Frame> frames = nf.GetNeighbors(_tmr);
             for (int i = 0; i < frames.Count; i++)
             {
                 if (!visitedNodes.Contains(frames[i]))
                 {
                     GetConceptCombinationText(frames[i], maxLevel, currLevel + 1, nfWeights, frameWeight, ref visitedNodes, ref maxConcept, ref RelWeight);
                 }
             }
         }
         else
         {
             double currRelWeight = nfWeights[_tmr.Nounframes.IndexOf(nf)] / frameWeight;
             if (maxConcept == null)
             {
                 RelWeight  = currRelWeight;
                 maxConcept = currConcept;
             }
             else
             {
                 if (currRelWeight > RelWeight)
                 {
                     RelWeight  = currRelWeight;
                     maxConcept = currConcept;
                 }
             }
         }
     }
     else if (currConcept is VerbFrame)
     {
         if (currLevel != maxLevel)
         {
             VerbFrame    vf     = (VerbFrame)currConcept;
             List <Frame> frames = vf.GetNeighbors(_tmr);
             for (int i = 0; i < frames.Count; i++)
             {
                 if (!visitedNodes.Contains(frames[i]))
                 {
                     GetConceptCombinationText(frames[i], maxLevel, currLevel + 1, nfWeights, frameWeight, ref visitedNodes, ref maxConcept, ref RelWeight);
                 }
             }
         }
     }
 }
Esempio n. 8
0
        public override double WeighVerbFrame(int verbFrameIndex)
        {
            VerbFrame VF = _mindMapTMR.VerbFrames[verbFrameIndex];
            //relations of verb frames ---> CaseRoles, Domain Relations, Temporal Relations
            //CaseRoles stored in VF.CaseRoles (dictionary)
            //Temporal Relations stored in VF.TemporalRelations (dictionary)
            //Domain Relations stored in VF.DomainRelations (dictionary)
            double Weight = 0;

            for (int i = 0; i < Enum.GetNames(typeof(CaseRole)).Length; i++)//CaseRoles
            {
                List <NounFrame> ListofNF = VF.CaseRoles[(CaseRole)i];
                int count = ListofNF.Count;
                if (count != 0)
                {
                    for (int j = 0; j < count; j++)
                    {
                        Weight += caseRoleWeights[(CaseRole)i];
                    }
                }
            }
            for (int i = 0; i < Enum.GetNames(typeof(DomainRelationType)).Length; i++)//Domain Relations
            {
                List <VerbFrame> ListofVF = VF.DomainRelations[(DomainRelationType)i];
                int count = ListofVF.Count;
                if (count != 0)
                {
                    for (int j = 0; j < count; j++)
                    {
                        Weight += domainRelationWeights[(DomainRelationType)i];
                    }
                }
            }
            for (int i = 0; i < Enum.GetNames(typeof(TemporalRelationType)).Length; i++)//Temporal Relations
            {
                List <VerbFrame> ListofVF = VF.TemporalRelations[(TemporalRelationType)i];
                int count = ListofVF.Count;
                if (count != 0)
                {
                    for (int j = 0; j < count; j++)
                    {
                        Weight += temporalRelationWeights[(TemporalRelationType)i];
                    }
                }
            }

            return(Weight);
        }
Esempio n. 9
0
        public VerbFrameEntity(int x, int y, VerbFrame verbFrame, MindMapTMR tmr, NewGoogleSearch googleImSearch, DrawingSizeMode SizeMode)
            : base(0, 0, 70, 40, verbFrame.VerbName, "")
        {
            _tmr           = tmr;
            _SizeMode      = SizeMode;
            GoogleImSearch = googleImSearch;
            string Text = "";

            _verbFrame = verbFrame;
            if (_verbFrame.AdverbsInfo != null)
            {
                foreach (MyWordInfo mwi in _verbFrame.AdverbsInfo)
                {
                    Text += mwi.Word;
                }
            }
            Text += (_verbFrame.VerbName);

            _text = Text;
            if (IsGoogleImage())
            {
                //_bitmap = GoogleSearch.GetImage(verbFrame.VerbName);
                //_rectangle = new Rectangle(x, y, _bitmap.Width, _bitmap.Height);
                //_position = new PointF(x + _bitmap.Width / 2, y + _bitmap.Height / 2);



                IList <IImageResult> Results;
                if (_SizeMode == DrawingSizeMode.Normal)
                {
                    Results = GoogleImSearch.Search2(_text);
                }
                else
                {
                    ImageSize imsize = GetAutoSize();
                    Results = GoogleImSearch.Search2(_text, imsize);
                }
                if (Results.Count >= 1)
                {
                    googleImSearch.LoadImageFromUrl(Results[0].TbImage.Url, picbox);
                    _bitmap    = new Bitmap(picbox.Image);
                    _rectangle = new Rectangle(x, y, _bitmap.Width, _bitmap.Height);
                    _position  = new PointF(x + _bitmap.Width / 2, y + _bitmap.Height / 2);
                }
            }
        }
Esempio n. 10
0
        public void HandleExpansion(Frame f, List <pics> Picforms)
        {
            bool Flag = false;

            if (f != null)
            {
                MindMapTMR NewTMR = new MindMapTMR();

                if (f is NounFrame)
                {
                    List <Frame> Frames = new List <Frame>();
                    Frames.Add(f);


                    foreach (Frame frame in this.ML.VerbFrames_NounFrames.Keys)
                    {
                        foreach (Dictionary <OurMindMapOntology.MindMapConcept, List <Frame> > dictionary in this.ML.VerbFrames_NounFrames[frame])
                        {
                            foreach (OurMindMapOntology.MindMapConcept c in dictionary.Keys)
                            {
                                if (c == f.Concept)
                                {
                                    Frames.Clear();
                                    Frames = dictionary[c];
                                    if (Frames.Count > 1)
                                    {
                                        Flag = true;
                                    }
                                }
                            }
                        }
                    }

                    foreach (Frame _f in Frames)
                    {
                        NounFrame nounframe = (NounFrame)_f;
                        if (NewTMR.Nounframes.Contains(nounframe) == false)
                        {
                            NewTMR.Nounframes.Add(nounframe);
                        }
                        Dictionary <CaseRole, List <VerbFrame> > AssociatedActions = this.OriginalTMR.GetNounFrameAssociatedactions(this.OriginalTMR.Nounframes.IndexOf((NounFrame)_f));
                        foreach (CaseRole cr in AssociatedActions.Keys)
                        {
                            foreach (VerbFrame vf in AssociatedActions[cr])
                            {
                                if (NewTMR.VerbFrames.Contains(vf) == false)
                                {
                                    NewTMR.VerbFrames.Add(vf);
                                }
                            }
                        }

                        foreach (CaseRole cr in nounframe.Ownerof.Keys)
                        {
                            for (int i = 0; i < nounframe.Ownerof[cr].Count; i++)
                            {
                                if (NewTMR.Nounframes.Contains(nounframe.Ownerof[cr][i]) == false)
                                {
                                    NewTMR.Nounframes.Add(nounframe.Ownerof[cr][i]);
                                }
                            }
                        }

                        foreach (NounFrame nf in this.OriginalTMR.Nounframes)
                        {
                            foreach (CaseRole cr in nf.Ownerof.Keys)
                            {
                                foreach (NounFrame nf2 in nf.Ownerof[cr])
                                {
                                    if (nf2 == nounframe && NewTMR.Nounframes.Contains(nf) == false)
                                    {
                                        NewTMR.Nounframes.Add(nf);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (f is VerbFrame)
                {
                    NounFrame nf = null;

                    VerbFrame vf = (VerbFrame)f;
                    foreach (CaseRole cr in vf.CaseRoles.Keys)
                    {
                        foreach (NounFrame nf1 in vf.CaseRoles[cr])
                        {
                            foreach (NounFrame nf2 in ML.MainNounFrames)
                            {
                                if (nf1 == nf2)
                                {
                                    nf = nf1;
                                    NewTMR.Nounframes.Add(nf);
                                }
                            }
                        }
                    }
                    if (nf != null)
                    {
                        if (ML.MainNounFrames_VerbFrames[nf][vf.Concept].Count > 1)
                        {
                            Flag = true;
                            foreach (VerbFrame vf2 in ML.MainNounFrames_VerbFrames[nf][vf.Concept])
                            {
                                NewTMR.VerbFrames.Add(vf2);
                                //NewTMR.VerbFrames.Add((VerbFrame)ML.NewFrame_OriginalFrame[(Frame)vf2]);
                            }
                        }
                        else
                        {
                            NewTMR.VerbFrames.Add((VerbFrame)ML.NewFrame_OriginalFrame[(Frame)vf]);
                        }
                    }
                }

                for (int k = 0; k < NewTMR.VerbFrames.Count; k++)
                {
                    VerbFrame vf = NewTMR.VerbFrames[k];
                    foreach (DomainRelationType drt in vf.DomainRelations.Keys)
                    {
                        for (int i = 0; i < vf.DomainRelations[drt].Count; i++)
                        {
                            if (NewTMR.VerbFrames.Contains(vf.DomainRelations[drt][i]) == false)
                            {
                                NewTMR.VerbFrames.Add(vf.DomainRelations[drt][i]);
                            }
                        }
                    }
                }

                for (int k = 0; k < NewTMR.VerbFrames.Count; k++)
                {
                    VerbFrame vf = NewTMR.VerbFrames[k];
                    foreach (TemporalRelationType trt in vf.TemporalRelations.Keys)
                    {
                        for (int i = 0; i < vf.TemporalRelations[trt].Count; i++)
                        {
                            if (NewTMR.VerbFrames.Contains(vf.TemporalRelations[trt][i]) == false)
                            {
                                NewTMR.VerbFrames.Add(vf.TemporalRelations[trt][i]);
                            }
                        }
                    }
                }

                foreach (VerbFrame vf in NewTMR.VerbFrames)
                {
                    foreach (DomainRelationType drt in vf.DomainRelations_n.Keys)
                    {
                        for (int i = 0; i < vf.DomainRelations_n[drt].Count; i++)
                        {
                            if (NewTMR.Nounframes.Contains(vf.DomainRelations_n[drt][i]) == false)
                            {
                                NewTMR.Nounframes.Add(vf.DomainRelations_n[drt][i]);
                            }
                        }
                    }
                }

                foreach (VerbFrame vf in NewTMR.VerbFrames)
                {
                    foreach (TemporalRelationType trt in vf.TemporalRelations_n.Keys)
                    {
                        for (int i = 0; i < vf.TemporalRelations_n[trt].Count; i++)
                        {
                            if (NewTMR.Nounframes.Contains(vf.TemporalRelations_n[trt][i]) == false)
                            {
                                NewTMR.Nounframes.Add(vf.TemporalRelations_n[trt][i]);
                            }
                        }
                    }
                }

                foreach (VerbFrame vf in NewTMR.VerbFrames)
                {
                    foreach (CaseRole cr in vf.CaseRoles.Keys)
                    {
                        foreach (NounFrame nf in vf.CaseRoles[cr])
                        {
                            if (NewTMR.Nounframes.Contains(nf) == false)
                            {
                                NewTMR.Nounframes.Add(nf);
                            }
                        }
                    }
                }

                List <NounFrame> nfs = new List <NounFrame>();
                if (Flag == false)
                {
                    foreach (NounFrame nf in NewTMR.Nounframes)
                    {
                        foreach (CaseRole cr in nf.Ownerof.Keys)
                        {
                            foreach (NounFrame nf2 in nf.Ownerof[cr])
                            {
                                if (NewTMR.Nounframes.Contains(nf2) == false)
                                {
                                    nfs.Add(nf2);
                                }
                            }
                        }
                    }
                }

                foreach (NounFrame nf in nfs)
                {
                    if (NewTMR.Nounframes.Contains(nf) == false)
                    {
                        NewTMR.Nounframes.Add(nf);
                    }
                }
                pics newForm;

                if (Flag == true)
                {
                    newForm = new pics(NewTMR, this.OriginalTMR, ML, _level + 1, Picforms, _settings, _DrawSizeMode);
                }
                else
                {
                    if (NewTMR.VerbFrames.Count != 0 || NewTMR.VerbFrames.Count != 0)
                    {
                        MultilevelGenerator.MultiLevel NewML = new MultilevelGenerator.MultiLevel(NewTMR);
                        MindMapTMR NewNewTMR = NewML.Run();
                        newForm = new pics(NewNewTMR, this.OriginalTMR, NewML, _level + 1, Picforms, _settings, _DrawSizeMode);
                    }
                    else
                    {
                        return;
                    }
                }
                if (f.Concept != null)
                {
                    newForm.descText = f.Concept.Text;
                }
                else if (f is NounFrame)
                {
                    newForm.descText = ((NounFrame)f).Text;
                }
                else
                {
                    newForm.descText = ((VerbFrame)f).VerbName;
                }


                newForm.Text      = this.Text;
                newForm.MdiParent = this.MdiParent;
                newForm.Show();
            }
        }
Esempio n. 11
0
        private void panel1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Frame f = viewer.getDoubleClickedFrame(e.X, e.Y);

            if (f != null)
            {
                MindMapTMR NewTMR = new MindMapTMR();

                if (f is NounFrame && this.ML.MainNounFrames.Contains((NounFrame)f) == false)
                {
                    List <VerbFrame> verbFrames = new List <VerbFrame>();
                    Dictionary <CaseRole, List <VerbFrame> > AssociatedActions = this.CurrentTMR.GetNounFrameAssociatedactions(this.CurrentTMR.Nounframes.IndexOf((NounFrame)f));
                    foreach (CaseRole cr in AssociatedActions.Keys)
                    {
                        foreach (VerbFrame vf in AssociatedActions[cr])
                        {
                            verbFrames.Add(vf);
                        }
                    }

                    foreach (VerbFrame vf in verbFrames)
                    {
                        VerbFrame original_vf = (VerbFrame)this.ML.NewFrame_OriginalFrame[vf];
                        NewTMR.VerbFrames.Add(original_vf);
                    }
                }
                else if (f is VerbFrame)
                {
                    NounFrame nf = null;

                    VerbFrame vf = (VerbFrame)f;
                    foreach (CaseRole cr in vf.CaseRoles.Keys)
                    {
                        foreach (NounFrame nf1 in vf.CaseRoles[cr])
                        {
                            foreach (NounFrame nf2 in ML.MainNounFrames)
                            {
                                if (nf1 == nf2)
                                {
                                    nf = nf1;
                                    NewTMR.Nounframes.Add(nf);
                                }
                            }
                        }
                    }
                    if (nf != null)
                    {
                        if (ML.MainNounFrames_VerbFrames[nf][vf.Concept].Count > 1)
                        {
                            foreach (VerbFrame vf2 in ML.MainNounFrames_VerbFrames[nf][vf.Concept])
                            {
                                NewTMR.VerbFrames.Add(vf2);
                            }
                        }
                        else
                        {
                            NewTMR.VerbFrames.Add(vf);
                        }
                    }
                }

                foreach (VerbFrame vf in NewTMR.VerbFrames)
                {
                    foreach (CaseRole cr in vf.CaseRoles.Keys)
                    {
                        foreach (NounFrame nf in vf.CaseRoles[cr])
                        {
                            if (NewTMR.Nounframes.Contains(nf) == false)
                            {
                                NewTMR.Nounframes.Add(nf);
                            }
                        }
                    }
                }

                FrmNewTMR newForm = new FrmNewTMR(NewTMR, this.OriginalTMR, ML);
                newForm.Text = f.Concept.Name;
                newForm.ShowDialog();
            }
        }
Esempio n. 12
0
        public TMRVerbFrameEntity(int x, int y, VerbFrame verbFrame)
            : base(0, 0, 70, 40, verbFrame.VerbName, "")

        {
            _verbFrame = verbFrame;
        }
Esempio n. 13
0
        public MindMapTMR Run()
        {
            MainNounFrames_VerbFrames = new Dictionary <NounFrame, Dictionary <MindMapConcept, List <Frame> > >();
            VerbFrames_NounFrames     = new Dictionary <Frame, List <Dictionary <MindMapConcept, List <Frame> > > >();
            NewFrame_OriginalFrame    = new Dictionary <Frame, Frame>();

            //new TMR..
            MindMapTMR NewTMR = new MindMapTMR();

            //Initializing el status beta3 kol frame..
            this.FramesStatus = new List <FrameStatus>();
            for (int i = 0; i < this.TMR.Nounframes.Count + this.TMR.VerbFrames.Count; i++)
            {
                this.FramesStatus.Add(FrameStatus.Hidden);
            }

            //Weight-based partitioning of the nounframes..
            List <Frame> Nounframes = new List <Frame>();

            foreach (Frame f in this.TMR.Nounframes)
            {
                Nounframes.Add(f);
            }
            WeightBasedPartitioner wbp1     = new WeightBasedPartitioner(Nounframes, this.NounFramesWeights);
            List <List <Frame> >   Clusters = wbp1.Partition();

            //getting maximum centroid  cluster
            List <int> dummy = getMaximumCentroidCluster(wbp1);

            this.MainNounFrames = new List <NounFrame>();

            foreach (int i in dummy)
            {
                this.MainNounFrames.Add((NounFrame)wbp1.Frames[i]);
                NewTMR.Nounframes.Add((NounFrame)wbp1.Frames[i]);
                this.NewFrame_OriginalFrame.Add((NounFrame)wbp1.Frames[i], wbp1.Frames[i]);
                this.FramesStatus[this.TMR.Nounframes.IndexOf((NounFrame)wbp1.Frames[i])] = FrameStatus.Present;
            }

            foreach (NounFrame main_nf1 in this.MainNounFrames)
            {
                foreach (NounFrame main_nf2 in this.MainNounFrames)
                {
                    if (main_nf1 != main_nf2)
                    {
                        List <List <Frame> >    paths     = new List <List <Frame> >();
                        List <List <CaseRole> > relations = new List <List <CaseRole> >();
                        GetRelations((Frame)main_nf1, (Frame)main_nf2, out paths, out relations);

                        foreach (List <Frame> path in paths)
                        {
                            foreach (Frame f in path)
                            {
                                if (f is NounFrame)
                                {
                                    if (this.FramesStatus[this.TMR.Nounframes.IndexOf((NounFrame)f)] == FrameStatus.Hidden)
                                    {
                                        NewTMR.Nounframes.Add((NounFrame)f);
                                        this.FramesStatus[this.TMR.Nounframes.IndexOf((NounFrame)f)] = FrameStatus.Present;
                                    }
                                }
                                else
                                {
                                    if (this.FramesStatus[this.TMR.Nounframes.Count + this.TMR.VerbFrames.IndexOf((VerbFrame)f)] == FrameStatus.Hidden)
                                    {
                                        NewTMR.VerbFrames.Add((VerbFrame)f);
                                        this.FramesStatus[this.TMR.Nounframes.Count + this.TMR.VerbFrames.IndexOf((VerbFrame)f)] = FrameStatus.Present;
                                    }
                                }
                            }
                        }
                    }
                }
            }


            for (int i = 0; i < this.MainNounFrames.Count; i++)
            {
                List <VerbFrame> nf_verbframes         = new List <VerbFrame>();
                List <double>    nf_verbframes_weights = new List <double>();

                Dictionary <CaseRole, List <VerbFrame> > AssociatedActions = this.TMR.GetNounFrameAssociatedactions(this.TMR.Nounframes.IndexOf(this.MainNounFrames[i]));
                foreach (CaseRole cr in AssociatedActions.Keys)
                {
                    foreach (VerbFrame vf in AssociatedActions[cr])
                    {
                        if (FramesStatus[this.TMR.VerbFrames.IndexOf(vf) + this.TMR.Nounframes.Count] == FrameStatus.Hidden && nf_verbframes.Contains(vf) == false)
                        {
                            nf_verbframes.Add(vf);
                            nf_verbframes_weights.Add(this.VerbFramesWeights[this.TMR.VerbFrames.IndexOf(vf)]);
                        }
                    }
                }

                List <Frame> Verbframes = new List <Frame>();
                foreach (Frame f in nf_verbframes)
                {
                    Verbframes.Add(f);
                }

                Dictionary <MindMapConcept, List <Frame> > concept_VerbFrames = new Dictionary <MindMapConcept, List <Frame> >();
                Dictionary <MindMapConcept, List <Frame> > concept_NounFrames = new Dictionary <MindMapConcept, List <Frame> >();

                concept_VerbFrames = groupFrames(Verbframes);
                this.MainNounFrames_VerbFrames.Add(this.MainNounFrames[i], concept_VerbFrames);

                foreach (MindMapConcept c in concept_VerbFrames.Keys)
                {
                    if (concept_VerbFrames[c].Count > 1)
                    {
                        List <NounFrame> nounframe = new List <NounFrame>();
                        nounframe.Add(this.MainNounFrames[i]);
                        NewTMR.VerbFrames.Add(new VerbFrame(c.Text, c));
                        NewTMR.VerbFrames[NewTMR.VerbFrames.Count - 1].CaseRoles.Add(CaseRole.Agent, nounframe);
                    }
                    else
                    {
                        VerbFrame original_verbframe = (VerbFrame)concept_VerbFrames[c][0];
                        VerbFrame verbFrame          = cloneVerbFrame(original_verbframe);

                        int index = this.TMR.VerbFrames.IndexOf(original_verbframe);
                        foreach (CaseRole cr in verbFrame.CaseRoles.Keys)
                        {
                            List <Frame> NounFrames = new List <Frame>();
                            foreach (NounFrame nf in verbFrame.CaseRoles[cr])
                            {
                                if (this.MainNounFrames.Contains(nf) == false)
                                {
                                    NounFrames.Add(nf);
                                }
                            }
                            if (NounFrames.Count > 5)
                            {
                                concept_NounFrames = groupFrames(NounFrames);
                                if (this.VerbFrames_NounFrames.ContainsKey(concept_VerbFrames[c][0]) == false)
                                {
                                    List <Dictionary <MindMapConcept, List <Frame> > > list = new List <Dictionary <MindMapConcept, List <Frame> > >();
                                    list.Add(concept_NounFrames);
                                    this.VerbFrames_NounFrames.Add(concept_VerbFrames[c][0], list);
                                }
                                else
                                {
                                    this.VerbFrames_NounFrames[concept_VerbFrames[c][0]].Add(concept_NounFrames);
                                }

                                this.FramesStatus[this.TMR.VerbFrames.IndexOf(verbFrame) + this.TMR.Nounframes.Count] = FrameStatus.Present;

                                foreach (MindMapConcept c_nfs in concept_NounFrames.Keys)
                                {
                                    if (concept_NounFrames[c_nfs].Count > 1)
                                    {
                                        NounFrame newNounFrame = new NounFrame(c_nfs.Text, c_nfs);
                                        NewTMR.Nounframes.Add(newNounFrame);
                                        verbFrame.CaseRoles[cr].Add(newNounFrame);

                                        foreach (Frame frame in concept_NounFrames[c_nfs])
                                        {
                                            this.FramesStatus[this.TMR.Nounframes.IndexOf((NounFrame)frame)] = FrameStatus.Grouped;
                                            verbFrame.CaseRoles[cr].Remove((NounFrame)frame);
                                        }
                                    }

                                    else
                                    {
                                        this.FramesStatus[this.TMR.Nounframes.IndexOf((NounFrame)concept_NounFrames[c_nfs][0])] = FrameStatus.Present;
                                    }
                                }
                            }
                        }
                        NewTMR.VerbFrames.Add(verbFrame);
                        NewFrame_OriginalFrame.Add(verbFrame, this.TMR.VerbFrames[index]);
                    }
                }
            }

            for (int k = 0; k < NewTMR.VerbFrames.Count; k++)
            {
                VerbFrame vf = NewTMR.VerbFrames[k];
                foreach (TemporalRelationType trt in vf.TemporalRelations.Keys)
                {
                    for (int i = 0; i < vf.TemporalRelations[trt].Count; i++)
                    {
                        if (NewTMR.VerbFrames.Contains(vf.TemporalRelations[trt][i]) == false)
                        {
                            NewTMR.VerbFrames.Add(vf.TemporalRelations[trt][i]);
                        }
                    }
                }
            }

            for (int k = 0; k < NewTMR.VerbFrames.Count; k++)
            {
                VerbFrame vf = NewTMR.VerbFrames[k];
                foreach (DomainRelationType drt in vf.DomainRelations.Keys)
                {
                    for (int i = 0; i < vf.DomainRelations[drt].Count; i++)
                    {
                        if (NewTMR.VerbFrames.Contains(vf.DomainRelations[drt][i]) == false)
                        {
                            NewTMR.VerbFrames.Add(vf.DomainRelations[drt][i]);
                        }
                    }
                }
            }

            foreach (VerbFrame vf in NewTMR.VerbFrames)
            {
                foreach (CaseRole cr in vf.CaseRoles.Keys)
                {
                    for (int i = 0; i < vf.CaseRoles[cr].Count; i++)
                    {
                        if (NewTMR.Nounframes.Contains(vf.CaseRoles[cr][i]) == false)
                        {
                            NewTMR.Nounframes.Add(vf.CaseRoles[cr][i]);
                        }
                    }
                }
            }

            foreach (VerbFrame vf in NewTMR.VerbFrames)
            {
                foreach (DomainRelationType drt in vf.DomainRelations_n.Keys)
                {
                    for (int i = 0; i < vf.DomainRelations_n[drt].Count; i++)
                    {
                        if (NewTMR.Nounframes.Contains(vf.DomainRelations_n[drt][i]) == false)
                        {
                            NewTMR.Nounframes.Add(vf.DomainRelations_n[drt][i]);
                        }
                    }
                }
            }

            foreach (VerbFrame vf in NewTMR.VerbFrames)
            {
                foreach (TemporalRelationType trt in vf.TemporalRelations_n.Keys)
                {
                    for (int i = 0; i < vf.TemporalRelations_n[trt].Count; i++)
                    {
                        if (NewTMR.Nounframes.Contains(vf.TemporalRelations_n[trt][i]) == false)
                        {
                            NewTMR.Nounframes.Add(vf.TemporalRelations_n[trt][i]);
                        }
                    }
                }
            }

            List <NounFrame> dummylist = new List <NounFrame>();

            foreach (NounFrame nf in NewTMR.Nounframes)
            {
                foreach (CaseRole cr in nf.Ownerof.Keys)
                {
                    for (int i = 0; i < nf.Ownerof[cr].Count; i++)
                    {
                        if (TMR.Nounframes.Contains(nf.Ownerof[cr][i]) == true && NewTMR.Nounframes.Contains(nf.Ownerof[cr][i]) == false && this.FramesStatus[this.TMR.Nounframes.IndexOf(nf.Ownerof[cr][i])] != FrameStatus.Grouped)
                        {
                            dummylist.Add(nf.Ownerof[cr][i]);
                        }
                    }
                }
            }

            foreach (NounFrame nf in TMR.Nounframes)
            {
                foreach (CaseRole cr in nf.Ownerof.Keys)
                {
                    foreach (NounFrame nf2 in nf.Ownerof[cr])
                    {
                        if (NewTMR.Nounframes.Contains(nf2) == true && NewTMR.Nounframes.Contains(nf) == false)
                        {
                            NewTMR.Nounframes.Add(nf);
                        }
                    }
                }
            }



            foreach (NounFrame nf in dummylist)
            {
                if (NewTMR.Nounframes.Contains(nf) == false)
                {
                    NewTMR.Nounframes.Add(nf);
                }
            }



            return(NewTMR);
        }
Esempio n. 14
0
        private VerbFrame cloneVerbFrame(VerbFrame original_verbframe)
        {
            VerbFrame verbFrame = new VerbFrame(original_verbframe.VerbName, original_verbframe.Concept);

            verbFrame.VerbNegation = original_verbframe.VerbNegation;

            foreach (CaseRole cr in original_verbframe.CaseRoles.Keys)
            {
                foreach (NounFrame nf in original_verbframe.CaseRoles[cr])
                {
                    if (verbFrame.CaseRoles.ContainsKey(cr) == false)
                    {
                        List <NounFrame> dummy2 = new List <NounFrame>();
                        dummy2.Add(nf);
                        verbFrame.CaseRoles.Add(cr, dummy2);
                    }
                    else
                    {
                        verbFrame.CaseRoles[cr].Add(nf);
                    }
                }
            }

            foreach (TemporalRelationType trt in original_verbframe.TemporalRelations.Keys)
            {
                foreach (VerbFrame vf in original_verbframe.TemporalRelations[trt])
                {
                    if (verbFrame.TemporalRelations.ContainsKey(trt) == false)
                    {
                        List <VerbFrame> dummy2 = new List <VerbFrame>();
                        dummy2.Add(vf);
                        verbFrame.TemporalRelations.Add(trt, dummy2);
                    }
                    else
                    {
                        verbFrame.TemporalRelations[trt].Add(vf);
                    }
                }
            }

            foreach (DomainRelationType drt in original_verbframe.DomainRelations.Keys)
            {
                foreach (VerbFrame vf in original_verbframe.DomainRelations[drt])
                {
                    if (verbFrame.DomainRelations.ContainsKey(drt) == false)
                    {
                        List <VerbFrame> dummy2 = new List <VerbFrame>();
                        dummy2.Add(vf);
                        verbFrame.DomainRelations.Add(drt, dummy2);
                    }
                    else
                    {
                        verbFrame.DomainRelations[drt].Add(vf);
                    }
                }
            }

            foreach (DomainRelationType drt in original_verbframe.DomainRelations_n.Keys)
            {
                foreach (NounFrame nf in original_verbframe.DomainRelations_n[drt])
                {
                    if (verbFrame.DomainRelations_n.ContainsKey(drt) == false)
                    {
                        List <NounFrame> dummy2 = new List <NounFrame>();
                        dummy2.Add(nf);
                        verbFrame.DomainRelations_n.Add(drt, dummy2);
                    }
                    else
                    {
                        verbFrame.DomainRelations_n[drt].Add(nf);
                    }
                }
            }

            foreach (TemporalRelationType trt in original_verbframe.TemporalRelations_n.Keys)
            {
                foreach (NounFrame nf in original_verbframe.TemporalRelations_n[trt])
                {
                    if (verbFrame.TemporalRelations_n.ContainsKey(trt) == false)
                    {
                        List <NounFrame> dummy2 = new List <NounFrame>();
                        dummy2.Add(nf);
                        verbFrame.TemporalRelations_n.Add(trt, dummy2);
                    }
                    else
                    {
                        verbFrame.TemporalRelations_n[trt].Add(nf);
                    }
                }
            }

            return(verbFrame);
        }