已更新python,見新博客 http://www.hrwhisper.me/archives/708
寫作背景:
南京決賽比賽完那天晚上寫的。
使用方法:
將My Clippings.txt 放在e盤根目錄下即可。
輸出也在e盤根目錄。
設計思想:
以下面的筆記爲例。在每一段筆記後面都是==========分隔。
同樣書名的也會分隔。
而kindle對於不同書只會直接往下繼續寫。要是同時看幾本書就亂七八糟的。
嗯so~
讀取第一行作爲書名判斷,第二行無用數據拋棄掉。
接下來的正文讀取到==========爲止。
然後按相同書名的輸出即可。
當然如果你在標註的同時寫了筆記。。我這個功能沒做,因爲Kpw2打字蛋疼死!
嗯還有就是中文處理有點問題,先不修復了。
反正能用。
行者無疆 (餘秋雨)
- 您在位置 #1635-1636的標註 | 添加於 2014年8月26日星期二 下午11:33:04
看城市潛力,擁擠的市中心不是標誌。市中心是一個旋渦,把衰草污濁旋到了外緣。真正的潛力忽閃在小巷的窗臺下,近郊的庭園裏。
==========
行者無疆 (餘秋雨)
- 您在位置 #1642-1643的標註 | 添加於 2014年8月26日星期二 下午11:33:33
這就像寫作,當形容詞如女郎盛妝、排比句如情人並肩,那就一定尚未進入文章之道。文章的極致如老街疏桐,桐下舊座,座間閒談,精緻散漫。 城市這篇文章,也是這樣。
==========
源代碼:
//kindle筆記簡單分類。
//by hrwhisper 2014.8.21
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int MAXLINELENGTH = 10000; //max note length
const int MAXBOOK = 1000; //max book numbers
char line[MAXLINELENGTH];
const char newNoteTarget[] = "==========";
int curBookLen = 0;//current read book numbers;
int curNoteLen = 0; //current note numbers;
char bookName[MAXBOOK][MAXLINELENGTH]; //restore all bookName
char noteContent[MAXBOOK][MAXLINELENGTH << 4]; //all note content
char curBookName[MAXBOOK]; //current book name;
vector<int> nameIndex[MAXBOOK]; //the name includes indexs in the same line.
int curBookNameIndex(char *name){
int id=-1;
for (int i = 0; i < curBookLen; i++)
{
if (strcmp(name, bookName[i]) == 0)
{
id = i;
return id;
}
}
if (id == -1)
{
id=curBookLen++;
strcpy(bookName[id], name);
}
return id;
}
int main()
{
freopen("E:\\My Clippings.txt","r",stdin);
freopen("E:\\result.txt", "w", stdout);
while (gets(curBookName) != NULL)
{
int id = curBookNameIndex(curBookName);
printf("%s\n", curBookName);
nameIndex[id].push_back(curNoteLen);
gets(line); //這是無用數據的,因爲是日期
while (gets(line), strcmp(line, newNoteTarget) != 0)
{
strcat(noteContent[curNoteLen], line);
}
//printf("%s\n", curBookName);
curNoteLen++;
}
for (int i = 0; i < curBookLen; i++)
{
puts(bookName[i]);
printf("\n");
for (int j = 0; j < nameIndex[i].size(); j++)
{
printf("%s",noteContent[ nameIndex[i][j] ]);
printf("\n\n");
}
printf("\n\n\n\n\n%s\n",newNoteTarget);
}
return 0;
}