Example #1
0
 def transform(self, X):
     mat = np.zeros((len(X), 1))
     for i, (_, s) in enumerate(X.iterrows()):
         idx = get_aligned_data().get((s.claimId, s.articleId))
         if idx:
             try:
                 claim_tok = get_tokenized_lemmas(s.claimHeadline)
                 article_tok = get_tokenized_lemmas(s.articleHeadline)
                 mat[i, 0] = self._sts(claim_tok, article_tok, idx)
             except:
                 pass
     return mat
Example #2
0
 def transform(self, X):
     mat = np.zeros((len(X), 1))
     for i, (_, s) in enumerate(X.iterrows()):
         idx = get_aligned_data().get((s.claimId, s.articleId))
         if idx:
             try:
                 claim_tok = get_tokenized_lemmas(s.claimHeadline)
                 article_tok = get_tokenized_lemmas(s.articleHeadline)
                 mat[i, 0] = self._sts(claim_tok, article_tok, idx)
             except:
                 pass
     return mat
Example #3
0
    def transform(self, X):
        mat = np.zeros((len(X), 1))
        for i, (_, s) in enumerate(X.iterrows()):
            idx = get_aligned_data().get((s.claimId, s.articleId))
            f = 0
            if idx:
                claim_tok = get_tokenized_lemmas(s.claimHeadline)
                article_tok = get_tokenized_lemmas(s.articleHeadline)
                for x, y in idx:
                    if x > 0 and y == 0:
                        f = self._match(claim_tok[x-1])
                    elif x == 0 and y > 0:
                        f = self._match(article_tok[y-1])
                    elif [x-1, y-1] not in idx:
                        f = self._match(claim_tok[x-1]) or self._match(article_tok[y-1])
            mat[i, 0] = f

        return mat
Example #4
0
    def transform(self, X):
        mat = np.zeros((len(X), 1))
        for i, (_, s) in enumerate(X.iterrows()):
            idx = get_aligned_data().get((s.claimId, s.articleId))
            f = 0
            if idx:
                claim_tok = get_tokenized_lemmas(s.claimHeadline)
                article_tok = get_tokenized_lemmas(s.articleHeadline)
                for x, y in idx:
                    if x > 0 and y == 0:
                        f = self._match(claim_tok[x - 1])
                    elif x == 0 and y > 0:
                        f = self._match(article_tok[y - 1])
                    elif [x - 1, y - 1] not in idx:
                        f = self._match(claim_tok[x - 1]) or self._match(
                            article_tok[y - 1])
            mat[i, 0] = f

        return mat