public static List <Frame> GetNeighbors(this NounFrame nf, MindMapTMR tmr) { List <Frame> frames = new List <Frame>(); Dictionary <CaseRole, List <VerbFrame> > Associatedactions = tmr.GetNounFrameAssociatedactions(tmr.Nounframes.IndexOf(nf)); //Array caseRoleArr = Enum.GetValues(typeof(CaseRole)); int len = Enum.GetNames(typeof(CaseRole)).Length; for (int i = 0; i < Enum.GetNames(typeof(CaseRole)).Length; i++) { //Enum.GetValues(CaseRole) if (Associatedactions.ContainsKey((CaseRole)i)) { List <VerbFrame> ListofVF = Associatedactions[(CaseRole)i]; foreach (VerbFrame vf in ListofVF) { frames.Add(vf); } } if (nf.Ownerof.ContainsKey((CaseRole)i)) { foreach (NounFrame nfi in nf.Ownerof[(CaseRole)i]) { frames.Add(nfi); } } } return(frames); }
public override double WeighNounFrame(int nounFrameIndex) { LoadRelationWeights(); LoadRelationFactors(); NounFrame NF = _mindMapTMR.Nounframes[nounFrameIndex]; //relations of noun frames ---> CaseRoles Dictionary <CaseRole, List <VerbFrame> > Associatedactions = MindMapTMR.GetNounFrameAssociatedactions(nounFrameIndex); double Weight = 0; //Array caseRoleArr = Enum.GetValues(typeof(CaseRole)); int len = Enum.GetNames(typeof(CaseRole)).Length; for (int i = 0; i < Enum.GetNames(typeof(CaseRole)).Length; i++) { //Enum.GetValues(CaseRole) if (Associatedactions.ContainsKey((CaseRole)i)) { List <VerbFrame> ListofVF = Associatedactions[(CaseRole)i]; int count = ListofVF.Count; if (count != 0) { for (int j = 0; j < count; j++) { Weight += caseRoleWeights[(CaseRole)i]; } } } } return(Weight); }
public FrmAddEditFrame(NounFrame noun) : this() { this.txtFrameText.Text = noun.Text; this.cmbConcepts.SelectedItem = noun.Concept; this.Text = "Edit " + noun.Text; nounResult = noun; }
public void AddNounFrameEntity(NounFrame nounFrame, Point point) { NounFrameEntity nfe = new NounFrameEntity(point.X, point.Y, nounFrame, _TMR, GImSearch, SizeMode, _conceptCombination); this.Add(nfe); _dicNounFrame.Add(nounFrame, nfe); Control.Invalidate(); }
public FrmAddEditFrame() { _ontology = new MindMapOntology("1.owl"); InitializeComponent(); LoadComboBox(); //this.cmbConcepts.Items.AddRange(LoadConcepts.LoadGetFile()); nounResult = null; verbResult = null; }
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(); }
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); } } } } }
void FilterMeaningRepresentationForDrawing() { for (int i = 0; i < _TMR.Nounframes.Count; i++) { NounFrame nf = _TMR.Nounframes[i]; if (nf.Ownerof.ContainsKey(CaseRole.Possession)) { List <NounFrame> Pnfs = nf.Ownerof[CaseRole.Possession]; for (int j = 0; j < Pnfs.Count; j++) { NounFrame nfj = Pnfs[j]; if (_TMR.HasNoRelationsExceptFrom(Pnfs[j], nf)) { MyWordInfo wi = new MyWordInfo(); wi.Word = nfj.Text; wi.Sense = nfj.ParseNode.SenseNo; //TODO : assign part of speach here //wi.Pos = bool found = false; foreach (MyWordInfo winfo in nf.AdjectivesInfo) { if (wi.Word == winfo.Word) { found = true; break; } } if (!found) { nf.AdjectivesInfo.Add(wi); } int index = _TMR.Nounframes.IndexOf(nfj); Pnfs.RemoveAt(j); j--; if (index != -1) { _TMR.Nounframes.RemoveAt(index); if (index < i) { i--; } } } } } } }
private void btnAddCaseRole_Click(object sender, EventArgs e) { FrmCaseRoleRelation form = new FrmCaseRoleRelation(tmr.Nounframes, tmr.VerbFrames); if (form.ShowDialog() == DialogResult.OK) { NounFrame currentNoun = tmr.Nounframes[form.NounIndex]; CaseRole c = form.Relation; int currentVerbIndex = form.VerbIndex; if (!this.tmr.VerbFrames[currentVerbIndex].CaseRoles.ContainsKey(c) || !this.tmr.VerbFrames[currentVerbIndex].CaseRoles[c].Contains(currentNoun)) { this.tmr.VerbFrames[currentVerbIndex].AddCaseRole(c, currentNoun); this.viewer.UpdateRelations(); } } }
public TMRNounFrameEntity(int x, int y, NounFrame nounFrame) : base(0, 0, 70, 40, nounFrame.Text, "") //:base(0,0,70,40,nounFrame.Text) { _nounFrame = nounFrame; string Text = ""; Text += (_nounFrame.Text); _nounFrame.SearchText1 = Text; Text2 = nounFrame.IS_a; if (IsGoogleImage()) { _bitmap = GoogleSearch.GetImage(_nounFrame.SearchText1); _rectangle = new Rectangle(x, y, _bitmap.Width, _bitmap.Height); _position = new PointF(x + _bitmap.Width / 2, y + _bitmap.Height / 2); } }
public TMRNounFrameEntity(int x, int y, NounFrame nounFrame, NewGoogleSearch googleImSearch) : base(0, 0, 70, 40, nounFrame.Text, "") //:base(0,0,70,40,nounFrame.Text) { GoogleImSearch = googleImSearch; _nounFrame = nounFrame; string Text = ""; //////////////////////////// if (_nounFrame.AdjectivesInfo != null) { foreach (MyWordInfo mwi in _nounFrame.AdjectivesInfo) { Text += mwi.Word; } } Text += (_nounFrame.Text); /////////////////////////// _nounFrame.SearchText1 = Text; Text2 = nounFrame.IS_a; if (IsGoogleImage()) { //_bitmap = GoogleSearch.GetImage(_nounFrame.SearchText1); IList <IImageResult> Results = GoogleImSearch.Search2(_nounFrame.SearchText1); 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); } } }
private void getShortertPathtoMainNounFrames(NounFrame nf, out List <Frame> Path, out List <CaseRole> Relations) { Path = null; Relations = null; int ShortestPathDistance = int.MaxValue; List <List <Frame> > Paths; List <List <CaseRole> > PathsRelations; foreach (NounFrame mainnounframe in this.MainNounFrames) { checkedRelations.Clear(); GetRelations(nf, mainnounframe, out Paths, out PathsRelations); for (int i = 0; i < Paths.Count; i++) { if (Paths[i].Count < ShortestPathDistance) { Path = Paths[i]; Relations = PathsRelations[i]; ShortestPathDistance = Paths[i].Count; } } } }
public NounFrameEntity(int x, int y, NounFrame nounFrame) : base(0, 0, 70, 40, nounFrame.Text, "") { _nounFrame = nounFrame; string Text = ""; if (_nounFrame.Adjective != null) { foreach (ParseNode adj in _nounFrame.Adjective) { Text += (adj.Text + " "); } } Text += (_nounFrame.Text); _nounFrame.SearchText1 = Text; string _wordologyDirectoryPath = Application.ExecutablePath; int index = _wordologyDirectoryPath.LastIndexOf("\\"); _wordologyDirectoryPath = _wordologyDirectoryPath.Substring(0, index); if (IsGoogleImage()) { ///////////////// habal string strpath = ""; if (_nounFrame.Text == "agricultural".ToUpper()) { strpath = _wordologyDirectoryPath + @"\pics\agricultural.jpg"; } else if (_nounFrame.Text == "queen".ToUpper()) { strpath = _wordologyDirectoryPath + @"\pics\queen.jpg"; } else if (_nounFrame.Text == "shakespeare".ToUpper()) { strpath = _wordologyDirectoryPath + @"\pics\shakespeare.jpg"; } else if (_nounFrame.Text == "living".ToUpper()) { strpath = _wordologyDirectoryPath + @"\pics\coins.jpg"; } else if (_nounFrame.Text == "writer".ToUpper()) { strpath = _wordologyDirectoryPath + @"\pics\writer.jpg"; } //////////////////////////// if (strpath != "") { _bitmap = new Bitmap(strpath); } else { _bitmap = GoogleSearch.GetImage(_nounFrame.SearchText1); } ///////////////////////// _rectangle = new Rectangle(x, y, _bitmap.Width, _bitmap.Height); _position = new PointF(x + _bitmap.Width / 2, y + _bitmap.Height / 2); } }
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); }
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(); } }
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(); } }
public NounFrameEntity(int x, int y, NounFrame nounFrame, MindMapTMR tmr, NewGoogleSearch googleImSearch, DrawingSizeMode sizeMode, ConceptCmbination conceptCombination) : base(0, 0, 70, 40, "", "") { _tmr = tmr; _SizeMode = sizeMode; GoogleImSearch = googleImSearch; _conceptComb = conceptCombination; _nounFrame = nounFrame; string Text = ""; //if (_nounFrame.Adjective != null) //{ // foreach (ParseNode adj in _nounFrame.Adjective) // Text += (adj.Text + " "); //} if (_nounFrame.AdjectivesInfo != null) { foreach (MyWordInfo mwi in _nounFrame.AdjectivesInfo) { Text += (mwi.Word + " "); } } Text += (_nounFrame.Text); _conceptCombText = GetConceptCombinationText(); _nounFrame.SearchText1 = Text; //string _wordologyDirectoryPath = Application.ExecutablePath; //int index = _wordologyDirectoryPath.LastIndexOf("\\"); //_wordologyDirectoryPath = _wordologyDirectoryPath.Substring(0, index); if (IsGoogleImage()) { ///////////////// habal string strpath = ""; //if (_nounFrame.Text == "agricultural".ToUpper()) // strpath = _wordologyDirectoryPath+@"\pics\agricultural.jpg"; //else if (_nounFrame.Text == "queen".ToUpper()) // strpath = _wordologyDirectoryPath+@"\pics\queen.jpg"; //else if (_nounFrame.Text == "shakespeare".ToUpper()) // strpath =_wordologyDirectoryPath+@"\pics\shakespeare.jpg"; //else if (_nounFrame.Text == "living".ToUpper()) // strpath = _wordologyDirectoryPath+@"\pics\coins.jpg"; //else if (_nounFrame.Text == "writer".ToUpper()) // strpath = _wordologyDirectoryPath+@"\pics\writer.jpg"; //////////////////////////// if (strpath != "") { _bitmap = new Bitmap(strpath); } else { //_bitmap = GoogleSearch.GetImage(_nounFrame.SearchText1); IList <IImageResult> Results; if (sizeMode == DrawingSizeMode.Normal) { Results = GoogleImSearch.Search2(_nounFrame.SearchText1 + " " + _conceptCombText); } else { ImageSize imsize = GetAutoSize(); Results = GoogleImSearch.Search2(_nounFrame.SearchText1 + " " + _conceptCombText, imsize); } // if (Results.Count > 500000 && Results.Count < 15000000) double R; double.TryParse(_nounFrame.SearchText1, out R); if (Results.Count >= 1 && R == 0) { 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); } } ///////////////////////// //_rectangle = new Rectangle(x, y, _bitmap.Width, _bitmap.Height); //_position = new PointF(x + _bitmap.Width / 2, y + _bitmap.Height / 2); } }