the twitter world

38
STRICTLY PRIVATE & HIGHLY CONFIDENTIAL 网网网网网网网网网网 / 网网网 /2010-11 The The Twitter Twitter World World 2010 网 11 网 9 网 网网网网 网网网 网网网 网网 网网网 网网 策策 策策 策策策 策策 策 策策策 http:// hi.baidu.com/drkevinzhang /

Upload: gwidon

Post on 05-Jan-2016

84 views

Category:

Documents


0 download

DESCRIPTION

The Twitter World. 2010 年 11 月 9 日. 指导老师:赵燕平 张华平 主讲: 欧阳旭 孙隽. http://hi.baidu.com/drkevinzhang/. 策划: 孙隽 欧阳旭 米志付 赵伟东. What Is Twitter. ICTCLAS & Human-based computation. Coding Language In Twitter. Twitter Construction. Searching Technology In Twitter. Web 2.0 :一个时代的诞生. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The  Twitter World

STRICTLY PRIVATE & HIGHLY CONFIDENTIAL

《网络信息内容安全》讲义 / 张华平 /2010-11

TheThe Twitter World Twitter World

2010 年 11 月 9日

指导老师:赵燕平 张华平

主讲: 欧阳旭 孙隽

策划: 孙隽 欧阳旭 米志付 赵伟东

http://hi.baidu.com/drkevinzhang/

Page 2: The  Twitter World

ICTCLAS &Human-based

computation

TwitterConstructi

on

WhatIs

Twitter

CodingLanguageIn Twitter

SearchingTechnolog

yIn Twitter

Page 3: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Web 2.0:一个时代的诞生

Web 1.0 1. 用户仅仅是获取信息 2. 很少能对网络做出贡献

Web 2.0 1. 不仅仅是阅读者 (Negative Receiving ) 2. 更是创作者 (Positive Creating) 3. Collective Intelligence

Page 4: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Web 2.0 主要代表技术

Blog—— 博客 / 网志: WEB BLOGInstant Publication ; Communicate with Friends

RSS —— 是站点用来和其他站点之间共享内容的一种简易方式(也叫聚合内容)的技术。

WIKI—— 百科全书 , Wiki-- 一种多人协作的写作工具。 Wiki 站点可以有多人(甚至任何访问者)维护,每个人都可以发表自己的意见,或者对共同的主题进行扩展或者探讨。

Page 5: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter 的由来

缺少同步服务

页面信息分散

讨论聚拢性不强

BLOG

Evan Williams 等人在 2006 年推出了 Twitter 服务

1. 形容鸟的叽叽喳喳声

2. 形容人说话议论时的声音

Page 6: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter 的机理

Page 7: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter 的机理

Twitter(一种服务)

Web2 . 0 模式(互联网平台)

参与者自行组织其中的内容( Web Maker )

Followers

Following

关注某一账号所发布内容的其他 Twitter 用户

主动“追随”别人

Page 8: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter 大显身手

2008 年的美国总统大选, Twitter 视作是奥巴马竞选成功的重要因素之一。

奥巴马

希拉里

Follower Following

131151 135229

5996 0

Twitter 的秘密在于你关注了多少人,而不在于有多少人关注你 .

要尽可能多地去追随更多的人,它是一个很好的从别人那里获取信息的来源

Page 9: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter 大显身手

2009 年 6 月,当杰克逊被救护车抬出家门时,有位路人用手机向 Twitter 发布了一条消息:天哪,我在杰克逊家门口, ( 看到 ) 有人被抬出去了,肯定是发生什么事了。

事实上,连 CNN 、美联社的报道都是援引 Twitter 上的信息。

从杰克逊的离去,所有加入传播的人都开始在想: 140 字内,我该说些什么 ? 我该传播一些什么 ?

而新媒体的意义,也许便从宣传式播、挖掘式传播发展到主动式传播

Page 10: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter设计语言

基本概念回顾:

