Process web annotations.
175129
@Override
    public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        // Commented for http://code.google.com/p/sipservlets/issues/detail?id=168
    	// When no sip.xml but annotations only, Application is not recognized as SIP App by AS7
//        SipMetaData sipMetaData = deploymentUnit.getAttachment(SipMetaData.ATTACHMENT_KEY);
//        if (sipMetaData == null) {
//            return;
//        }
        SipAnnotationMetaData sipAnnotationsMetaData = deploymentUnit.getAttachment(SipAnnotationMetaData.ATTACHMENT_KEY);
        if (sipAnnotationsMetaData == null) {
            sipAnnotationsMetaData = new SipAnnotationMetaData();
            deploymentUnit.putAttachment(SipAnnotationMetaData.ATTACHMENT_KEY, sipAnnotationsMetaData);
        }
        Map<ResourceRoot, Index> indexes = AnnotationIndexUtils.getAnnotationIndexes(deploymentUnit);

        // Process components
        for (final Entry<ResourceRoot, Index> entry : indexes.entrySet()) {
            if (logger.isDebugEnabled()) logger.debug("doDeploy(): processing annotations from " + entry.getKey().getRootName());
            final Index jarIndex = entry.getValue();
            SipMetaData sipMetaData = processAnnotations(sipAnnotationsMetaData, jarIndex);
            if(sipMetaData != null) {
            	// https://github.com/Mobicents/sip-servlets/issues/68 Adding only the ones that actually have annotations 
            	// to save memory and computing time later on
            	sipAnnotationsMetaData.put(entry.getKey().getRootName(), sipMetaData);
            }
        }
    }
