owned this note
owned this note
Published
Linked with GitHub
# LAWSHACK2021
[TOC]
## 爬蟲
1.使用 request.get
### 正則表達RE
[參考](https://www.youtube.com/watch?v=sa-TUpSx1JA)

[play](https://regex101.com/?fbclid=IwAR2ce8bBrNEeqcTLSiuFv-dZqijjgW-eYg_lQN43MBmcd0cJpMCQSVLqFb4)
:::info
\w = 文字
+ :
re.compile(r"臺\w+\s?\w*院")>> 臺 任何文字(**\w**) 1 or more(**+**) 有空格(**\s**) 0 or 1 空格(**?**) 有文字(**\w**) 0 or more(**X**)
:::
## NLP 段字
:::info
!pip install ArticutAPI
from ArticutAPI import Articut
from pprint import pprint
username = "" #這裡填入您在 https://api.droidtown.co 使用的帳號 email。若使用空字串,則預設使用每小時 2000 字的公用額度。
apikey = "" #這裡填入您在 https://api.droidtown.co 登入後取得的 api Key。若使用空字串,則預設使用每小時 2000 字的公用額度。
articut = Articut(username, apikey)
inputSTR = str(rows)
resultDICT = articut.parse(inputSTR)
pprint(resultDICT)
:::
## 參考資料
### 警大
[警大資料](https://www.cprc.moj.gov.tw/media/8796/4425145230.pdf?mediaDL=true&fbclid=IwAR29ybIT7RXAY2nHcjSkamFia19zYU4QXqZFcx4lQIwcPedUgpmC2hsOgzs)
### 成大資料
[訴訟爬蟲](http://www.aclclp.org.tw/rocling/2020/1010.pdf)




## 判決書
1
分三類
坦承判刑
自首
或是坦承犯行
1. 詐騙的方法有的判決不只一種
2. 判決結果可能要分開(有期徒刑、拘役、罰金、勞役)
3. 同一判決書有兩個(含)以上的被告
通常主文內會提及
共犯的部分
共犯含幫助和教唆犯
拘役正常60
最高120
易服勞役和易服社會勞動應該可以歸為一類
## API 使用
``` =python
def main(inputSTR):
resultDICT = articut.parse(inputSTR)
return resultDICT
def textRank(resultDICT):
textRankLIST = articut.analyse.textrank(resultDICT)
return textRankLIST
#權重法律
def tfidf(resultDICT):
keywordLIST = articut.analyse.extractTags(resultDICT, topK=3)
return keywordLIST
#犯罪
def crime(resultDICT):
crimeLIST = articut.LawsToolkit.getCrime(resultDICT)
return crimeLIST
#罪責
def penalty(resultDICT):
penaltyLIST = articut.LawsToolkit.getPenalty(resultDICT)
return penaltyLIST
#返回 犯的法律條文
def article(resultDICT):
articleLIST = articut.LawsToolkit.getLawArticle(resultDICT)
return articleLIST
#動詞
def Action (resultDICT):
VerbLIST = articut.getVerbStemLIST(resultDICT)
return VerbLIST
```
:::info
回傳的數值 這邊比較像數值 回傳
``` =python
def pos2UniversalPOS(pos):
if pos in ['FUNC_inner']:
return 'ADP'
if pos in ['FUNC_determiner']:
return 'DET'
if pos in ['AUX', 'MODAL']:
return 'AUX'
if pos in ['ASPECT', 'FUNC_negation']:
return 'PART'
if pos in ['FUNC_inter', 'FUNC_conjunction']:
return 'CONJ'
if pos in ['ENTITY_person', 'ENTITY_pronoun']: #被告或法官
return 'PERSON'
if pos in ['TIME_justtime', 'RANGE_period']:
return 'TIME'
if pos in ['QUANTIFIER', 'ENTITY_measurement']:
return 'QUANTITY'
if pos in ['MODIFIER', 'MODIFIER_color', 'FUNC_modifierHead']:
return 'ADJ'
if pos in ['LOCATION', 'RANGE_locality', 'KNOWLEDGE_place', 'KNOWLEDGE_addTW', 'KNOWLEDGE_route']:
return 'LOC'
if pos in ['VerbP', 'ACTION_verb', 'ACTION_lightVerb', 'ACTION_quantifiedVerb']:
return 'VERB'
if pos in ['TIME_day', 'TIME_week', 'TIME_month', 'TIME_season', 'TIME_year', 'TIME_decade', 'TIME_holiday']:
return 'DATE'
if pos in ['IDIOM', 'ENTITY_noun', 'ENTITY_nouny', 'ENTITY_oov', 'ENTITY_NP', 'ENTITY_nounHead', 'ENTITY_num', 'ENTITY_classifier', 'ENTITY_possessive']:
return 'NOUN'
這邊需要去作出判斷
文字
```
:::
### 發想
1. 這邊會想發想是因為最近詐騙事件頻傳
2. 造成我們會想要把 資訊更明瞭