void FrameView::update(bool modified) { if (m_updating) return; DocInfo *info = activeDocInfo(); if (info == NULL) return; FtmDocument *doc = info->doc(); m_updating = true; const int pxunit = font.pixelSize(); int chans = doc->GetAvailableChannels(); horizontalScrollBar()->setRange(0, doc->GetAvailableChannels()-1); verticalScrollBar()->setRange(0, doc->GetFrameCount()-1); horizontalScrollBar()->setValue(info->currentChannel()); verticalScrollBar()->setValue(info->currentFrame()); int w_compensation = size().width() - viewport()->size().width(); setFixedWidth(pxunit*2*(chans+1) + w_compensation); if (modified || (!gui::isPlaying()) || (!(m_currentFrame == info->currentFrame() && m_currentChannel == info->currentChannel()))) viewport()->update(); m_updating = false; }
void FrameView::scrollVertical(int i) { if (gui::isPlaying() || m_updating) return; DocInfo *dinfo = gui::activeDocInfo(); if (dinfo == NULL) return; dinfo->setCurrentFrame(i); m_updating = true; gui::updateFrameChannel(); m_updating = false; }
void FrameView::scrollHorizontal(int i) { if (m_updating) return; DocInfo *dinfo = gui::activeDocInfo(); if (dinfo == NULL) return; dinfo->setCurrentChannel(i); m_updating = true; gui::updateFrameChannel(); m_updating = false; }
void FrameView::mouseReleaseEvent(QMouseEvent *e) { DocInfo *dinfo = gui::activeDocInfo(); if (dinfo == NULL) return; QPoint p = viewport()->mapFromParent(e->pos()); unsigned int frame, chan; if (posToFrameChannel(p, frame, chan)) { if (!gui::isPlaying()) { dinfo->setCurrentFrame(frame); } dinfo->setCurrentChannel(chan); dinfo->setCurrentChannelColumn(0); gui::updateFrameChannel(); } }
int main(int argc, char *argv[]) { Index *ind; if (argc < 3) { cerr << "usage: dumpTerm <index_name> <internal/external termid> [-ext]" << endl; exit (1); } ind = IndexManager::openIndex(argv[1]); TERMID_T did; if (argc == 3) did = atoi(argv[2]); else did = ind->term(argv[2]); cout << ind->term(did) << endl; DocInfoList *tList = ind->docInfoList(did); if (tList == NULL) { cerr << ": empty docInfoList" << endl; exit (1); } DocInfo *info; tList->startIteration(); while (tList->hasMore()) { info = tList->nextEntry(); const LOC_T *pos = info->positions(); COUNT_T count = info->termCount(); cout << ind->document(info->docID()) << "(" << count << "): "; if (pos != NULL) { for (COUNT_T i = 0; i < count; i++) cout << pos[i] << " "; } cout << endl; } delete tList; delete(ind); return 0; }
DocInfo HTMLParser::parse(RICPNS::Document &document) { oneurl curl; string html; cleanText(document.getText(), html); GumboOutput* output = gumbo_parse(html.c_str()); GumboNode* node = output->root; string docUrl = document.getURL(); string content, pageTitle; list<pair<string, string> > links; // thread t1(&HTMLParser::extractContent, this, node, ref(content)); // thread t2(&HTMLParser::extractPageTitle, this, node, ref(pageTitle)); // thread t3(&HTMLParser::extractLinks, this, node, ref(links), ref(docUrl)); extractContent(node, content); extractPageTitle(node, pageTitle); extractLinks(node, links, docUrl); // t1.join(); // t2.join(); // t3.join(); gumbo_destroy_output(&kGumboDefaultOptions, output); DocInfo docInfo; docInfo.setContent(content); docInfo.setCanonicalUrl( curl.Parse(docUrl) ? curl.CNormalize(docUrl) : docUrl); docInfo.setUrl(docUrl); docInfo.setTitle(pageTitle); docInfo.setLinks(links); // cout << docInfo.getUrl() << " - "<< " " << link << endl; // static int i=1; // cout << i++ << " - " << docInfo.getCanonicalUrl() << endl; // // // for(pair<string, string> link : links){ // cout << " ------- " << link.first << endl; // cout << link.second << endl; // } return docInfo; }
void Retrieval(double *qryArr, IndexedRealVector &results, Index *ind){ //retrieve documents with respect to the array representation of the query lemur::retrieval::ArrayAccumulator scoreAccumulator(ind->docCount()); scoreAccumulator.reset(); for (int t=1; t<=ind->termCountUnique();t++) { if (qryArr[t]>0) { // fetch inverted entries for a specific query term DocInfoList *docList = ind->docInfoList(t); // iterate over all individual documents docList->startIteration(); while (docList->hasMore()) { DocInfo *matchInfo = docList->nextEntry(); // for each matched term, calculated the evidence double wt; if (strcmp(LocalParameter::weightScheme.c_str(),"RawTF")==0) { wt = computeRawTFWeight(matchInfo->docID(), // doc ID t, // term ID matchInfo->termCount(), // freq of term t in this doc qryArr[t], // freq of term t in the query ind); }else if (strcmp(LocalParameter::weightScheme.c_str(),"RawTFIDF")==0) { wt = computeRawTFIDFWeight(matchInfo->docID(), // doc ID t, // term ID matchInfo->termCount(), // freq of term t in this doc qryArr[t], // freq of term t in the query ind); }else if (strcmp(LocalParameter::weightScheme.c_str(),"LogTFIDF")==0) { wt = computeLogTFIDFWeight(matchInfo->docID(), // doc ID t, // term ID matchInfo->termCount(), // freq of term t in this doc qryArr[t], // freq of term t in the query ind); }else if (strcmp(LocalParameter::weightScheme.c_str(),"Okapi")==0) { wt = computeOkapiWeight(matchInfo->docID(), // doc ID t, // term ID matchInfo->termCount(), // freq of term t in this doc qryArr[t], // freq of term t in the query ind); }else if (strcmp(LocalParameter::weightScheme.c_str(),"Custom")==0){ wt = computeCustomWeight(matchInfo->docID(), // doc ID t, // term ID matchInfo->termCount(), // freq of term t in this doc qryArr[t], // freq of term t in the query ind); }else{ cerr<<"The weighting scheme of "<<LocalParameter::weightScheme.c_str()<<" is not supported"<<endl; exit(1); } scoreAccumulator.incScore(matchInfo->docID(),wt); } delete docList; } } // Adjust the scores for the documents when it is necessary double s; int d; for (d=1; d<=ind->docCount(); d++) { if (scoreAccumulator.findScore(d,s)) { } else { s=0; } if (strcmp(LocalParameter::weightScheme.c_str(),"RawTF")==0) { results.PushValue(d, computeAdjustedScore(s, // the score from the accumulator d, // doc ID ind)); // index }else if (strcmp(LocalParameter::weightScheme.c_str(),"RawTFIDF")==0) { results.PushValue(d, computeAdjustedScore(s, // the score from the accumulator d, // doc ID ind)); // index }else if (strcmp(LocalParameter::weightScheme.c_str(),"LogTFIDF")==0) { results.PushValue(d, computeAdjustedScore(s, // the score from the accumulator d, // doc ID ind)); // index }else if (strcmp(LocalParameter::weightScheme.c_str(),"Okapi")==0) { results.PushValue(d, computeAdjustedScore(s, // the score from the accumulator d, // doc ID ind)); // index }else if (strcmp(LocalParameter::weightScheme.c_str(),"Custom")==0){ results.PushValue(d, computeCustomAdjustedScore(s, // the score from the accumulator d, // doc ID ind)); // index }else{ cerr<<"The weighting scheme of "<<LocalParameter::weightScheme.c_str()<<" is not supported"<<endl; exit(1); } } }
bool WebExtensionContentScript::Matches(const DocInfo& aDoc) const { if (!mFrameID.IsNull()) { if (aDoc.FrameID() != mFrameID.Value()) { return false; } } else { if (!mAllFrames && !aDoc.IsTopLevel()) { return false; } } if (!mMatchAboutBlank && aDoc.URL().InheritsPrincipal()) { return false; } // Top-level about:blank is a special case. We treat it as a match if // matchAboutBlank is true and it has the null principal. In all other // cases, we test the URL of the principal that it inherits. if (mMatchAboutBlank && aDoc.IsTopLevel() && aDoc.URL().Spec().EqualsLiteral("about:blank") && aDoc.Principal() && aDoc.Principal()->GetIsNullPrincipal()) { return true; } // With the exception of top-level about:blank documents with null // principals, we never match documents that have non-codebase principals, // including those with null principals or system principals. if (aDoc.Principal() && !aDoc.Principal()->GetIsCodebasePrincipal()) { return false; } // Content scripts are not allowed on pages that have elevated // privileges via mozAddonManager (see bug 1280234) if (AddonManagerWebAPI::IsValidSite(aDoc.PrincipalURL().URI())) { return false; } if (mHasActiveTabPermission && aDoc.ShouldMatchActiveTabPermission()) { return true; } return MatchesURI(aDoc.PrincipalURL()); }