###### tags: `中山` `文字分析平台`
# 檔案整理
## `run.py`
### Celery initialize
* 取得字典
* `def get_dictionary(id, username, lexicon_id)`
* 處理全部
* `def parse_all(task_id, articles_ids)`
* 切分data (batch_size與batch_number不可同時指定)
* `def data_split(data = [], batch_size=None, batch_number=None)`
* 資料及切割
* `def data_seg(username, coll_name)`
* 開始執行任務
* `def start_process_a_task(username)`
---
### 登入/登出
* 載入使用者資訊
* `def load_user(user_id)`
* 登入
* /login
* `def login()` `@login_manager.user_loader`
* login_page.html
* 登出
* /logout
* `def logout()`
* redirect("/login")
* 變更密碼頁面
* /pwd_manage
* `def pwd_manage()`
* reset_password.html
* 確認密碼
* /check_password
* `def check_password()`
* 重設密碼
* /reset_password
* `def reset_password()`
---
### 文件集
* 文件集管理
* / OR /index OR /coll_manage
* `def coll_manage()`
* coll_manage.html
* 特定文件集的資料畫面
* /coll_manage/<string:coll_id>
* `def coll_detail(coll_id)`
* 選擇文件集
* /select/<string:coll_name>
* `def cookie_insertion(coll_name)`
---
### 資料新增(Data Input)
* 新增資料選擇我們提供的文章資料庫
* /data_input/<string:data_source>/<string:coll_id>
* `def input_data_source(data_source=None, coll_id=None)`
* 導向新增資料畫面
* input.html
* iframe for 全部的資料來源
* /form_data_source/<string:data_source>
* 從選擇資料來源的資料庫撈取資料
* `def form_data_source(data_source=None)`
* 自行上傳檔案
* /data_input/csv/<string:coll_id>
* `def input_csv(coll_id=None)`
* iframe for CSV資料上傳
* /csv_form
* `def csv_form()`
---
### 參數&字典 設定
* 文字處裡參數頁面
* /parameter OR /parameter/<string:dict_id>
* `def parameter(dict_id="")`
* parameter.html
* 參數設定iframe
* /parameter_form
* /parameter_form/<string:dict_id>
* `def parameter_form`
* /iframe/parameter_form.html
* 字典管理(按"點擊查看自訂字典詳細資訊..."||"斷詞字典管理"進來選擇字典畫面)
* /parameter/dictionary (尚未選擇字典)
* `def para_dictionary()`
* dictionary.html
* /parameter/dictionary/<string:dict_id> (已選擇字典)
* `def dictionary_detail(dict_id)`
* dict_detail.html
---
### 抽樣處理
* Sample process 處理畫面
* /sample_process
* `def sample_process()`
* sample_process.html
### 全部處理
* /full_process
* `def full_process()`
* full_process.html
---
### 資料探索
* /result_output
* `def result_output()`
* result_output.html
* 自訂輸出類別
* /category_dictionary
* `def category_dictionary()`
* category_dictionary.html
* 查看stopword
* /stopword_sentimentLexicon
* `def stopword_sentimentLexicon()`
* stopword_sentimentLexicon.html
* 新增自訂類別
* /create_new_category
* `def create_new_category()`
* 更新類別
* /update_category
* `def update_new_category()`
* 重置情緒字典
* /reset_sentiment_lexicon
* `def reset_sentiment_lexicon()`
* 更新情緒 字典
* /update_sentiment_lexicon
* `def update_sentiment_lexicon_api()`
---
### iframe
* /dicitionary_form
* `def dicitionary_form()`
* **render_template**:
* iframe/dicitionary_form.html
---
### Web API
* 新增描述
* /add_description/<string:doc_type>
* `def add_description(doc_type)`
* **redirect**:
* "/coll_manage/"+doc_id
* "/parameter/dictionary/"+doc_id
* 更新字典單字
* /update_token_lexicon/<string:update_type>
* `def update_token_lexicon_vocabularies(update_type)`
* **redirect**:
* "/parameter/dictionary/"+lexicon_id
* **redirect**:
* /sample_process
* 新增文件集
* /create_new_collection
* `def create_new_collection()`
* 新增字典
* /create_new_token_dict
* `def create_new_token_dict()`
* 刪除字典
* /delete_token_dict
* `def delete_token_dict()`
* 刪除文件集
* /delete_new_collection
* `def delete_new_collection()`
* 新增任務
* /add_task
* `def insert_task()`
* 重新啟動任務
* /restart_task
* `def restartTask()`
* 上傳csv檔
* /upload_csv_file
* `def upload_csv_file()`
* 新增爬蟲任務
* /insert_crawl_task/<string:resource>/<string:coll_id>
* `def insert_crawl_task(resource, coll_id)`
* 隨機抽樣
* /random_sample/<string:amount>
* `def random_sample(amount)`
* 根據id隨機抽樣
* /random_sample_by_ids
* `def random_sample_by_ids()`
* 搜尋字典單字
* /search_token_lexicon
* `def search_token_lexicon()`
* 任務狀態更新
* /task_state_update
* `def task_state_update()`
* 根據時間搜尋文章數量
* /arts_count_by_date
* `def arts_count_by_date()`
* 爬蟲任務數量
* /crawl_task_count/<string:data_source>
* `def crawl_task_count(data_source)`
* 論壇數量
* /get_forum_interval/<string:data_source>/<string:forum>
* `def get_forum_interval(data_source, forum)`
---
### NLP API
* 文章斷句
* /sentence_seg
* `def sentence_seg_api()`
* 文章斷詞
* /tokenizer
* `def tokenizer_api()`
* 詞性標註
* /postagger
* `def postagger_api()`
* 獲取類別字典
* /get_category_lexicon/<username>
* `def getCategoryLexicon(username)`
* 獲取情緒字典
* /get_sentiment_lexicon/<username>
* `def getSentimentLexicon(username)`
* 輸出
* /output
* `def output()`
* **render_template("output.html")**
* 獲取文件集的日期區間
* /getMinMaxDate
* `def getMinMaxDate()`
* 獲取MetaData
* /getMetaData
* `def getMetaData()`
* **render_template('output_preview.html',data=preview)**
* 獲取留言
* /getComment
* `def getComment()`
* **render_template('output_preview.html', data=preview)**
* 資料預覽
* /getPreview
* `def getPreview()`
* **render_template('output_preview.html',data=preview)**
* 檔案下載
* /download/<filename>
* `def download(filename)`
* 下載csv檔
* /download_example_csv/
* `def download_example_csv()`