面向对象 (Object Oriented, OO) :对象是人们要进行研究的任何事物,从数,人到飞机。类:对象的抽象是类,类的具体化就是对象。(以潘笛和人为例)

JVM : Java Virtual Machine ( Java 虚拟机),它是一个虚构出来的计算机 , 是通过在实 际的计算机上仿真模拟各种计算机功能来实现的。引入 Java 语言虚拟机后 ,Java 语言在不同平台上运行时不需要重新编译。线程: thread 。。线程 (thread), 有时被称为轻量级进程(Lightweight Process , LWP) ,是 程序执行流的最小单元。静态类型语言:是指需要进行变量 /对象类型声明的语言,一般情况下需要编译 执行。

例如 C/C++/Java/C# 动态类型语言:是指不需要进行变量 /对象类型声明的语言,一般情况下不需要 编译 (

但也有编译型的 )。例如 PHP/ASP/Ruby/Python/Perl/ABAP/SQL/JavaScript/Unix Shell 等XML:( Extensible Markup Language )即可扩展标记语言, Xml 是 Internet环境中跨平台 的,依赖于内容的技术,是当前处理结构化文档信息的有力工具。 XML 与

HTML 的设计区别是: XML 是用来存储数据的,重在数据本身。而 HTML 是用来 定义数据的,重在数据的显示模式。API(Application Programming Interface,应用程序编程接口 ) 是一些预先定义的函数,目的 是提供应用程序与开发人员基于某软件或硬件的以访问一组例程的能力,而又

需访问源码,或理解内部工作机制的细节。

Page 11: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter工程师对 Ruby的不满

1 ) Ruby 不太合适开发长时间运行 (Long-Live) 的服务器端程序,但 JVM 很合适,因为 Java 有 10 年的经验教训和优化, Scala 是运行在 JVM 上的,所以天生就有了这个优点;

2) Ruby没有很好的线程 (Thread)支持, Ruby 多线程会限制在一个 CPU 上且Ruby VM 的垃圾收集支持也没有 Java先进,就造成每个 Ruby 进程长时间运行后使用的内存月来越大;

3) JRuby缺乏使用广泛的 Rem支持(很多优秀的 Ruby包都需要 C 扩展,它们并没有移植到 Java ),而且性能也不太理想,比MRI ( C 实现的 Ruby VM )要慢

Ruby ,一种为简单快捷面向对象编程(面向对象程序设计)而创的脚本语言,由日本人松本行弘开发。

Ruby 是完全面向对象的:任何一点数据都是对象,包括在其他语言中的基本类型,每个过程或函数都是方法。

Page 12: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

从思考到选择 Scala

理想中的编程语言:

◆快速◆函数式◆表达能力◆静态类型◆并发◆优美◆轻量

Page 13: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

1. Type inference that does not suck. (静态类型)

2. Immutable save where mutability fits (面向对象,并发,异步)

3. First-class functions, because we are classy people (把函数写成没有名字的文本)

4. Traits, because inheritance isn’t always what you want(引入新方法)

5. Pattern matching: case statements on crack

6. XML literals and query methods make working with XML positively tolerable ( JavaScript+JSON )

7. Actors: a nice way to handle concurrency(but not the only way)

Scala 的特性

Page 14: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

平台构成平台构成——概述概述

Twitter.com 手机第三方

Twitter平台

Page 15: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

进入进入 TwitterTwitter 架架构构

• 一些架构数据– Twitter目前有 105,779,710 注册用户数;– Twitter 现在每天有 300,000 的新注册用户数;– 每月有 180万独立访问用户数;– 75% 的流量来自 Twitter.com 网以外的网站;– 每天通过 API 有 30亿请求总次数;– Twitter 用户每天平均有 5500万次 tweet;– 37% 的活跃用户为手机用户;–超过一半( 60% )的 tweet 来自第三方应用;

Page 16: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

核心业务

