network analysis with networkx : real-world example-2

10
Kyunghoon Kim Network Analysis with networkX Real-World Example - 2 2014. 07. 18. UNIST Mathematical Sciences Kyunghoon Kim ( [email protected] ) 2014-07-18 Real-World Example - 2 1

Upload: kyunghoon-kim

Post on 15-Jan-2015

183 views

Category:

Education


2 download

DESCRIPTION

UNIST Mathematical Sciences Network analysis with networkX(python library)

TRANSCRIPT

Page 1: Network Analysis with networkX : Real-World Example-2

Kyunghoon Kim

Network Analysis with networkX

Real-World Example - 2

2014. 07. 18.

UNIST Mathematical Sciences

Kyunghoon Kim ( [email protected] )

2014-07-18 Real-World Example - 2 1

Page 2: Network Analysis with networkX : Real-World Example-2

Kyunghoon Kim

This is the upgrade version of last ‘Real-World Example - 1’http://www.slideshare.net/koorukuroo/network3-36009536

You can use the command ‘pip install’: pip install umorphemehttps://pypi.python.org/pypi?:action=display&name=UMorpheme

For this example

2014-07-18 Real-World Example - 2 2

Page 3: Network Analysis with networkX : Real-World Example-2

Kyunghoon Kim

MeCab : The morphological analysis engine that was developed by Kyoto University Graduate School of Informatics

Eunjeon Hannip Project : Korean library with MeCab that was developed by Yongwoon Lee, Youngho Yoo.

Morpheme Analyzer

2014-07-18 Real-World Example - 2 3

Page 4: Network Analysis with networkX : Real-World Example-2

Kyunghoon Kim

On the OS ‘Windows’, there are some problem for the installation(e.g., compile process such as Make). Cygwin, MinGW also have some problem.

So we replaced it by Restful WebService.

Morpheme Analyzer

2014-07-18 Real-World Example - 2 4

Page 5: Network Analysis with networkX : Real-World Example-2

Kyunghoon Kim

Install using pip :pip install umorpheme

https://gist.github.com/koorukuroo/4aea6353b20c789bb2bcorhttp://goo.gl/geDLK4

If you want to know a principle of morpheme analyzer, refer to the kkma site.http://kkma.snu.ac.kr/documents/?doc=algorithm

Online Morpheme analyzer

2014-07-18 Real-World Example - 2 5

Page 6: Network Analysis with networkX : Real-World Example-2

Kyunghoon Kim

# -*- coding: utf8 -*-

import Umorpheme.morpheme as um

from collections import OrderedDict

s = "나는멸치볶음보리밥을롯데리아에서한예슬과함께먹었습니다. 롯데리아에는맥도날드해피밀이없습니다." # input sentence

data = um.analyzer(s, '23485900349', "[롯데리아,맥도날드]", 1)

Online Morpheme analyzer

2014-07-18 Real-World Example - 2 6

Page 7: Network Analysis with networkX : Real-World Example-2

Kyunghoon Kim

temp = {}

for key, value in data.items():

temp[int(key)] = value

data = OrderedDict(sorted(temp.items()))

for i, j in data.iteritems():

print i, j['data'], j['feature']

Online Morpheme analyzer

2014-07-18 Real-World Example - 2 7

Page 8: Network Analysis with networkX : Real-World Example-2

Kyunghoon Kim

0 나 NP

1 는 JX

2 멸치볶음보리밥 COMP

6 을 JKO

7 롯데리아 CUSTOM

8 에서 JKB

9 한예슬 NNP

10 과 JKB

11 함께 MAG

12 먹 VV

13 었 EP

14 습니다 EF

15 . SF

16 롯데리아 CUSTOM

17 에 JKB

18 는 JX

19 맥도날드 CUSTOM

20 해피밀 COMP

22 이 JKS

23 없 VA

24 습니다 EF

25 . SF

Online Morpheme analyzer

2014-07-18 Real-World Example - 2 8

Document of Tag like NP, JX : http://goo.gl/tI84DW

Page 9: Network Analysis with networkX : Real-World Example-2

Kyunghoon Kim

{u'24': {u'data': u'\uc2b5\ub2c8\ub2e4', u'feature': u'EF'}, u'25': {u'data': u'.', u'feature': u'SF'}, u'20': {u'data': u'\ud574\ud53c\ubc00', u'feature': u'COMP'}, u'22': {u'data': u'\uc774', u'feature': u'JKS'}, u'23': {u'data': u'\uc5c6', u'feature': u'VA'}, u'1': {u'data': u'\ub294', u'feature': u'JX'}, u'0': {u'data': u'\ub098', u'feature': u'NP'}, u'2': {u'data': u'\uba78\uce58\ubcf6\uc74c\ubcf4\ub9ac\ubc25', u'feature': u'COMP'}, u'7': {u'data': u'\ub86f\ub370\ub9ac\uc544', u'feature': u'CUSTOM'}, u'6': {u'data': u'\uc744', u'feature': u'JKO'}, u'9': {u'data': u'\ud55c\uc608\uc2ac', u'feature': u'NNP'}, u'8': {u'data': u'\uc5d0\uc11c', u'feature': u'JKB'}, u'11': {u'data': u'\ud568\uaed8', u'feature': u'MAG'}, u'10': {u'data': u'\uacfc', u'feature': u'JKB'}, u'13': {u'data': u'\uc5c8', u'feature': u'EP'}, u'12': {u'data': u'\uba39', u'feature': u'VV'}, u'15': {u'data': u'.', u'feature': u'SF'}, u'14': {u'data': u'\uc2b5\ub2c8\ub2e4', u'feature': u'EF'}, u'17': {u'data': u'\uc5d0', u'feature': u'JKB'}, u'16': {u'data': u'\ub86f\ub370\ub9ac\uc544', u'feature': u'CUSTOM'}, u'19': {u'data': u'\ub9e5\ub3c4\ub0a0\ub4dc', u'feature': u'CUSTOM'}, u'18': {u'data': u'\ub294', u'feature': u'JX'}}

Online Morpheme analyzer

2014-07-18 Real-World Example - 2 9

Page 10: Network Analysis with networkX : Real-World Example-2

Kyunghoon Kim

Let’s practice!

TextRank : Bringing Order into Textshttp://www.cse.unt.edu/~rada/papers/mihalcea.emnlp04.pdf

Practice

2014-07-18 Real-World Example - 2 10