1337743
def handle_annotation_list(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
        
        annotation = tokens['name']
        self.raise_for_redefined_annotation(line, position, annotation)
        self.annotation_to_local[annotation] = set(tokens['values'])
        return tokens
1030277
public static function gather() {
		
		// set-up default var
		$annotationsDir = Config::getOption("annotationsDir");
		
		// set-up the dispatcher
		$dispatcherInstance = Dispatcher::getInstance();
		
		// dispatch that the data gather has started
		$dispatcherInstance->dispatch("annotations.gatherStart");
		
		// set-up the comments store
		self::$store["comments"] = array();
		
		// create the annotations dir if it doesn't exist
		if (!is_dir($annotationsDir)) {
			mkdir($annotationsDir);
		}
		
		// find the markdown-based annotations
		$finder = new Finder();
		$finder->files()->name("*.md")->in($annotationsDir);
		$finder->sortByName();
		
		foreach ($finder as $name => $file) {
				
			$data    = array();
			$data[0] = array();
			
			$text = file_get_contents($file->getPathname());
			
			$matches = (strpos($text,PHP_EOL."~*~".PHP_EOL) !== false) ? explode(PHP_EOL."~*~".PHP_EOL,$text) : array($text);
			
			foreach ($matches as $match) {
				
				list($yaml,$markdown) = Documentation::parse($match);
				
				if (isset($yaml["el"]) || isset($yaml["selector"])) {
					$data[0]["el"]  = (isset($yaml["el"])) ? $yaml["el"] : $yaml["selector"];
				} else {
					$data[0]["el"]  = "#someimpossibleselector";
				}
				$data[0]["title"]   = isset($yaml["title"]) ? $yaml["title"] : "";
				$data[0]["comment"] = $markdown;
				
				self::$store["comments"] = array_merge(self::$store["comments"],$data);
				
			}
			
		}
		
		// read in the old style annotations.js, modify the data and generate JSON array to merge
		$data = array();
		$oldStyleAnnotationsPath = $annotationsDir.DIRECTORY_SEPARATOR."annotations.js";
		if (file_exists($oldStyleAnnotationsPath)) {
			$text = trim(file_get_contents($oldStyleAnnotationsPath));
			$text = str_replace("var comments = ","",$text);
			if ($text[strlen($text)-1] == ";") {
				$text = rtrim($text,";");
			}
			$data = json_decode($text,true);
			if ($jsonErrorMessage = JSON::hasError()) {
				JSON::lastErrorMsg(Console::getHumanReadablePath($oldStyleAnnotationsPath),$jsonErrorMessage,$data);
			}
		}
		
		// merge in any data from the old file if the json decode was successful
		if (is_array($data) && isset($data["comments"])) {
			self::$store["comments"] = array_merge(self::$store["comments"],$data["comments"]);
		}
		
		$dispatcherInstance->dispatch("annotations.gatherEnd");
		
	}
1270843
protected function scanAnnotations()
    {
        $scans = $this->classesToScan();

        if (empty($scans)) {
            return;
        }

        $scanner = $this->getAnnotationScanner();

        $scanner->setClassesToScan($scans);

        $scanner->scan();
    }
504615
def process_response(self, request, response, spider):
        """"""
        return response.replace(body=str(BeautifulSoup(response.body, self.parser)))
551038
def process(source, target, rdfsonly, base=None, logger=logging):
    '''
    

    '''
    for link in source.match():
        s, p, o = link[:3]
        #SKip docheader statements
        if s == (base or '') + '@docheader': continue
        if p in RESOURCE_MAPPING: p = RESOURCE_MAPPING[p]
        if o in RESOURCE_MAPPING: o = RESOURCE_MAPPING[o]
        if p == VERSA_BASEIRI + 'refines':
            tlinks = list(source.match(s, TYPE_REL))
            if tlinks:
                if tlinks[0][TARGET] == VERSA_BASEIRI + 'Resource':
                    p = I(RDFS_NAMESPACE + 'subClassOf')
                elif tlinks[0][TARGET] == VERSA_BASEIRI + 'Property':
                    p = I(RDFS_NAMESPACE + 'subPropertyOf')
        if p == VERSA_BASEIRI + 'properties':
            suri = I(iri.absolutize(s, base)) if base else s
            target.add((URIRef(o), URIRef(RDFS_NAMESPACE + 'domain'), URIRef(suri)))
            continue
        if p == VERSA_BASEIRI + 'value':
            if o not in ['Literal', 'IRI']:
                ouri = I(iri.absolutize(o, base)) if base else o
                target.add((URIRef(s), URIRef(RDFS_NAMESPACE + 'range'), URIRef(ouri)))
                continue
        s = URIRef(s)
        #Translate v:type to rdf:type
        p = RDF.type if p == TYPE_REL else URIRef(p)
        o = URIRef(o) if isinstance(o, I) else Literal(o)
        if not rdfsonly or p.startswith(RDF_NAMESPACE) or p.startswith(RDFS_NAMESPACE):
            target.add((s, p, o))
    return
507682
private function processHtml()
    {
        $this->tree->build_tree();

        $this->css->load_css_file(Stylesheet::getDefaultStylesheet(), Stylesheet::ORIG_UA);

        $acceptedmedia = Stylesheet::$ACCEPTED_GENERIC_MEDIA_TYPES;
        $acceptedmedia[] = $this->options->getDefaultMediaType();

        // <base href="" />
        $base_nodes = $this->dom->getElementsByTagName("base");
        if ($base_nodes->length && ($href = $base_nodes->item(0)->getAttribute("href"))) {
            list($this->protocol, $this->baseHost, $this->basePath) = Helpers::explode_url($href);
        }

        // Set the base path of the Stylesheet to that of the file being processed
        $this->css->set_protocol($this->protocol);
        $this->css->set_host($this->baseHost);
        $this->css->set_base_path($this->basePath);

        // Get all the stylesheets so that they are processed in document order
        $xpath = new DOMXPath($this->dom);
        $stylesheets = $xpath->query("//*[name() = 'link' or name() = 'style']");

        /** @var \DOMElement $tag */
        foreach ($stylesheets as $tag) {
            switch (strtolower($tag->nodeName)) {
                // load <link rel="STYLESHEET" ... /> tags
                case "link":
                    if (mb_strtolower(stripos($tag->getAttribute("rel"), "stylesheet") !== false) || // may be "appendix stylesheet"
                        mb_strtolower($tag->getAttribute("type")) === "text/css"
                    ) {
                        //Check if the css file is for an accepted media type
                        //media not given then always valid
                        $formedialist = preg_split("/[\s\n,]/", $tag->getAttribute("media"), -1, PREG_SPLIT_NO_EMPTY);
                        if (count($formedialist) > 0) {
                            $accept = false;
                            foreach ($formedialist as $type) {
                                if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
                                    $accept = true;
                                    break;
                                }
                            }

                            if (!$accept) {
                                //found at least one mediatype, but none of the accepted ones
                                //Skip this css file.
                                break;
                            }
                        }

                        $url = $tag->getAttribute("href");
                        $url = Helpers::build_url($this->protocol, $this->baseHost, $this->basePath, $url);

                        $this->css->load_css_file($url, Stylesheet::ORIG_AUTHOR);
                    }
                    break;

                // load <style> tags
                case "style":
                    // Accept all <style> tags by default (note this is contrary to W3C
                    // HTML 4.0 spec:
                    // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media
                    // which states that the default media type is 'screen'
                    if ($tag->hasAttributes() &&
                        ($media = $tag->getAttribute("media")) &&
                        !in_array($media, $acceptedmedia)
                    ) {
                        break;
                    }

                    $css = "";
                    if ($tag->hasChildNodes()) {
                        $child = $tag->firstChild;
                        while ($child) {
                            $css .= $child->nodeValue; // Handle <style><!-- blah --></style>
                            $child = $child->nextSibling;
                        }
                    } else {
                        $css = $tag->nodeValue;
                    }

                    $this->css->load_css($css, Stylesheet::ORIG_AUTHOR);
                    break;
            }
        }
    }
941693
def run_parser_plugins(self, url_data, pagetype):
        """"""
        run_plugins(self.parser_plugins, url_data, stop_after_match=True, pagetype=pagetype)