• Following 和 Be followed• 1. 为每一个注册用户订制一个 Be-followed的表,主要内容是每一个 follower 的 ID。同时,也订制一个 Following的表,主要内容是每一个 following作者的 ID。

• 2. 当用户打开自己的个人空间时, Twitter先查阅 Following表,找到所有 following的作者的 ID。然后去数据库读取每一位作者最近写的短信。汇总后按时间顺序显示在用户的个人主页上。

• 3. 当用户写了一则短信时, Twitter先查阅 Be-followed表,找到所有 followers 的 IDs。然后逐个更新那些 followers的主页。

• 如果有 follower正在阅读他的 Twitter个人主页,主页里暗含的JavaScript会自动每隔几十秒,访问一下 Twitter服务器,检查正在看的这个个人主页是否有更新。如果有更新,立刻下载新的主页内容。这样 follower就能读到最新发表的短信了。

Page 17: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

架构思想架构思想

Mongrel Rails ServerMongrel Rails Server

发布消息

Kestrel(MQ)

Kestrel(MQ)

Mongrel Rails ServerMongrel Rails Server

获取消息

缓存聚合器缓存聚合器

Vector CacheTweet/user

Vector CacheTweet/user Row Cache

Items/userRow CacheItems/user

Fragment CacheItems/tweet

Fragment CacheItems/tweet

Page CacheItems/user(Varnish)

Page CacheItems/user(Varnish)

MySqlMySql

99%hits 95%hits95%hits

40%hits

Page 18: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

架构架构 1—1— 缓存缓存

每个 tweet 平均被 126 个用户跟踪,所以这里有着明显的缓存需求 ;

只有 API 有着一个页面缓存,当每次从一个用户那里来了一个 tweet 时就会失效,而应用的其它部分都是无缓存的 ;

Page 19: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

架构架构 1—1— 缓存缓存

• 改进进程

– 1 、创建一个直写式向量缓存 Vector Cache,包含了一个 tweet ID 的数组, tweet ID 是序列化的 64位整数。命中率是 99% 。

– 2 、加入一个直写式行缓存 Row Cache ,它包含了数据库记录:用户和 tweets 。这一缓存有着 95%的命中率并且使用了 Nick Kallen 的名为Cache Money的 Rails插件。

– 3 、引入了一个直读式的碎片缓存 Fragment Cache ,它包含了通过 API 客户端访问到的 tweets 的序列化版本,这些 tweets 可以被打包成 JSON , XML 或者是 Atom 的格式,有着同样是 95% 的命中率。

– 4 、为页面缓存创建一个单独的缓存池 Page Cache 。根据 Evan 的说法,该页面缓存池使用了一个分代的键模式,而不是直接的失效;

Page 20: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

架构架构 1—1— 缓存缓存

Page 21: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

架构架构 11

用三层结构表示

Page 22: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Page 23: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

关于网络 Tag的技术

GirlMother

HedgehogLawn

GirlMother

HedgehogLawn

Image Retrieval

Image Tagging

加标签( tag )是一种网络搜索技术:以 Flickr为例: 图片上传者可自己定义该相片的关键字,也就是“标签( Tags )”(是元资料( Metadata )的一种格式),如此一来搜寻者可很快的找到想要的相片,例如指定拍摄地点或照片的主题,而创作者也能很快了解相同标签( Tags )下有哪些由其他人所分享的照片。

Page 24: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

关于 Twitter Hashtag技术

# 标签还是很有的。加 # 标签,可表示在谈论某个特定话题;还有那些缩写的 # 标签消息。比如 #sxsw ,表示在德州奥斯丁举行的西南偏南音乐节;还有 #nptech ,表示非赢利技术( non-profitable technology )

Page 25: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter 风靡之因

内容以简短的文字为主

手段多样化,包括Web 、客户端和手机

网站主交互模式是“分众型广播”,简单,且就在首页为主

网站交互手段即时且简单,主要是即时回应

