kindle manager
This commit is contained in:
7
.gitignore
vendored
Executable file
7
.gitignore
vendored
Executable file
@@ -0,0 +1,7 @@
|
||||
*.pyc
|
||||
*.swp
|
||||
log*
|
||||
*Clippings*
|
||||
*xxx*
|
||||
cr
|
||||
rungit*
|
||||
201
LICENSE
Normal file
201
LICENSE
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
120
README.md
Executable file
120
README.md
Executable file
@@ -0,0 +1,120 @@
|
||||
kindle manager
|
||||
============
|
||||
|
||||
1. 读取kindle笔记,获取标注和剪贴文章。
|
||||
1. 按书本标题搜索,并输出markdown格式标注
|
||||
1. 按作者搜索内容,并输出markdown格式标注
|
||||
|
||||
## 说明
|
||||
在`My Clippings.txt`中,有3种类型
|
||||
|
||||
### 书签 ###
|
||||
格式为:
|
||||
|
||||
庆余年(精校版) (猫腻)^M
|
||||
- 您在位置 #33260 的书签 | 添加于 2020年1月12日星期日 下午10:37:10^M
|
||||
^M
|
||||
^M
|
||||
|
||||
### 标注 ###
|
||||
格式为:
|
||||
|
||||
<feff>薛兆丰经济学讲义 (薛兆丰)^M
|
||||
- 您在位置 #1408-1410的标注 | 添加于 2020年1月13日星期一 上午8:11:05^M
|
||||
^M
|
||||
么到底什么叫边际?边际就是“新增”带来的“新增”。 例如,边际成本就是每新增一个单位产品所需要付出的新增成本;边际收入是每多卖一个产品能够带来的新增收入;边际产量是每新增一份投入所带来的新增产量;边际效用是每消耗一个单位的商品所能带来>的新增享受。^M
|
||||
|
||||
### 笔记 ###
|
||||
笔记比较特殊,笔记是与标注连在一起的。表示该笔记是在该标注上完成的。
|
||||
|
||||
<feff>薛兆丰经济学讲义 (薛兆丰)^M
|
||||
- 您在位置 #4284-4286的标注 | 添加于 2020年1月30日星期四 上午10:23:58^M
|
||||
^M
|
||||
一个国家很大,贫富有差距,并非每个学校和家长都能负担得起这样标准的校车。标准太高,就会逼着很多学校,尤其是农村的学校放弃提供校车,家长们就只能使用安全性能更低的交通工具,比如自己骑自行车或雇用黑车等,结果是孩子们享受到的安全保障反而降低了。^M
|
||||
==========^M
|
||||
<feff>薛兆丰经济学讲义 (薛兆丰)^M
|
||||
- 您在位置 #4286 的笔记 | 添加于 2020年1月30日星期四 上午10:26:10^M
|
||||
^M
|
||||
是山寨 假货 问题^M
|
||||
==========^M
|
||||
<feff>薛兆丰经济学讲义 (薛兆丰)^M
|
||||
- 您在位置 #4286 的笔记 | 添加于 2020年1月30日星期四 上午10:26:31^M
|
||||
^M
|
||||
山寨 假货 问题^M
|
||||
|
||||
### 剪贴文章 ###
|
||||
|
||||
Book Title\n
|
||||
- 剪贴文章 位置N | 已添加至 sometime\n
|
||||
\n
|
||||
剪贴文章内容\n
|
||||
|
||||
每一个摘录都用`==========\n`分割开。
|
||||
|
||||
## 内容提取
|
||||
|
||||
### 书名
|
||||
|
||||
<feff>薛兆丰经济学讲义 (薛兆丰)^M
|
||||
vi re:
|
||||
^.\([^(]\+\)(
|
||||
|
||||
### 作者
|
||||
|
||||
庆余年(精校版) (猫腻)^M
|
||||
vi re:
|
||||
([^()]\{-})^M$
|
||||
|
||||
### 位置/页码/添加时间
|
||||
|
||||
- 您在位置 #4286 的笔记 | 添加于 2020年1月30日星期四 上午10:26:31^M
|
||||
vi re:
|
||||
#\(\d\+-\{0,1}\d\+\).\+\(\d\{4}年\d\{1,2}月\d\{1,2}日\)\(星期.\) \(..\)\(\d\{1,2}:\d\{1,2}:\d\{1,2}\)
|
||||
group1 - 页码
|
||||
group2 - xxxx年xx月xx日
|
||||
group3 - 星期
|
||||
group4 - 上下午
|
||||
group5 - 时间
|
||||
|
||||
|
||||
## 保存的数据结构
|
||||
|
||||
### dict data structure
|
||||
book =
|
||||
{
|
||||
"bookname_xxx": {
|
||||
"author": "李",
|
||||
"section1636": {
|
||||
"content": "张",
|
||||
"day": "2020年4月3日",
|
||||
"meridiem": "下午",
|
||||
"position": "311-311",
|
||||
"time": "3:00:53",
|
||||
"type": "HL",
|
||||
"week": "星期五"
|
||||
},
|
||||
"section1651": {
|
||||
"content": "治",
|
||||
"day": "2020年4月3日",
|
||||
"meridiem": "下午",
|
||||
"position": "514",
|
||||
"time": "3:43:50",
|
||||
"type": "NT",
|
||||
"week": "星期五"
|
||||
},
|
||||
"section1814": {
|
||||
"content": null,
|
||||
"day": "2020年4月12日",
|
||||
"meridiem": "下午",
|
||||
"position": "5186",
|
||||
"time": "2:20:12",
|
||||
"type": "BM",
|
||||
"week": "星期日"
|
||||
},
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
|
||||
### Markdown文本 ###
|
||||
|
||||
35
changelog.md
Normal file
35
changelog.md
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
# Change Log
|
||||
|
||||
## 1.0.0 (20200526)
|
||||
### create
|
||||
- abstract note/bookmark/highlight from kindle clipping
|
||||
- formatter output to special file
|
||||
|
||||
### learn lesson
|
||||
- assign value to a not exist key, will throw KeyError, too inflexible!!! perl much better
|
||||
- use defaultdict to solve obove problem, note, defaultdict only create two layer key auto
|
||||
```
|
||||
a=defaultdict(dict)
|
||||
a['1']['2'] = 1
|
||||
|
||||
b=defaultdict(dict)
|
||||
b['1']['2']['3'] = 1 # ERROR
|
||||
|
||||
b['1']['2'] = {'3':1} # OK
|
||||
```
|
||||
- logging, file io, very strict indent!
|
||||
- re.X(VERBOSE), different regular express between vim & python
|
||||
|
||||
## 1.0.1 (20200528)
|
||||
### feature
|
||||
- add search clip
|
||||
|
||||
# feature plan
|
||||
## 20200528
|
||||
- optimize search feature
|
||||
- first abstract from kindle hard / local directory for different OS
|
||||
- add GUI use QT
|
||||
|
||||
|
||||
|
||||
174
file2.py
Normal file
174
file2.py
Normal file
@@ -0,0 +1,174 @@
|
||||
|
||||
#############################################
|
||||
## PROGRAM: file2.py
|
||||
## AUTHOR: Chengan 20200526
|
||||
## douboer@gmail.com
|
||||
#############################################
|
||||
|
||||
import re
|
||||
import json
|
||||
from collections import defaultdict
|
||||
|
||||
# some constants
|
||||
BOUNDARY = '==========\n'
|
||||
# MACOS - /Volumes/Kindle/documents/My\ Clippings.txt
|
||||
CLIPFILE = './My Clippings.txt'
|
||||
STAT = 'NONE'
|
||||
|
||||
'''
|
||||
STAT :
|
||||
NONE - match nothing
|
||||
START - start line of section
|
||||
BM - section is a bookmark
|
||||
HL - section is a highlight
|
||||
NT - section is a note
|
||||
'''
|
||||
# data structure
|
||||
'''
|
||||
book = {'bookname1':
|
||||
{ 'author':'chen',
|
||||
'HL':
|
||||
{ 'index1':
|
||||
{
|
||||
'position':'123-145',
|
||||
'content':'xxxx',
|
||||
'day':'2020年5月26日',
|
||||
'week':'星期二',
|
||||
'meridiem':'PM',
|
||||
'time':'10:26:31'
|
||||
},
|
||||
'index2':
|
||||
{
|
||||
...
|
||||
},
|
||||
...
|
||||
},
|
||||
# 'BM': xxx skip bookmark because the content is empty
|
||||
# { 'index1':
|
||||
# {
|
||||
# 'position':'123',
|
||||
# 'day':'2020年5月26日',
|
||||
# 'week':'星期二',
|
||||
# 'meridiem':'PM',
|
||||
# 'time':'10:26:31'
|
||||
# },
|
||||
# 'index2':
|
||||
# {
|
||||
# ...
|
||||
# },
|
||||
# ...
|
||||
# }
|
||||
'NT':
|
||||
{ 'index1':
|
||||
{
|
||||
'position':'123',
|
||||
'content':'xxxx',
|
||||
'day':'2020年5月26日',
|
||||
'week':'星期二',
|
||||
'meridiem':'PM',
|
||||
'time':'10:26:31'
|
||||
},
|
||||
'index2':
|
||||
{
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
},
|
||||
'bookname2':
|
||||
...
|
||||
}
|
||||
'''
|
||||
|
||||
#author & bookname info
|
||||
au = re.compile(
|
||||
r'''
|
||||
^\ufeff+
|
||||
(.+) \( #bookname
|
||||
(.+)\) #author
|
||||
''', flags=re.X )
|
||||
|
||||
# page & date info
|
||||
# 您在位置 #4286 的笔记 | 添加于 2020年1月30日星期四 上午10:26:31^M
|
||||
# re.X(VERBOSE): 详细模式。这个模式下正则表达式可以是多行,忽略空白字符,并可以加入注释
|
||||
#\(\d\+-\{0,1}\d\+\).\+\(\d\{4}年\d\{1,2}月\d\{1,2}日\)\(星期.\) \(..\)\(\d\{1,2}:\d\{1,2}:\d\{1,2}\)
|
||||
da = re.compile(
|
||||
r'''
|
||||
\#
|
||||
(\d+-{0,1}\d+) #group1 - page
|
||||
.+
|
||||
(笔记|标注|书签) #group2 - type
|
||||
.+
|
||||
(\d{4}年\d{1,2}月\d{1,2}日) #group3 - xxxx年xx月xx日
|
||||
(星期.) #group4 - week
|
||||
\s
|
||||
(..) #group5 - pm/am
|
||||
(\d{1,2}:\d{1,2}:\d{1,2}) #group6 - time
|
||||
''', flags=re.X )
|
||||
|
||||
with open(CLIPFILE, 'r', encoding='utf8', errors='ignore') as f:
|
||||
books = defaultdict(dict)
|
||||
bookname = ''
|
||||
author = ''
|
||||
idx = 0
|
||||
num_section = 0
|
||||
num_line = 0
|
||||
for line in f.readlines():
|
||||
idx += 1
|
||||
line = line.strip()
|
||||
if line.isspace(): continue
|
||||
|
||||
# judge whether or not RE matched
|
||||
# if matched will not do an other RE search
|
||||
# in order to low down the computation
|
||||
flg = False
|
||||
if not flg:
|
||||
aus = au.search(line)
|
||||
if aus:
|
||||
STAT = 'START'
|
||||
bookname = aus.group(1)
|
||||
author = aus.group(2)
|
||||
books[bookname]['author']= author
|
||||
print("book:",aus.group(1),"auth:",aus.group(2))
|
||||
flg = True
|
||||
|
||||
if not flg:
|
||||
das = da.search(line)
|
||||
if das:
|
||||
STAT = ('HL' if das.group(2)=='标注' else ('NT' if das.group(2)=='笔记' else 'BM'))
|
||||
|
||||
# skip bookmark
|
||||
if STAT=='BM': continue
|
||||
|
||||
pos = das.group(1)
|
||||
day = das.group(3)
|
||||
week = das.group(4)
|
||||
pmam = das.group(5)
|
||||
time = das.group(6)
|
||||
#books[bookname][STAT] = {'idx']:idx}
|
||||
books[bookname][STAT] = {idx:{'position':pos}}
|
||||
books[bookname][STAT] = {idx:{'day':day}}
|
||||
books[bookname][STAT] = {idx:{'week':week}}
|
||||
books[bookname][STAT] = {idx:{'meridiem':pmam}}
|
||||
books[bookname][STAT] = {idx:{'time':time}}
|
||||
|
||||
print(pos,STAT,day,week,'PM' if das.group(5)=="下午" else 'AM')
|
||||
|
||||
flg = True
|
||||
|
||||
if not flg:
|
||||
# record the hightlight dict
|
||||
# so if the next section is note,
|
||||
# we can modify the highlight content
|
||||
if STAT=='START':
|
||||
pass
|
||||
elif STAT=='HL':
|
||||
bk_idx = idx
|
||||
bk_content = line
|
||||
books[bookname][STAT] = {idx:{'content':line}}
|
||||
# if the section is note,
|
||||
# append the note to the previous highlight content
|
||||
elif STAT=='NT':
|
||||
books[bookname]['HL'] = {bk_idx:{'content':bk_content+'(CG注:'+line}}
|
||||
|
||||
#print(json.dumps(books,indent=4,sort_keys=True,ensure_ascii=False))
|
||||
240
kman.py
Normal file
240
kman.py
Normal file
@@ -0,0 +1,240 @@
|
||||
|
||||
#############################################
|
||||
## PROGRAM: file2.py
|
||||
## AUTHOR: Chengan
|
||||
## CREATE: 20200526
|
||||
## douboer@gmail.com
|
||||
#############################################
|
||||
|
||||
import platform
|
||||
import re
|
||||
import json
|
||||
import logging
|
||||
from collections import defaultdict
|
||||
|
||||
# data structure - use dict
|
||||
'''
|
||||
books =
|
||||
{
|
||||
"bookname_xxx": {
|
||||
"author": "李",
|
||||
"section1636": {
|
||||
"content": "张",
|
||||
"day": "2020年4月3日",
|
||||
"meridiem": "下午",
|
||||
"position": "311-311",
|
||||
"time": "3:00:53",
|
||||
"type": "HL",
|
||||
"week": "星期五"
|
||||
},
|
||||
"section1651": {
|
||||
"content": "治",
|
||||
"day": "2020年4月3日",
|
||||
"meridiem": "下午",
|
||||
"position": "514",
|
||||
"time": "3:43:50",
|
||||
"type": "NT",
|
||||
"week": "星期五"
|
||||
},
|
||||
"section1814": {
|
||||
"content": null,
|
||||
"day": "2020年4月12日",
|
||||
"meridiem": "下午",
|
||||
"position": "5186",
|
||||
"time": "2:20:12",
|
||||
"type": "BM",
|
||||
"week": "星期日"
|
||||
},
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
'''
|
||||
|
||||
# modi clippath for different os
|
||||
SYS = 'WIN' if platform.system()=='Windows' else \
|
||||
('LINUX' if platform.system()=='LINUX' else 'MAC')
|
||||
|
||||
# some constants
|
||||
LASTLINE = '=========='
|
||||
NTPREF = '--CG注:'
|
||||
CLIPPATH = './My Clippings.txt' # /Volumes/Kindle/documents/My\ Clippings.txt
|
||||
STAT = 'NONE'
|
||||
DEBUG = 1 # 0 - INFO; 1 - DEBUG
|
||||
LOG2FILE = 1 # 0 - to stdio; 1 - to file
|
||||
|
||||
# log info
|
||||
logger = logging.getLogger()
|
||||
#formatter = logging.Formatter
|
||||
# ('%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s')
|
||||
formatter = logging.Formatter('')
|
||||
|
||||
if LOG2FILE:
|
||||
handler = logging.FileHandler("log")
|
||||
handler.setFormatter(formatter)
|
||||
logger.addHandler(handler)
|
||||
else:
|
||||
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
|
||||
|
||||
if DEBUG:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
#author & bookname info
|
||||
au = re.compile(
|
||||
r'''
|
||||
^\ufeff*
|
||||
(.+) \( #bookname
|
||||
(.+)\) #author
|
||||
''', flags=re.X )
|
||||
|
||||
# page & date info
|
||||
#\(\d\+-\{0,1}\d\+\).\+\(\d\{4}年\d\{1,2}月\d\{1,2}日\)\(星期.\) \(..\)\(\d\{1,2}:\d\{1,2}:\d\{1,2}\)
|
||||
da = re.compile(
|
||||
r'''
|
||||
\#
|
||||
(\d+-{0,1}\d+) #group1 - page
|
||||
.+
|
||||
(笔记|标注|书签) #group2 - type
|
||||
.+
|
||||
(\d{4}年\d{1,2}月\d{1,2}日) #group3 - xxxx年xx月xx日
|
||||
(星期.) #group4 - week
|
||||
\s
|
||||
(..) #group5 - pm/am
|
||||
(\d{1,2}:\d{1,2}:\d{1,2}) #group6 - time
|
||||
''', flags=re.X )
|
||||
|
||||
# input: section dict & and section index
|
||||
# return: dict
|
||||
# d = { 'bookname':bookname,
|
||||
# bookname: {
|
||||
# 'author':author
|
||||
# 'section0':{
|
||||
# 'type':'HL',
|
||||
# 'position':'123',
|
||||
# 'day':'2020年5月26日',
|
||||
# 'week':'星期二',
|
||||
# 'meridiem':'PM',
|
||||
# 'time':'10:26:31'
|
||||
# 'content':content }}}
|
||||
def parse_section(sec,idx):
|
||||
# 1. highlight over the picture, the content(#3 line) is empty, only two lines
|
||||
# 2. bookmark section only two lines
|
||||
# 3. other not correct format < 2
|
||||
if len(sec)<=2:
|
||||
return False
|
||||
|
||||
# parse #2 line
|
||||
section = defaultdict(dict)
|
||||
authinfo = sec[0]
|
||||
dateinfo = sec[1]
|
||||
content = sec[2] if len(sec)==3 else None
|
||||
|
||||
das = da.search(dateinfo)
|
||||
# type of section
|
||||
'''
|
||||
STAT :
|
||||
START - start line of section
|
||||
BM - section is a bookmark
|
||||
HL - section is a highlight
|
||||
NT - section is a note
|
||||
'''
|
||||
tpy = ('HL' if das.group(2)=='标注' else \
|
||||
('NT' if das.group(2)=='笔记' else 'BM'))
|
||||
pos = das.group(1)
|
||||
day = das.group(3)
|
||||
week = das.group(4)
|
||||
pmam = das.group(5)
|
||||
time = das.group(6)
|
||||
|
||||
# parse #1 line
|
||||
aus = au.search(authinfo)
|
||||
bookname = aus.group(1)
|
||||
author = aus.group(2)
|
||||
section[bookname]['author'] = author
|
||||
|
||||
section['bookname'] = bookname
|
||||
section[bookname][str(idx)] = {
|
||||
'type':tpy,
|
||||
'position':pos,
|
||||
'day':day,
|
||||
'week':week,
|
||||
'meridiem':pmam,
|
||||
'time':time,
|
||||
'content':content }
|
||||
|
||||
return section
|
||||
|
||||
# format output
|
||||
# input: books - dict
|
||||
# f - 'MD'
|
||||
# 'TXT'
|
||||
# 'JSON'
|
||||
# output:
|
||||
#
|
||||
def formmat_out(books,f='MD'):
|
||||
pass
|
||||
|
||||
# search clip, searching scope may be title/author/content
|
||||
# input: books - dict
|
||||
# s - key word
|
||||
# t - 'ALL'
|
||||
# 'HL'
|
||||
# 'BM'
|
||||
# 'NT'
|
||||
# p - 'ALL'
|
||||
# 'TITLE'
|
||||
# 'AUTHOR'
|
||||
# 'CONTENT'
|
||||
# output:
|
||||
#
|
||||
def search_clip(books, s, t='ALL', p='ALL'):
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 4 lines for each section seperated with '======='
|
||||
# so read 4 lines before '======='
|
||||
with open(CLIPPATH, 'r', encoding='utf8', errors='ignore') as f:
|
||||
books = defaultdict(dict)
|
||||
secd = defaultdict(dict)
|
||||
sidx = 0
|
||||
idx = 0
|
||||
sec = []
|
||||
STAT = 'START'
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
if re.match(r'^\s*$',line): continue
|
||||
idx += 1
|
||||
|
||||
if not re.search(LASTLINE,line):
|
||||
# content more than 1 line
|
||||
if idx>3:
|
||||
sec[2] += str(' '+line)
|
||||
logger.debug('idx {} {}'.format(idx, sec[2]))
|
||||
else:
|
||||
sec.append(line)
|
||||
logger.debug('idx {} {}'.format(idx, sec[idx-1]))
|
||||
else:
|
||||
idx = 0
|
||||
sidx += 1
|
||||
|
||||
# parsing section & fill data structure
|
||||
secd = parse_section(sec,sidx)
|
||||
|
||||
if secd:
|
||||
bn = secd['bookname']
|
||||
tpy = secd[bn][str(sidx)]['type']
|
||||
|
||||
books[bn]['author'] = secd[bn]['author']
|
||||
books[bn][str(sidx)] = secd[bn][str(sidx)]
|
||||
|
||||
if tpy=='NT' and books[bn][str(sidx-1)]['type']=='HL':
|
||||
books[bn][str(sidx-1)]['content'] += str(NTPREF+sec[2])
|
||||
else: # BM or not correct format section
|
||||
sidx -= 1
|
||||
|
||||
# initial section for next section loop
|
||||
sec = []
|
||||
|
||||
# print data with json format
|
||||
logger.debug(json.dumps(books, indent=4, sort_keys=True, ensure_ascii=False))
|
||||
|
||||
405
tclip.txt
Executable file
405
tclip.txt
Executable file
@@ -0,0 +1,405 @@
|
||||
庆余年(精校版) (猫腻)
|
||||
|
||||
- 您在位置 #33260 的书签 | 添加于 2020年1月12日星期日 下午10:37:10
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
==========
|
||||
|
||||
另一半中国史 (高洪雷)
|
||||
|
||||
- 您在位置 #2468 的书签 | 添加于 2020年1月12日星期日 下午11:09:06
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
==========
|
||||
|
||||
薛兆丰经济学讲义 (薛兆丰)
|
||||
|
||||
- 您在位置 #1408-1410的标注 | 添加于 2020年1月13日星期一 上午8:11:05
|
||||
|
||||
|
||||
|
||||
么到底什么叫边际?边际就是“新增”带来的“新增”。 例如,边际成本就是每新增一个单位产品所需要付出的新增成本;边际收入是每多卖一个产品能够带来的新增收入;边际产量是每新增一份投入所带来的新增产量;边际效用是每消耗一个单位的商品所能带来的新增享受。
|
||||
|
||||
==========
|
||||
|
||||
薛兆丰经济学讲义 (薛兆丰)
|
||||
|
||||
- 您在位置 #1419-1421的标注 | 添加于 2020年1月13日星期一 上午8:12:44
|
||||
|
||||
|
||||
|
||||
这就是边际效用递减的规律,它指的是每多消耗一个单位的商品,所能带来的新增的享受在递减。例如我们吃东西的时候,食物带给我们的边际效用,通常都是递减的。 边际效
|
||||
|
||||
==========
|
||||
|
||||
薛兆丰经济学讲义 (薛兆丰)
|
||||
|
||||
- 您在位置 #1419-1420的标注 | 添加于 2020年1月13日星期一 上午8:12:49
|
||||
|
||||
|
||||
|
||||
这就是边际效用递减的规律,它指的是每多消耗一个单位的商品,所能带来的新增的享受在递减。例如我们吃东西的时候,食物带给我们的边际效用,通常都是递减的。
|
||||
|
||||
==========
|
||||
|
||||
庆余年(精校版) (猫腻)
|
||||
|
||||
- 您在位置 #43335-43336的标注 | 添加于 2020年1月17日星期五 下午6:05:22
|
||||
|
||||
|
||||
|
||||
“身为帝者,不可无情,不可多情。”皇帝将脸转了过去,“对身周无情者,对天下无情,天下必乱;对身周多情者,必受其害,天下丧其主,亦乱。”
|
||||
|
||||
==========
|
||||
|
||||
庆余年(精校版) (猫腻)
|
||||
|
||||
- 您在位置 #48484-48484的标注 | 添加于 2020年1月19日星期日 下午8:00:29
|
||||
|
||||
|
||||
|
||||
:“园子里的护卫能掺多少人就掺多少人,我会派人盯着,
|
||||
|
||||
==========
|
||||
|
||||
庆余年(精校版) (猫腻)
|
||||
|
||||
- 您在位置 #49901-49901的标注 | 添加于 2020年1月20日星期一 下午7:57:10
|
||||
|
||||
|
||||
|
||||
叶灵儿叹了口
|
||||
|
||||
==========
|
||||
|
||||
庆余年(精校版) (猫腻)
|
||||
|
||||
- 您在位置 #63955 的书签 | 添加于 2020年1月25日星期六 下午12:15:00
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
==========
|
||||
|
||||
庆余年(精校版) (猫腻)
|
||||
|
||||
- 您在位置 #70589-70589的标注 | 添加于 2020年1月27日星期一 下午6:32:55
|
||||
|
||||
|
||||
|
||||
书生造反,十年不成,
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #2971-2975的标注 | 添加于 2020年1月28日星期二 下午4:30:12
|
||||
|
||||
|
||||
|
||||
关于病菌的历史作用的最令人生畏的例子,来自随同哥伦布1492年的航行而开始的欧洲人对美洲的征服。虽然被那些杀人不眨眼的西班牙征服者杀死的印第安人不计其数,但凶恶的西班牙病菌杀死的印第安人却要多得多。为什么在欧洲和美洲之间这种可怕的病菌的交流是这样不对等?为什么印第安人的疾病没有大批杀死西班牙入侵者,并传回欧洲,消灭掉欧洲95%的人口?
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #2990-2992的标注 | 添加于 2020年1月28日星期二 下午4:32:56
|
||||
|
||||
|
||||
|
||||
可以从数学上把病菌的传播定义为:由每一个原发病人传染的新的受害者的数目。这个数目的大小取决于每一个受害者能够传染给新的受害者的持续时间的长短,以及这种病菌从一个受害者转移到下一个受害者的效率的高低。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #2987-2988的标注 | 添加于 2020年1月28日星期二 下午4:33:12
|
||||
|
||||
|
||||
|
||||
病菌以各种稀奇古怪的方式使我们生病,如使我们得生殖器溃疡或腹泻。它这样做会得到什么样的演化利益呢?这似乎是特别令人费解而又自拆台脚的事,因为病菌杀死了它的宿主也就杀死了它自己。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #2994-2995的标注 | 添加于 2020年1月28日星期二 下午4:33:47
|
||||
|
||||
|
||||
|
||||
我们的疾病的许多“症状”,实际上不过是某种非常聪明的病菌在改变我们的身体或行为以便使我们帮助传播病菌时所表现出来的一些方式而已。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3018-3019的标注 | 添加于 2020年1月28日星期二 下午4:43:11
|
||||
|
||||
|
||||
|
||||
这就是为什么“使我们生病”是符合病菌的利益的
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3019-3019的标注 | 添加于 2020年1月28日星期二 下午4:43:17
|
||||
|
||||
|
||||
|
||||
但是,为什么病菌会演化出杀死宿主这种明显自拆台脚的策略呢?
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3062-3065的标注 | 添加于 2020年1月28日星期二 下午5:05:35
|
||||
|
||||
|
||||
|
||||
人类历史上最大的一次流行病是在第一次世界大战结束时杀死2100万人的流行性感冒。黑死病(腺鼠疫)在1346年到1352年间杀死了欧洲四分之一的人口,在有些城市里死亡人数高达70%。19世纪80年代初,当加拿大太平洋铁路修经萨斯喀彻温时,该省以前很少接触过白人及其病菌的印第安人死于肺结核的人数每年竟达到惊人的9%。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3073-3074的标注 | 添加于 2020年1月28日星期二 下午5:08:40
|
||||
|
||||
|
||||
|
||||
但由于这种病菌除了在活人体内是不可能生存的,所以人死了这种病也就消失了,直到又一批后代达到易受感染的年代——直到一个受到感染的外来人使一场流行病重新开始。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3183-3185的标注 | 添加于 2020年1月28日星期二 下午5:38:20
|
||||
|
||||
|
||||
|
||||
在第一年,黏液病毒在受到感染的兔子中造成了令人满意的(对澳大利亚农民来说)99.8%的死亡率。令这些农民感到失望的是,第二年兔子的死亡率下降到90%,最后下降到25%,使得要在澳大利亚完全消灭兔子的希望落空了
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3189-3191的标注 | 添加于 2020年1月28日星期二 下午5:40:07
|
||||
|
||||
|
||||
|
||||
一提起梅毒,我们立刻会联想到两种情况:生殖器溃疡和病情发展的十分缓慢,许多得不到治疗的患者要过好多年才会死去。然而,当梅毒于1495年首次在欧洲明确见诸记录时,它的脓疱通常从头部到膝部遍布全身,使脸上的肉一块块脱落,不消几个月就使人一命呜呼。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3189-3193的标注 | 添加于 2020年1月28日星期二 下午5:40:17
|
||||
|
||||
|
||||
|
||||
一提起梅毒,我们立刻会联想到两种情况:生殖器溃疡和病情发展的十分缓慢,许多得不到治疗的患者要过好多年才会死去。然而,当梅毒于1495年首次在欧洲明确见诸记录时,它的脓疱通常从头部到膝部遍布全身,使脸上的肉一块块脱落,不消几个月就使人一命呜呼。到1546年,梅毒已演化成具有我们今天所熟悉的那些症状的疾病。显然,同多发性黏液瘤病一样,为使患者活得长些而进行演化的那些梅毒螺旋体因此就能够把它们的螺旋体后代传染给更多的患者
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3196-3197的标注 | 添加于 2020年1月28日星期二 下午5:42:57
|
||||
|
||||
|
||||
|
||||
1519年科尔特斯率领600个西班牙人在墨西哥海岸登陆,去征服拥有好几百万人口的勇猛好战的阿兹特克帝国
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3203-3230的标注 | 添加于 2020年1月28日星期二 下午5:43:38
|
||||
|
||||
|
||||
|
||||
到1618年,墨西哥原来2000万左右的人口急剧减少到160万左右。 皮萨罗于1531年率领168个人在秘鲁海岸登陆去征服有几百万人口的印加帝国时,同样带来了一场浩劫。对皮萨罗来说幸运的而对印加人来说不幸的是,天花已在1526年由陆路到达,杀死了印加的很大一部分人口,包括瓦伊纳·卡帕克皇帝和他的指定继承人。我们已在第三章中看到,皇位空缺的结果是使瓦伊纳·卡帕克的另两个儿子阿塔瓦尔帕和瓦斯卡尔卷入了一场内战,使皮萨罗在征服这个分裂的帝国中坐收渔人之利。 当我们美国人想到存在于1492年的新大陆人口最多的社会时,出现在我们心头的往往只是阿兹特克人和印加人的那些社会。我们忘记了北美洲也曾在那最合逻辑的地方——密西西比河流域养活了人口众多的印第安人社会,我们今天的一些最好的农田就在这个地方。然而,在这种情况下,西班牙征服者对于摧毁这些社会并未起到直接的作用;一切都是由事先已经传播的欧亚大陆的病菌来完成的。当埃尔南多·德索托成为第一个欧洲征服者于1540年在美国东南部行军时,他碰到了两年前因当地居民死于流行病而被放弃的一些城镇旧址。这些流行病是从沿海地区印第安人那儿传来的,而这些印第安人又是被到沿海地区来的西班牙人感染的。西班牙人的这些病菌赶在这些西班牙人之前向内陆传播。 德索托仍然看得到密西西比河下游沿岸的一些人口稠密的印第安城镇。在这次远征结束后,又过了很久,欧洲人才又一次到达密西西比河河谷,但这时欧亚大陆的病菌已在北美洲安家落户,并不断向四处传播。到欧洲人下一次在密西西比河下游出现,即17世纪初法国的移民出现时,所有这些印第安人的大城镇已经消失殆尽。它们的遗迹就是密西西比河河谷的那些大土堆。直到最近我们才知道,构筑这种大土堆的社会,有许多在哥伦布到达新大陆时仍然大部分完好无损,它们的瓦解(可能是疾病造成的结果)是从1492年到欧洲人对密西西比河进行系统勘探这一段时间里发生的。 在我年轻的时候,美国小学生所受到的教育是:北美洲本来只有大约100万印第安人居住。把人数说得这样少,对于为白人的征服行为辩解是有用的,因为他们所征服的只不过是一个可以认为几乎是空无所有的大陆。然而,考古发掘和对最早的欧洲探险者所留下的关于我们海岸地区的描写的仔细研究现已表明,印第安人原来的人数在2000万左右。就整个新大陆来说,据估计在哥伦布来到后的一两个世纪中,印第安人口减少了95%。 主要的杀手是旧大陆来的病菌。印第安人以前从来没有接触过这些病菌,因此对它们既没有免疫能力,也没有遗传抵抗能力。天花、麻疹、流行性感冒和斑疹伤寒争先恐后地要做杀手的头把交椅。好像这些病还嫌不够似的,紧随其后的还有白喉、疟疾、流行性腮腺炎、百日咳、瘟疫、肺结核和黄热病。在无数情况下,白人实际上在当地亲眼目睹了病菌来到时所产生的破坏。例如,1837年,具有我们大平原最精致的文化之一的曼丹族印第安部落,从一艘自圣路易沿密苏里河逆流而上的轮船上感染了天花。一个曼丹人村庄里的人口在几个星期之内就从2000人急剧减少到不足40人。 虽然有十几种来自旧大陆的主要传染病在新大陆安家落户,但也许还没有一种主要的致命疾病从美洲来到欧洲。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3207-3208的标注 | 添加于 2020年1月28日星期二 下午5:46:47
|
||||
|
||||
|
||||
|
||||
当我们美国人想到存在于1492年的新大陆人口最多的社会时,出现在我们心头的往往只是阿兹特克人和印加人的那些社会。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3203-3203的标注 | 添加于 2020年1月28日星期二 下午5:49:23
|
||||
|
||||
|
||||
|
||||
到1618年,墨西哥原来2000万左右的人口急剧减少到160万左右。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3219-3223的标注 | 添加于 2020年1月28日星期二 下午5:50:17
|
||||
|
||||
|
||||
|
||||
在我年轻的时候,美国小学生所受到的教育是:北美洲本来只有大约100万印第安人居住。把人数说得这样少,对于为白人的征服行为辩解是有用的,因为他们所征服的只不过是一个可以认为几乎是空无所有的大陆。然而,考古发掘和对最早的欧洲探险者所留下的关于我们海岸地区的描写的仔细研究现已表明,印第安人原来的人数在2000万左右。就整个新大陆来说,据估计在哥伦布来到后的一两个世纪中,印第安人口减少了95%。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3223-3225的标注 | 添加于 2020年1月28日星期二 下午5:50:50
|
||||
|
||||
|
||||
|
||||
主要的杀手是旧大陆来的病菌。印第安人以前从来没有接触过这些病菌,因此对它们既没有免疫能力,也没有遗传抵抗能力。天花、麻疹、流行性感冒和斑疹伤寒争先恐后地要做杀手的头把交椅
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3225-3226的标注 | 添加于 2020年1月28日星期二 下午5:50:58
|
||||
|
||||
|
||||
|
||||
好像这些病还嫌不够似的,紧随其后的还有白喉、疟疾、流行性腮腺炎、百日咳、瘟疫、肺结核和黄热病
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3259-3261的标注 | 添加于 2020年1月28日星期二 下午5:54:00
|
||||
|
||||
|
||||
|
||||
梅毒、淋病、肺结核和流行性感冒于1779年随库克船长[5]到来,接着于1804年又发生了一场斑疹伤寒大流行以及后来的许多“较小的”流行病,把夏威夷的人口从1779年的50万左右减少到1853年的84000人。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3577-3578的标注 | 添加于 2020年1月28日星期二 下午6:47:19
|
||||
|
||||
|
||||
|
||||
正如人类学家克劳德·莱维-斯特劳斯所说的那样,古代文字的主要功能是“方便对别人的奴役”。非专职人员个人使用文字只是很久以后的事,因为那时书写系统变得比较简单同时也更富于表现力。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3597-3598的标注 | 添加于 2020年1月28日星期二 下午8:59:22
|
||||
|
||||
|
||||
|
||||
文字只在新月沃地、墨西哥、可能还有中国独立出现,完全是因为这几个地方是粮食生产在它们各自的半球范围内出现的最早地区
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3687-3688的标注 | 添加于 2020年1月28日星期二 下午9:36:29
|
||||
|
||||
|
||||
|
||||
问题似乎在他们的社会。否则又怎样来解释澳大利亚东北部的土著为什么没有采用弓箭?而他们见过与他们进行贸易的托雷斯海峡的岛上居民在使用弓箭。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3695-3697的标注 | 添加于 2020年1月28日星期二 下午9:38:01
|
||||
|
||||
|
||||
|
||||
1942年,当第二次世界大战仍在进行时,美国政府制定了曼哈顿计划,其显而易见的目的就是抢在纳粹之前发明出为制造原子弹所需要的技术。3年后,这个计划成功了,共花去20亿美元(相当于今天的200多亿美元)
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3716-3717的标注 | 添加于 2020年1月28日星期二 下午9:43:39
|
||||
|
||||
|
||||
|
||||
特利布·戴姆勒得以在一辆自行车上安装了一台发动机从而制造了第一辆摩托车
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3730-3732的标注 | 添加于 2020年1月28日星期二 下午9:45:48
|
||||
|
||||
|
||||
|
||||
从专利法律师观点看,最佳的发明就是全无先例的发明,就像雅典娜整个地从宙斯的前额跳出来一样[3]。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3750-3751的标注 | 添加于 2020年1月28日星期二 下午9:50:58
|
||||
|
||||
|
||||
|
||||
从来就没有这样的人。所有公认的著名发明家都有一些有本领的前人和后人,而且他们是在社会有可能使用他们的成果的时候对原来的发明作出改进的
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3827-3828的标注 | 添加于 2020年1月28日星期二 下午11:58:58
|
||||
|
||||
|
||||
|
||||
在现代的西方,保护发明者的所有权的专利权和其他财产法奖励发明,而在现代的中国,缺乏这种保护妨碍了发明
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3834-3835的标注 | 添加于 2020年1月28日星期二 下午11:59:42
|
||||
|
||||
|
||||
|
||||
对各种观点和异端观点的宽容促进了创新,而浓厚的传统观点(如中国强调中国古代的经典)则扼杀了创新
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3841-3841的标注 | 添加于 2020年1月29日星期三 上午12:01:16
|
||||
|
||||
|
||||
|
||||
在整个历史上,战争常常是促进技术革新的主要因素
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3843-3844的标注 | 添加于 2020年1月29日星期三 上午12:02:15
|
||||
|
||||
|
||||
|
||||
强有力的集中统一的政府在19世纪后期的德国和日本对技术起了推动作用,而在公元1500年后的中国则对技术起了抑制作用。
|
||||
|
||||
==========
|
||||
|
||||
枪炮、病菌与钢铁 : 人类社会的命运 (世纪人文系列丛书·开放人文) (贾雷德·戴蒙德)
|
||||
|
||||
- 您在位置 #3844-3846的标注 | 添加于 2020年1月29日星期三 上午12:04:24
|
||||
|
||||
|
||||
39
tdict.py
Normal file
39
tdict.py
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
|
||||
#############################################
|
||||
## PROGRAM: tdict.py
|
||||
## AUTHOR: Chengan 20200526
|
||||
## douboer@gmail.com
|
||||
## test multi-key dict
|
||||
#############################################
|
||||
|
||||
import re
|
||||
from collections import defaultdict
|
||||
|
||||
t = {'a':{'b':{'c':1}}}
|
||||
t['a']['b']['c']=2
|
||||
t['a']=2
|
||||
print(t)
|
||||
|
||||
t1 = {'a':{'b':{'c':'3'}}}
|
||||
t2 = t1
|
||||
print(t2)
|
||||
|
||||
t3 = {'b':{'c':'4'}}
|
||||
t4 = defaultdict(dict)
|
||||
t4['a'] = t3
|
||||
print(t4)
|
||||
|
||||
t4['a1']['b2'] = {'c3':'5'}
|
||||
print(t4)
|
||||
t4['a1']['d2'] = {'c3':'6'}
|
||||
print(t4)
|
||||
t4['a1']['e2'] = {'c3':'7'}
|
||||
print(t4)
|
||||
|
||||
t4['b1']['b2'] = {'b5':1}
|
||||
print(t4)
|
||||
|
||||
t4['b1']['b2']['b3'] = {'b5':1}
|
||||
print(t4)
|
||||
|
||||
46
tfile.py
Normal file
46
tfile.py
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
import re
|
||||
|
||||
#author & bookname info
|
||||
#庆余年(精校版) (猫腻)
|
||||
au = re.compile(
|
||||
r'''
|
||||
^\ufeff
|
||||
(.+) \( #bookname
|
||||
(.+)\) #author
|
||||
''', flags=re.X )
|
||||
|
||||
# page & date info
|
||||
# 您在位置 #4286 的笔记 | 添加于 2020年1月30日星期四 上午10:26:31^M
|
||||
# re.X(VERBOSE): 详细模式。这个模式下正则表达式可以是多行,忽略空白字符,并可以加入注释
|
||||
#\(\d\+-\{0,1}\d\+\).\+\(\d\{4}年\d\{1,2}月\d\{1,2}日\)\(星期.\) \(..\)\(\d\{1,2}:\d\{1,2}:\d\{1,2}\)
|
||||
da = re.compile(
|
||||
r'''
|
||||
\#
|
||||
(\d+-{0,1}\d+) #group1 - page
|
||||
.+
|
||||
(\d{4}年\d{1,2}月\d{1,2}日) #group2 - xxxx年xx月xx日
|
||||
(星期.) #group3 - week
|
||||
\s
|
||||
(..) #group4 - pm/am
|
||||
(\d{1,2}:\d{1,2}:\d{1,2}) #group5 - time
|
||||
''', flags=re.X )
|
||||
|
||||
with open('./My Clippings.t.txt', 'r', encoding='utf8', errors='ignore') as f:
|
||||
for line in f.readlines():
|
||||
f = False
|
||||
if not f:
|
||||
aus = au.search(line)
|
||||
if aus:
|
||||
print("book:",aus.group(1),"auth:",aus.group(2))
|
||||
f = True
|
||||
|
||||
if not f:
|
||||
das = da.search(line)
|
||||
if das:
|
||||
print(das.group(1),
|
||||
das.group(2),
|
||||
das.group(3),
|
||||
'PM' if das.group(4)=="下午" else 'AM')
|
||||
f = True
|
||||
|
||||
19
tlog.py
Normal file
19
tlog.py
Normal file
@@ -0,0 +1,19 @@
|
||||
|
||||
# CG test logging
|
||||
|
||||
import logging
|
||||
import os.path
|
||||
import time
|
||||
|
||||
logger = logging.getLogger()
|
||||
logging.basicConfig(format='%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s',
|
||||
level=logging.INFO)
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
tt = 'xxx'
|
||||
tt1 = 'yyy'
|
||||
logger.debug('this is a logger debug message {} {}'.format(tt,tt1))
|
||||
logger.info('this is a logger info message')
|
||||
logger.warning('this is a logger warning message')
|
||||
logger.error('this is a logger error message')
|
||||
logger.critical('this is a logger critical message')
|
||||
Reference in New Issue
Block a user