CODE:

#!/usr/bin/python
# -*- coding: utf-8 -*- '''
Created on 2014-8-19
@author: guaguastd
@name: job_title_standard.py
''' import os
import csv
from collections import Counter
from operator import itemgetter
from prettytable import PrettyTable # specify csv directory
CSV_FILE = os.path.join(r"E:", "\\", "eclipse", "LinkedIn", "dfile", "my_connections.csv") # define a set of transforms that converts the first item
# to the second item
transforms = [
('Sr.', 'Senior'),
('Sr', 'Senior'),
('Jr.', 'Junior'),
('Jr', 'Junior'),
('CEO', 'Chief Executive Officer'),
('COO', 'Chief Operating Officer'),
('CTO', 'Chief Technology Officer'),
('CFO', 'Chief Finance Officer'),
('VP', 'Vice President'),
] csvReader = csv.DictReader(open(CSV_FILE), delimiter=',', quotechar='"')
contacts = [row for row in csvReader] # Read in a list of titles and split
# apart any combined titles like "President/CEO."
# "President & CEO", "President and CEO"
titles = []
for contact in contacts:
titles.extend([t.strip() for t in contact['Job Title'].split('/')
if contact['Job Title'].strip() != '']) # Replace common/known abbreviations
for i, _ in enumerate(titles):
for transform in transforms:
titles[i] = titles[i].replace(*transform) # Print out a table of titles sorted by frequency
pt = PrettyTable(field_names=['Title', 'Freq'])
pt.align = 'l'
c = Counter(titles)
[pt.add_row([title, freq])
for (title, freq) in sorted(c.items(), key=itemgetter(1), reverse=True)
if freq > 0]
print pt # Print out a table of tokens sorted by frequency
tokens = []
for title in titles:
tokens.extend([t.strip(',') for t in title.split()])
pt = PrettyTable(field_names=['Token', 'Freq'])
pt.align = 'l'
c = Counter(tokens)
[pt.add_row([token, freq])
for (token, freq) in sorted(c.items(), key=itemgetter(1), reverse=True)
if freq > 0 and len(token) > 2]
print pt

RESULT:

+-----------------------------------+------+
| Title | Freq |
+-----------------------------------+------+
| Senior Software Developer | 1 |
| Sales Manager | 1 |
| Software Manager | 1 |
| Online Marketing Manager | 1 |
| Senior Consultant | 1 |
| Chief Executive Officer & Founder | 1 |
| Director | 1 |
| S | 1 |
| Student | 1 |
| Senior Software Engineer | 1 |
| ??? | 1 |
+-----------------------------------+------+
+------------+------+
| Token | Freq |
+------------+------+
| Manager | 3 |
| Senior | 3 |
| Software | 3 |
| Marketing | 1 |
| Founder | 1 |
| Consultant | 1 |
| Executive | 1 |
| Sales | 1 |
| Developer | 1 |
| Director | 1 |
| Chief | 1 |
| Officer | 1 |
| Student | 1 |
| Online | 1 |
| ??? | 1 |
| Engineer | 1 |
+------------+------+

Python 规范化LinkedIn用户联系人的职位名的更多相关文章

  1. Python 摘录LinkedIn用户联系人

    CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-8-18 @author: guaguastd @name: l ...

  2. 根据职位名,自动生成jd

    代码本身就是最好的解释,不赘述. 文本聚类输出: cluster.py #!/usr/bin/env python # coding=utf-8 import jieba,re from gensim ...

  3. oracle看到用户的所有表名、表睐、字段名称、现场的目光、是空的、字段类型

    --oracle看到用户的所有表名.表睐.字段名称.现场的目光.是空的.字段类型 select distinct TABLE_COLUMN.*, TABLE_NALLABLE.DATA_TYPE, T ...

  4. oracle查询所有用户表的表名、主键名称、索引、外键等

    1.查找表的所有索引(包括索引名,类型,构成列): select t.*,i.index_type from user_ind_columns t,user_indexes i where t.ind ...

  5. python入门:用户登录,三次错误机会

    #!/usr/bin/env python # -*- coding:utf-8 -*- #用户登录,三次机会重试 #主要分为两个部分,一部分是写三次循环,一部分写用户输入 #用户登录的实现,循环3次 ...

  6. python初步编写用户登录

     python初步编写用户登录 python编写用户登录 用python写一个脚本,使得这个脚本在执行后,可以产生如下的效果: 1.用户的账号为:root 密码为:westos 2.用户账号和密码均输 ...

  7. Python之读取用户指令和格式化打印

    Python之读取用户指令和格式化打印 一.读取用户指令 当你的程序要接收用户输入的指令时,可以用input函数: name = input("请输入你的名字:") print(& ...

  8. 我的第一个python web开发框架(37)——职位管理功能

    对于职位管理,我们可以理解它为角色权限的管理,就像前面所说的一样,有了职位管理,后台管理系统绑定好对应的权限以后,新进员工.离职或岗位调整,管理员操作起来就非常的便捷了,只需要重新绑定对应职位就可以做 ...

  9. linux python 安装到用户目录

    在公司服务器中,python可能存在多个版本,而且python中的包也有多个不同版本,由于不同猿的需求不同,经常会引起程序冲突,影响工作效率.因此,给大家分享一个在没有root权限时,将python安 ...

随机推荐

  1. system权限无法访问外挂SD卡

    总结Android应用system权限无法访问SD卡问题 包括android1.6 解决方案http://hi.baidu.com/yunlongchn/item/7d6636d8547317ffca ...

  2. css3上下翻页效果

    翻页效果显示当前时间 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> &l ...

  3. 关于Delphi cxGrid主从表中从表只能编辑第一条记录的问题

    在Delphi cxGrid主从表中从表只能编辑第一条记录,这个问题是由于设置主从关联字段错误造成的. 从表DBtableView2的keyfieldnames,DetailKeyFieldNames ...

  4. nginx进行项目域名配置时提示Job for nginx.service failed

    ps aux | grep nginx /bin/systemctl stop nginx.service /bin/systemctl start nginx.service /bin/system ...

  5. HDOJ 1085 Holding Bin-Laden Captive!

    Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  6. .net连接mysql

    首先在官网下载,mysql-connect-net,用于使用mysql的驱动程序,我在下载mysql-connect-net.msi. installer后,执行安装程序的时候一直无法安装成功,最简单 ...

  7. win10易升卸载

  8. linux程序运行浅析

    例如有一个脚本文件tests.sh,内容如下: #!/bin/bash #This is a sample test. cd /tmp echo "Hello, this is a test ...

  9. manjao linux下玩转arduino

    自从入手arduinon差不多半个月了,在window下几乎没有任何问题,下载,编程,编译,上传,运行.几乎没有任何问题.在linux编译成功,上传时下却总是提示找不到libncurses.so.5无 ...

  10. window postgresql 10.4安装

    window installer下载地址:https://www.enterprisedb.com/downloads/postgres-postgresql-downloads 其他版本官网下载地址 ...