void SequenceFeatures::AddUnigramFeatures(SequenceInstanceNumeric *sentence, int position) { CHECK(!input_features_unigrams_[position]); BinaryFeatures *features = new BinaryFeatures; input_features_unigrams_[position] = features; int sentence_length = sentence->size(); // Array of form IDs. const vector<int>* word_ids = &sentence->GetFormIds(); // Words. uint16_t WID = (*word_ids)[position]; // Current word. // Word on the left. uint16_t pWID = (position > 0)? (*word_ids)[position - 1] : TOKEN_START; // Word on the right. uint16_t nWID = (position < sentence_length - 1)? (*word_ids)[position + 1] : TOKEN_STOP; // Word two positions on the left. uint16_t ppWID = (position > 1)? (*word_ids)[position - 2] : TOKEN_START; // Word two positions on the right. uint16_t nnWID = (position < sentence_length - 2)? (*word_ids)[position + 2] : TOKEN_STOP; // Prefixes/Suffixes. vector<uint16_t> AID(sentence->GetMaxPrefixLength(position), 0xffff); vector<uint16_t> ZID(sentence->GetMaxSuffixLength(position), 0xffff); for (int l = 0; l < AID.size(); ++l) { AID[l] = sentence->GetPrefixId(position, l+1); } for (int l = 0; l < ZID.size(); ++l) { ZID[l] = sentence->GetSuffixId(position, l+1); } // Several flags. uint8_t flag_digit = sentence->HasDigit(position)? 0x1 : 0x0; uint8_t flag_upper = position > 0 && sentence->HasUpper(position)? 0x1 : 0x0; uint8_t flag_hyphen = sentence->HasHyphen(position)? 0x1 : 0x0; flag_digit = 0x0 | (flag_digit << 4); flag_upper = 0x1 | (flag_upper << 4); flag_hyphen = 0x2 | (flag_hyphen << 4); uint64_t fkey; uint8_t flags = 0x0; flags |= SequenceFeatureTemplateParts::UNIGRAM; // Maximum is 255 feature templates. CHECK_LT(SequenceFeatureTemplateUnigram::COUNT, 256); // Bias feature. fkey = encoder_.CreateFKey_NONE(SequenceFeatureTemplateUnigram::BIAS, flags); AddFeature(fkey, features); // Lexical features. fkey = encoder_.CreateFKey_W(SequenceFeatureTemplateUnigram::W, flags, WID); AddFeature(fkey, features); fkey = encoder_.CreateFKey_W(SequenceFeatureTemplateUnigram::pW, flags, pWID); AddFeature(fkey, features); fkey = encoder_.CreateFKey_W(SequenceFeatureTemplateUnigram::nW, flags, nWID); AddFeature(fkey, features); fkey = encoder_.CreateFKey_W(SequenceFeatureTemplateUnigram::ppW, flags, ppWID); AddFeature(fkey, features); fkey = encoder_.CreateFKey_W(SequenceFeatureTemplateUnigram::nnW, flags, nnWID); AddFeature(fkey, features); // Prefix/Suffix features. for (int l = 0; l < AID.size(); ++l) { uint8_t flag_prefix_length = l; fkey = encoder_.CreateFKey_WP(SequenceFeatureTemplateUnigram::A, flags, AID[l], flag_prefix_length); AddFeature(fkey, features); } for (int l = 0; l < ZID.size(); ++l) { uint8_t flag_suffix_length = l; fkey = encoder_.CreateFKey_WP(SequenceFeatureTemplateUnigram::Z, flags, ZID[l], flag_suffix_length); AddFeature(fkey, features); } // Several flags. fkey = encoder_.CreateFKey_P(SequenceFeatureTemplateUnigram::FLAG, flags, flag_digit); AddFeature(fkey, features); fkey = encoder_.CreateFKey_P(SequenceFeatureTemplateUnigram::FLAG, flags, flag_upper); AddFeature(fkey, features); fkey = encoder_.CreateFKey_P(SequenceFeatureTemplateUnigram::FLAG, flags, flag_hyphen); AddFeature(fkey, features); }
void CTagVwSplit::OnMove(int x, int y) { CMDIChildWnd::OnMove(x, y); WINDOWPLACEMENT wp; wp.length = sizeof(wp); GetWindowPlacement(&wp); int DX=wp.rcNormalPosition.left-m_PrevClientX; int DY=wp.rcNormalPosition.top-m_PrevClientY; if (m_CreateDone && (gs_pPrj->m_TrndBehaviour || gs_FileNewFlag) && gs_ProjectOpenFlag && gs_BlockSizeAdjustment==0) { CAutoIncDec AID(gs_BlockSizeAdjustment); CWindowLists WL; if (WL.BuildSingleList()<0) return; if (gs_FileNewFlag) { CWnd * pTopWnd=NULL; int Z=10000; WL.BuildZOrder(true); for (int i=0; i<WL.Wnds.GetCount(); i++) { CTopWindowInfo & WI=WL.Wnds[i]; CWnd * pWnd=WI.pWnd; if (pWnd->IsKindOf(RUNTIME_CLASS(CTagVwSplit)) && pWnd!=this) { if (WI.iZOrd<Z) { Z=WI.iZOrd; pTopWnd=WI.pWnd; } } } if (pTopWnd) { wp.length = sizeof(wp); pTopWnd->GetWindowPlacement(&wp); wp.length = sizeof(wp); SetWindowPlacement(&wp); } } else { //WINDOWPLACEMENT wp; wp.length = sizeof(wp); GetWindowPlacement(&wp); int W=wp.rcNormalPosition.right-wp.rcNormalPosition.left; int H=wp.rcNormalPosition.bottom-wp.rcNormalPosition.top; for (int i=0; i<WL.TrndWnds.GetCount(); i++) { if (WL.TrndWnds[i]!=this) { WINDOWPLACEMENT wpt; wpt.length = sizeof(wpt); WL.TrndWnds[i]->GetWindowPlacement(&wpt); if (gs_pPrj->m_TrndBehaviour & WB_Coincident) { wpt.rcNormalPosition=wp.rcNormalPosition; } else if (gs_pPrj->m_TrndBehaviour & WB_MoveTogether) { wpt.rcNormalPosition.left+=DX; wpt.rcNormalPosition.right+=DX; wpt.rcNormalPosition.top+=DY; wpt.rcNormalPosition.bottom+=DY; } wpt.length = sizeof(wpt); WL.TrndWnds[i]->SetWindowPlacement(&wpt); } } } } wp.length = sizeof(wp); GetWindowPlacement(&wp); m_PrevClientX=wp.rcNormalPosition.left; m_PrevClientY=wp.rcNormalPosition.top; }
void CTagVwSplit::DoBehaviourChange() { if (gs_pPrj->m_TrndBehaviour && gs_ProjectOpenFlag && gs_BlockSizeAdjustment==0) { CAutoIncDec AID(gs_BlockSizeAdjustment); WINDOWPLACEMENT wp; wp.length = sizeof(wp); if (gs_FileNewFlag) { CWindowLists WL; CWnd * pTopWnd=NULL; CWnd * pTopWndBut1=NULL; int Z=10000; WL.BuildZOrder(true); for (int i=0; i<WL.Wnds.GetCount(); i++) { CTopWindowInfo & WI=WL.Wnds[i]; CWnd * pWnd=WI.pWnd; if (pWnd->IsKindOf(RUNTIME_CLASS(CTagVwSplit)))// && pWnd!=this) { if (WI.iZOrd<Z) { Z=WI.iZOrd; pTopWndBut1=pTopWnd; pTopWnd=WI.pWnd; } } } if (pTopWndBut1) { wp.length = sizeof(wp); pTopWndBut1->GetWindowPlacement(&wp); wp.length = sizeof(wp); pTopWnd->SetWindowPlacement(&wp); } } else { CWindowLists WL; if (WL.BuildZOrder()<0) return; if (WL.TrndWnds.GetCount()<1) return; WINDOWPLACEMENT wp; wp.length = sizeof(wp); int iTop=-1; int iZ=10000; for (int i=0; i<WL.Wnds.GetCount(); i++) { if (WL.Wnds[i].pWnd->IsKindOf(RUNTIME_CLASS(CTagVwSplit)) && WL.Wnds[i].iZOrd<iZ) { iTop=i; iZ=WL.Wnds[i].iZOrd; } } if (iTop>=0) { WL.Wnds[iTop].pWnd->GetWindowPlacement(&wp); for (int i=0; i<WL.TrndWnds.GetCount(); i++) { WINDOWPLACEMENT wpt; wpt.length = sizeof(wpt); WL.TrndWnds[i]->GetWindowPlacement(&wpt); if (gs_pPrj->m_TrndBehaviour & WB_Coincident) { wpt.rcNormalPosition=wp.rcNormalPosition; } else if (gs_pPrj->m_TrndBehaviour & WB_MoveTogether) { _asm int 3; //wpt.rcNormalPosition.left+=DX; //wpt.rcNormalPosition.right+=DX; //wpt.rcNormalPosition.top+=DY; //wpt.rcNormalPosition.bottom+=DY; } wpt.length = sizeof(wpt); WL.TrndWnds[i]->SetWindowPlacement(&wpt); } }
void CTagVwSplit::OnSize(UINT nType, int cx, int cy) { CMDIChildWnd::OnSize(nType, cx, cy); if (nType==SIZE_MAXIMIZED) CWindowLists::SetWndMaxMode(TRUE); else if (nType==SIZE_MINIMIZED || nType==SIZE_RESTORED) CWindowLists::SetWndMaxMode(FALSE); if (m_CreateDone && gs_pPrj->m_TrndBehaviour && gs_ProjectOpenFlag && gs_BlockSizeAdjustment==0) { CAutoIncDec AID(gs_BlockSizeAdjustment); CWindowLists WL; if (WL.BuildSingleList()<0) return; if (gs_FileNewFlag) { if (WL.TrndWnds.GetCount()==1) // First { CRect IRect; CWnd * p=ScdMainWnd(); if (dynamic_cast<CMainFrame*>(p)->GetInitRect(2, IRect)) { WINDOWPLACEMENT wp; wp.length = sizeof(wp); GetWindowPlacement(&wp); wp.rcNormalPosition=IRect; SetWindowPlacement(&wp); } //WINDOWPLACEMENT wp; //wp.length = sizeof(wp); //GetWindowPlacement(&wp); //int W=wp.rcNormalPosition.right-wp.rcNormalPosition.left; //int H=wp.rcNormalPosition.bottom-wp.rcNormalPosition.top; //W=700; //H=450; //wp.rcNormalPosition.right=wp.rcNormalPosition.left+W; //wp.rcNormalPosition.bottom=wp.rcNormalPosition.top+H; //SetWindowPlacement(&wp); } } else { WINDOWPLACEMENT wp; wp.length = sizeof(wp); GetWindowPlacement(&wp); int W=wp.rcNormalPosition.right-wp.rcNormalPosition.left; int H=wp.rcNormalPosition.bottom-wp.rcNormalPosition.top; for (int i=0; i<WL.TrndWnds.GetCount(); i++) { if (WL.TrndWnds[i]!=this) { WINDOWPLACEMENT wpt; wpt.length = sizeof(wpt); WL.TrndWnds[i]->GetWindowPlacement(&wpt); if (gs_pPrj->m_TrndBehaviour & WB_Coincident) { wpt.rcNormalPosition=wp.rcNormalPosition; } else if (gs_pPrj->m_TrndBehaviour & WB_SizeTogether) { wpt.rcNormalPosition.right=wpt.rcNormalPosition.left+W; wpt.rcNormalPosition.bottom=wpt.rcNormalPosition.top+H; } wpt.length = sizeof(wpt); WL.TrndWnds[i]->SetWindowPlacement(&wpt); } } } } }