633378
def process(self):
        """"""
        var_name = self.name_edt.text()
        try:
            self.var_name = str(var_name)
        except UnicodeEncodeError:
            self.var_name = to_text_string(var_name)
        if self.text_widget.get_as_data():
            self.clip_data = self._get_table_data()
        elif self.text_widget.get_as_code():
            self.clip_data = try_to_eval(
                to_text_string(self._get_plain_text()))
        else:
            self.clip_data = to_text_string(self._get_plain_text())
        self.accept()
1313209
private void processRevisions()
	{
		logger.info("Processing revisions, extracting template information ...");
		RevisionIterator revisionIter=null;
		try{
			revisionIter = new RevisionIterator(dbConf);

			int revCounter = 0;
			while (revisionIter.hasNext()) {
				revCounter++;

				if (revCounter % VERBOSITY == 0) {
					logger.info("{} revisions processed ...", revCounter);
				}

				Revision curRevision = revisionIter.next();
				int curRevisionId = curRevision.getRevisionID();

				fillMapWithTemplateData(curRevision.getRevisionText(),
						revisionFilter, curRevisionId, TPLNAME_TO_REVISIONIDS);
			}
		}catch(WikiApiException e){
			logger.error("Error initializing Revision Iterator", e);
		}finally{
			if(revisionIter!=null){
				try{
					revisionIter.close();
				}catch(SQLException e){
					logger.error("Error closing RevisionIterator", e);
				}
			}
		}
	}
602828
public void process() {
        processOverview();
        for ( ClassDoc doc : rootDoc.classes() ) {
            packages.add(doc.containingPackage());
            processClass(doc);
        }
        for ( PackageDoc doc : packages ) {
            processPackage(doc);
        }
    }
1055322
def process_data(self, text, colsep=u"\t", rowsep=u"\n",
                     transpose=False, skiprows=0, comments='#'):
        """"""
        data = self._shape_text(text, colsep, rowsep, transpose, skiprows,
                                comments)
        self._model = PreviewTableModel(data)
        self.setModel(self._model)
1373401
public function loadAnnotated()
    {
        if ($this->app->environment('local') && $this->scanWhenLocal) {
            $this->scanAnnotations();
        }

        $scans = $this->classesToScan();

        if (! empty($scans) && $this->getAnnotationScanner()->annotationsAreScanned()) {
            $this->getAnnotationScanner()->loadScannedAnnotations();
        }
    }
1249747
private void process() {
    Entity entity = entityClass.getAnnotation(Entity.class);
    ProjectedEntity projectedEntity = entityClass.getAnnotation(ProjectedEntity.class);
    if (entity != null) {
      initEntityMetadata(entity);
    } else if (projectedEntity != null) {
      initEntityMetadata(projectedEntity);
    } else {
      String message = String.format("Class %s must either have %s or %s annotation",
          entityClass.getName(), Entity.class.getName(), ProjectedEntity.class.getName());
      throw new EntityManagerException(message);
    }

    processPropertyOverrides();

    processFields();
    // If we did not find valid Identifier...
    if (entityMetadata.getIdentifierMetadata() == null) {
      throw new EntityManagerException(
          String.format("Class %s requires a field with annotation of %s", entityClass.getName(),
              Identifier.class.getName()));
    }
    entityMetadata.setEntityListenersMetadata(EntityListenersIntrospector.introspect(entityClass));
    entityMetadata.ensureUniqueProperties();
    entityMetadata.cleanup();
  }
872858
def Main(url):
    '''
    
    '''
    # The object of Web-scraping.
    web_scrape = WebScraping()
    # Set the object of reading PDF files.
    web_scrape.readable_web_pdf = WebPDFReading()
    # Execute Web-scraping.
    document = web_scrape.scrape(url)
    # The object of automatic sumamrization.
    auto_abstractor = AutoAbstractor()
    # Set tokenizer. This is japanese tokenizer with MeCab.
    auto_abstractor.tokenizable_doc = MeCabTokenizer()
    # Object of abstracting and filtering document.
    abstractable_doc = TopNRankAbstractor()
    # Execute summarization.
    result_dict = auto_abstractor.summarize(document, abstractable_doc)
    # Output summarized sentence.
    [print(sentence) for sentence in result_dict["summarize_result"]]
895089
def p_annotation(self, p):
        """"""
        if len(p) < 8:
            args, kwargs = p[5]
            p[0] = AstAnnotationDef(
                self.path, p.lineno(1), p.lexpos(1), p[2], p[4], None, args, kwargs)
        else:
            args, kwargs = p[7]
            p[0] = AstAnnotationDef(
                self.path, p.lineno(1), p.lexpos(1), p[2], p[6], p[4], args, kwargs)
360957
private Map<String, Set<String>> scanForAnnotatedClasses(Set<URL> urls) throws IOException {
        AnnotationDB db = new AnnotationDB();
        db.setScanClassAnnotations(true);
        db.setScanFieldAnnotations(false);
        db.setScanMethodAnnotations(false);
        db.setScanParameterAnnotations(false);
      
        db.scanArchives(urls.toArray(new URL[urls.size()]));
        return db.getAnnotationIndex();
        
    }