مكتبة 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 الذي يجب استخدامه ، وإلا ، فإن TextDescripcriptives ستقوم بتنزيل معرض مناسب يعتمد على 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 القياسي. المكونات المتاحة هي وصفية _stats ، قابلية القراءة ، التبعية _distance ، pos_proportions ، التماسك ، والجودة المسبقة مع textdescriptives/ .
إذا كنت ترغب في إضافة جميع المكونات ، فيمكنك استخدام 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 يتضمن TextDescriptivives وظائف الراحة لاستخراج المقاييس من Doc إلى Pandas DataFrame أو قاموس.
td . extract_dict ( doc )
td . extract_df ( doc )| نص | first_order_coherence | الثانية _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_grad | الضباب الدخاني | gunning_fog | Automated_Readability_Index | COLEMAN_LIAU_INDEX | lix | ريكس | n_stop_words | alpha_ratio | mean_word_length | doc_length | نسبة _ellipsis | نسبة _bullet_points | DIPPLICITE_LINE_CHR_FRACTION | DIPPLICITY_PARAGRAPH_CHR_FRACTION | DiPlicate_5-gram_chr_fraction | DiPlicate_6-gram_chr_fraction | DIPPLICITE_7-GRAM_CHR_FRACTION | DiPlicate_8-gram_chr_fraction | DiPlicate_9-gram_chr_fraction | DIPPLICITE_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 | REPENCED_DISTANCE_STD | prop_adjacent_dependency_relation_mean | prop_adjacent_dependency_relation_std | token_length_mean | token_length_median | token_length_std | sentence_length_mean | sentence_length_median | sentence_length_std | Syllables_per_token_mean | Syllables_per_token_median | Syllables_per_token_std | n_tokens | n_unique_tokens | نسبة _nique_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 |
يحتوي TextDescriptivives على وثائق مفصلة بالإضافة إلى سلسلة من البرامج التعليمية للمغادرة في Jupyter. توجد جميع البرامج التعليمية في مجلد docs/tutorials ويمكن العثور عليها أيضًا على موقع الوثائق.
| الوثائق | |
|---|---|
| ابدء | الأدلة والتعليمات حول كيفية استخدام موصوفات النص وميزاته. |
| ؟ التجريبي | عرض مباشر للوصفات النصية. |
| ؟ دروس | برامج تعليمية مفصلة حول كيفية الاستفادة القصوى من الوصفات النصية |
| ؟ الأخبار و changelog | إضافات جديدة ، التغييرات وتاريخ الإصدار. |
| ؟ مراجع API | المرجع التفصيلي لواجهة برمجة تطبيقات TextDescriptive. بما في ذلك وثائق الوظيفة |
| ؟ ورق | preprint من ورقة textDescriptives. |