ไลบรารี Python สำหรับการคำนวณตัวชี้วัดที่หลากหลายจากข้อความโดยใช้ Spacy V.3 ส่วนประกอบและส่วนขยาย
pip install textdescriptives
textdescriptives/{metric_name} องค์ประกอบ coherence ใหม่ใหม่สำหรับการคำนวณการเชื่อมโยงความหมายระหว่างประโยคดูเอกสารสำหรับการสอนและข้อมูลเพิ่มเติม! ใช้ extract_metrics เพื่อแยกตัวชี้วัดที่คุณต้องการอย่างรวดเร็ว หากต้องการดูวิธีการที่มีอยู่คุณสามารถเรียกใช้:
import textdescriptives as td
td . get_valid_metrics ()
# {'quality', 'readability', 'all', 'descriptive_stats', 'dependency_distance', 'pos_proportions', 'information_theory', 'coherence'} ตั้งค่าพารามิเตอร์ spacy_model เพื่อระบุว่าโมเดล Spacy ที่จะใช้มิฉะนั้น textDescriptives จะทำการดาวน์โหลดโดยอัตโนมัติที่เหมาะสมตาม lang หากมีการตั้งค่า lang แล้ว spacy_model ไม่จำเป็นและในทางกลับกัน
ระบุตัวชี้วัดที่จะสกัดในอาร์กิวเมนต์ metrics None สารสกัดตัวชี้วัดทั้งหมด
import textdescriptives as td
text = "The world is changed. I feel it in the water. I feel it in the earth. I smell it in the air. Much that once was is lost, for none now live who remember it."
# will automatically download the relevant model (´en_core_web_lg´) and extract all metrics
df = td . extract_metrics ( text = text , lang = "en" , metrics = None )
# specify spaCy model and which metrics to extract
df = td . extract_metrics ( text = text , spacy_model = "en_core_web_lg" , metrics = [ "readability" , "coherence" ]) ในการรวมเข้ากับท่อส่งสัญญาณอื่น ๆ ให้นำเข้าไลบรารีและเพิ่มส่วนประกอบลงในไปป์ไลน์ของคุณโดยใช้ไวยากรณ์ Spacy มาตรฐาน ส่วนประกอบที่มีอยู่คือ descriptive_stats , ความสามารถในการอ่าน , การพึ่งพา _distance , pos_proportions , การเชื่อมโยงกัน และ คุณภาพ นำหน้าด้วย textdescriptives/
หากคุณต้องการเพิ่มส่วนประกอบทั้งหมดคุณสามารถใช้ Shorthand textdescriptives/all
import spacy
import textdescriptives as td
# load your favourite spacy model (remember to install it first using e.g. `python -m spacy download en_core_web_sm`)
nlp = spacy . load ( "en_core_web_sm" )
nlp . add_pipe ( "textdescriptives/all" )
doc = nlp ( "The world is changed. I feel it in the water. I feel it in the earth. I smell it in the air. Much that once was is lost, for none now live who remember it." )
# access some of the values
doc . _ . readability
doc . _ . token_length TextDescriptives รวมถึงฟังก์ชั่นความสะดวกสบายสำหรับการแยกการวัดจาก Doc ไปยัง Pandas Dataframe หรือพจนานุกรม
td . extract_dict ( doc )
td . extract_df ( doc )| ข้อความ | first_order_coherence | second_order_coherence | pos_prop_det | pos_prop_noun | pos_prop_aux | pos_prop_verb | pos_prop_punct | pos_prop_pron | pos_prop_adp | pos_prop_adv | pos_prop_sconj | flesch_reading_ease | flesch_kincaid_grade | หมอกควัน | gunning_fog | Automated_readability_index | coleman_liau_index | lix | ริกซ์ | n_stop_words | alpha_ratio | mean_word_length | doc_length | สัดส่วน _ellipsis | สัดส่วน _bullet_points | duplicate_line_chr_fraction | duplicate_paragraph_chr_fraction | duplicate_5-gram_chr_fraction | duplicate_6-gram_chr_fraction | duplicate_7-gram_chr_fraction | duplicate_8-gram_chr_fraction | duplicate_9-gram_chr_fraction | duplicate_10-gram_chr_fraction | top_2-gram_chr_fraction | top_3-gram_chr_fraction | top_4-gram_chr_fraction | สัญลักษณ์ _#_ to_word_ratio | มี _lorem ipsum | Passed_quality_check | การพึ่งพา _distance_mean | Dependency_distance_std | prop_adjacent_dependency_relation_mean | prop_adjacent_dependency_relation_std | token_length_mean | token_length_median | token_length_std | sentence_length_mean | SESTENCE_LENGTH_MEDIAN | SESTENCE_LENGTH_STD | Syllables_per_token_mean | Syllables_per_token_median | Syllables_per_token_std | n_tokens | n_unique_tokens | สัดส่วน _unique_tokens | n_characters | n_sentences | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | โลกเปลี่ยนไป (... ) | 0.633002 | 0.573323 | 0.097561 | 0.121951 | 0.0731707 | 0.170732 | 0.146341 | 0.195122 | 0.0731707 | 0.0731707 | 0.0487805 | 107.879 | -0.0485714 | 5.68392 | 3.94286 | -2.45429 | -0.708571 | 12.7143 | 0.4 | 24 | 0.853659 | 2.95122 | 41 | 0 | 0 | 0 | 0 | 0.232258 | 0.232258 | 0 | 0 | 0 | 0 | 0.0580645 | 0.174194 | 0 | 0 | เท็จ | เท็จ | 1.77524 | 0.553188 | 0.457143 | 0.0722806 | 3.28571 | 3 | 1.54127 | 7 | 6 | 3.09839 | 1.08571 | 1 | 0.368117 | 35 | 23 | 0.657143 | 121 | 5 |
TextDescriptives มีเอกสารรายละเอียดรวมถึงชุดของการสอนสมุดบันทึก Jupyter บทช่วยสอนทั้งหมดอยู่ในโฟลเดอร์ docs/tutorials และยังสามารถพบได้ในเว็บไซต์เอกสาร
| เอกสาร | |
|---|---|
| เริ่มต้น | คำแนะนำและคำแนะนำเกี่ยวกับวิธีการใช้ TextDescriptives และคุณสมบัติของมัน |
| ? การสาธิต | การสาธิตสดของข้อความ |
| - บทเรียน | แบบฝึกหัดโดยละเอียดเกี่ยวกับวิธีการใช้ประโยชน์สูงสุดจาก textdescriptives |
| - ข่าวและการเปลี่ยนแปลง | การเพิ่มเติมใหม่การเปลี่ยนแปลงและประวัติเวอร์ชัน |
| - API อ้างอิง | การอ้างอิงโดยละเอียดสำหรับ API ของ TextDescriptive รวมถึงเอกสารฟังก์ชั่น |
| - กระดาษ | preprint ของกระดาษ textdescriptives |