
342
3
부
애플리케이션
entities = df.select('title').collect()
entities = [r['title'] for r in entities]
entities = set(entities)
print(len(entities))
284812
동일한 범주 관계를 도입하고 싶을 수 있으므로 범주도 추출한다.
categories = [e for e in entities if e.startswith('Category:')]
entities = [e for e in entities if not e.startswith('Category:')]
이제 리다이렉트를 가져오자.
redirects = df.filter('redirect IS NOT NULL')\
.select('redirect._title', 'title').collect()
redirects = [(r['_title'], r['title']) for r in redirects]
print(len(redirects))
63941
이제
revision
.
text
._
VALUE
에서 기사를 가져올 수 있다.
data = df.filter('redirect IS NULL').selectExpr(
'revision.text._VALUE AS text',
'title'
).filter('text IS NOT NULL') ...