Extract mentions from an entity with ``raw_content``.

        :return: set
173838
def extract_mentions(self):
        
        if not hasattr(self, "raw_content"):
            return set()
        mentions = re.findall(r'@{[^;]+; [\w.-]+@[^}]+}', self.raw_content)
        if not mentions:
            return set()
        mentions = {s.split(';')[1].strip(' }') for s in mentions}
        mentions = {s for s in mentions}
        return mentions
220603
def get_corpus(filename: str) -> frozenset:
    
    lines = []
    with open(os.path.join(corpus_path(), filename), "r", encoding="utf-8-sig") as fh:
        lines = fh.read().splitlines()

    return frozenset(lines)
506307
def fetch_and_parse_article_list(list, extraction_fields = nil)
      # list should be an array of objects of format {pmid: pmid, article: RayyanFormats::Target}
      @hercules_articles.fight(list) do |article|
        fetch_and_parse_detail_page(article.sid, article, extraction_fields) do |article|
          yield article if block_given?
        end
      end
    end
642623
def parse_docstring(entity):
    
    doc = inspect.getdoc(entity)
    if not doc:
        return None, None
    doc = doc.splitlines(keepends=True)
    if not doc[0].strip():
        doc.pop(0)
    title = (doc and doc.pop(0).strip()) or None
    if doc and not doc[0].strip():
        doc.pop(0)
    desc = ''.join(doc).rstrip() or None
    return title, desc
1369606
def preprocess(s):
    
    # s = re.sub('@\S+', 'thisisamention', s)  # map all mentions to thisisamention
    s = re.sub(r'@\S+', ' ', s)  # map all mentions to thisisamention
    # s = re.sub('http\S+', 'http', s)  # keep only http from urls
    s = re.sub(r'http\S+', ' ', s)  # keep only http from urls
    s = re.sub(r'#(\S+)', r'hashtag\1 hashtag\1', s)  # #foo -> hashtagfoo hashtagfoo (for retaining hashtags even using bigrams)
    # s = re.sub(r'[0-9]+', '9', s)  # 1234 -> 9
    s = re.sub(r'\bRT\b', ' ', s, re.IGNORECASE)
    s = re.sub(r'&[a-z]+;', ' ', s, re.IGNORECASE)
    s = re.sub(r'\s+', ' ', s).strip()
    return s.lower()
283407
private Mention getMention(int tokenIndex)
    {
        Mention mention = null;
        for (Mention mention2 : mentions)
        {
            if (mention2.contains(tokenIndex))
                if (mention == null)
                    mention = mention2;
                else
                    throw new IllegalArgumentException();
        }
        return mention;
    }
265582
def apply(self, doc, clear, **kwargs):
        

        # Reattach doc with the current session or DetachedInstanceError happens
        doc = self.session.merge(doc)
        # Iterate over each mention class
        for i, mention_class in enumerate(self.mention_classes):
            tc_to_insert = defaultdict(list)
            # Generate TemporaryContexts that are children of the context using
            # the mention_space and filtered by the Matcher
            self.child_context_set.clear()
            for tc in self.matchers[i].apply(self.mention_spaces[i].apply(doc)):
                rec = tc._load_id_or_insert(self.session)
                if rec:
                    tc_to_insert[tc._get_table()].append(rec)
                self.child_context_set.add(tc)

            # Bulk insert temporary contexts
            for table, records in tc_to_insert.items():
                stmt = insert(table.__table__).values(records)
                self.session.execute(stmt)

            # Generates and persists mentions
            mention_args = {"document_id": doc.id}
            for child_context in self.child_context_set:
                # Assemble mention arguments
                for arg_name in mention_class.__argnames__:
                    mention_args[arg_name + "_id"] = child_context.id

                # Checking for existence
                if not clear:
                    q = select([mention_class.id])
                    for key, value in list(mention_args.items()):
                        q = q.where(getattr(mention_class, key) == value)
                    mention_id = self.session.execute(q).first()
                    if mention_id is not None:
                        continue

                # Add Mention to session
                yield mention_class(**mention_args)
1160559
def content(self, content):
        
        allowed_values = ["UNRELEASED", "EARLYACCESS", "SUPPORTED", "EXTENDED_SUPPORT", "EOL"]
        if not set(content).issubset(set(allowed_values)):
            raise ValueError(
                "Invalid values for `content` [{0}], must be a subset of [{1}]"
                .format(", ".join(map(str, set(content)-set(allowed_values))),
                        ", ".join(map(str, allowed_values)))
            )

        self._content = content
959487
def scrape_links(self, text, context=False):
        ''''''
        return self.iter_processed_links(io.StringIO(text), context=context)
204421
def raw_role_mentions(self):
        
        return [int(x) for x in re.findall(r'<@&([0-9]+)>', self.content)]
347076
def _get_entities(self, text, language=''):
    
    body = {
        'document': {
            'type': 'PLAIN_TEXT',
            'content': text,
        },
        'encodingType': 'UTF32',
    }
    if language:
      body['document']['language'] = language

    request = self.service.documents().analyzeEntities(body=body)
    response = request.execute()
    result = []
    for entity in response.get('entities', []):
      mentions = entity.get('mentions', [])
      if not mentions:
        continue
      entity_text = mentions[0]['text']
      offset = entity_text['beginOffset']
      for word in entity_text['content'].split():
        result.append({'content': word, 'beginOffset': offset})
        offset += len(word)
    return result
1343196
def get_ancestor_id_names(mention):
    
    span = _to_span(mention)
    id_names = []
    i = _get_node(span.sentence)
    while i is not None:
        id_names.insert(0, str(i.get("id")))
        i = i.getparent()
    return id_names
1294019
def _extract(self):
        
        self.log.debug("Extracting emails from text content")
        for item in self.data:
            emails = extract_emails(item, self.domain, self.fuzzy)
            self.results.extend(emails)
        self.log.debug("Email extraction completed")
        return list(set(self.results))
602619
def get_spacy_entites(self, text: str) -> list:
        
        # NOTE: spaCy doc
        doc = self._language_model(text)

        entities = [{"entity": ent.label_,
                     "value": ent.text,
                     "start": ent.start_char,
                     "end": ent.end_char} for ent in doc.ents]

        return entities
220594
def raw_mentions
      opts = self.options.clone
      attributes = opts.delete(:with)

      if opts[:geo]
        opts[:geo] = self.instance_eval("#{opts[:geo]}")
      end

      query = []
      attributes.each do |attr|
        query << self.instance_eval("#{attr}")
      end

      {
        :google_news => GovKit::SearchEngines::GoogleNews.search(query, opts),
        :google_blogs => GovKit::SearchEngines::GoogleBlog.search(query, opts),
#        :technorati => GovKit::SearchEngines::Technorati.search(query),
        :bing => GovKit::SearchEngines::Bing.search(query, opts)
      }
    end
799439
def get_comments(self):
        
        # Lazily load info
        if self.info is None:
            self.get_info()

        if 'comments' in self.info:
            return [structure['text'] for structure in self.info['comments']['comments']]
        else:
            return []
1274219
def mentions(self):
        
        if self._mentions is None:
            self._mentions = []
            for mention_element in self._element.xpath('mention'):
                this_mention = Mention(self, mention_element)
                self._mentions.append(this_mention)
                if this_mention.representative:
                    self._representative = this_mention
        return self._mentions