网站本身是一个开放平台,方便大量第三方应用植入。

该产品如果只有你一个人使用,没法玩:你要玩好它,你必须要拉更多的朋友来

TwitterTwitter

可快速发布的内容可快速发布的内容

可快速发布的网站结构可快速发布的网站结构

病毒式传播设计病毒式传播设计

Page 26: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter 获取信息

Page 27: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter 获取信息

信息按照时间顺序排列,越新的信息越靠前

通过点击它提供的链接地址,我们就可以看到 Dell 笔记本电池销售页面,达到按图索骥的效果。 这样一来,热门产品的型号、报价与用户反馈等重要信息便一目了然了。

Page 28: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter 即时信息搜索

由于 Twitter 的信息发布属于即时性质,所以这种关键字搜索便是关键字的即时搜索

可以使用 RSS 订阅的方式来让 Twitter 的搜索引擎将最新的结果自动发送到自己的订阅器上面

Page 29: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter 即时信息搜索

Google 阅读器。确定之后,再次登录进入 Google 阅读器,就可以随时看到 Twitter 上面关于 Dell 的最新搜索结果。

Page 30: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter社交网络进行可视化

通过观察用户之间公开交流,可以看到某个用户与哪些人之间进行了通信,他们探讨了哪些话题。

通过对双方交流频率的统计,可以了解他们之间的关系紧密程度。

将某个用户与所有其他用户的交流进行分类统计,就可以获得该用户社交网络的概貌

Mailana 是一个统计社交联络信息的网站

利用来自于 Twitter 平台的数据,通过统计与数据挖掘的方法,对某个用户的社交联络信息进行可视化。

Page 31: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

Twitter社交网络进行可视化

Page 32: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

人本计算( Human-based Computation)

Let’s make digitalization as an Example

1. The former 129 years’ material are not digitalized

2. Scanning the earlier material Dividing the text image into simple words

3. Strip and distort the words into the identifying code

Surf InternetProduceOnline

Computing Cost

Surf InternetProduceOnline

Computing Cost

Countless Computing

Cost

Countless Computing

Cost

Accumulation is

Enormous

Accumulation is

Enormous

Page 33: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

人本计算( Human-based Computation)

Collects very mini power of huge number of people and it can help finish large projects while single human is not able to

Traditional Method: System catch intent from human, processing according to certain logic and send the result back to users.

Human-Based method: System leaves some specific processing logic to the user. Then extract the users’ action feature to derive the final results.

Page 34: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

人本计算在图片检索上的应用

ChildHedgehog

Mother

ChildHedgehog

Mother

HedgehogHedgehog

GirlWoman

Hedgehog

GirlWoman

Hedgehog

1. Upload the images to the image sharing website.

2. The website distributes the images to different users

3. Users tag the images with their own methods

4. Backstage system utilizes suitable algorithm to process the tags to extract the suitable keywords

Page 35: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

ICTCLAS分词系统

Page 36: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

ICTCLAS分词系统

Primary Chinese StringPrimary Chinese String

Element segmentationElement segmentation

Segmentation for N-shortest pathSegmentation for N-shortest path

Simple new words recognitionSimple new words recognition

Cascade new words recognitionCascade new words recognition

Duality segmentation chartDuality segmentation chart

CHMM based on ClassCHMM based on Class

Word class CHMM recognitionWord class CHMM recognition

Morphology Analysis ResultsMorphology Analysis Results

Optimizing segmentation chart

Fifth HMM Level

Third HMM LevelSecond HMM Level

First HMM Level

Segment unit sequence

Optimum N resultsForth HMM Level

Page 37: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

诚挚感谢!

Page 38: The  Twitter World

All rights reserved. No content can be reproduced without prior agreement with Section VI. 《网络信息内容安全》讲义 / 张华平 /2010-10

ContactEmail: [email protected]

Welcome to visit my blog

http://hi.baidu.com/drkevinzhang/

Thank you