Nltk: فشل تقسيم الجمل في بعض الحالات الزاوية

تم إنشاؤها على ٢٦ أغسطس ٢٠١٩  ·  3تعليقات  ·  مصدر: nltk/nltk

أفهم مدى صعوبة تقسيم الجمل التي تحتوي على اختصارات وأن إضافة الاختصارات يمكن أن يكون لها عيوب ، كما هو موضح بشكل جيد في # 2154. ومع ذلك ، فقد عثرت على بعض القضايا الجانبية التي أود أن أسأل عنها. يبدو أن استخدام أي مما يلي

  • على سبيل المثال
  • بمعنى آخر
  • وآخرون.

في الجملة سوف يقسم الجملة بطريقة خاطئة.

مثال على سبيل المثال

>>> sentence = ("Even though exempli gratia and id est are both Latin "
                "(and therefore italicized), no need to put e.g. or i.e. in "
                "italics when they’re in abbreviated form.")
>>> sent_tokenize_list = sent_tokenize(sentence)                                                                                                                           

>>> sent_tokenize_list                                                                                                                                            
['Even though exempli gratia and id est are both Latin (and therefore italicized), no need to put e.g.',
 'or i.e.',
 'in italics when they’re in abbreviated form.']

مثال على et al.

>>> from nltk.tokenize import sent_tokenize
>>> sentence = ("If David et al. get the financing, we can move forward "
                "with the prototype. However, this is very unlikely be cause "
                "they did not publish sufficiently last year.")
>>> sent_tokenize_list = sent_tokenize(sentence)
>>> sent_tokenize_list
['If David et al.',
 'get the financing, we can move forward with the prototype.',
 'However, this is very unlikely because they did not publish sufficiently last year.']

على الكمبيوتر المحمول الخاص بي ، أستخدم 3.4.5 nltk.__version__ .

كما أرى ، تختلف هذه المشكلة عن # 2154 لأنها اختصارات معروفة وشائعة الاستخدام (خاصة في الدوائر الأكاديمية).

nice idea tokenizer

التعليق الأكثر فائدة

اختراق سريع ، باتباع # 2154

>>> import nltk
>>> punkt = nltk.data.load('tokenizers/punkt/english.pickle')
>>> punkt._params.abbrev_types.add('al')
>>> text = 'If David et al. get the financing, we can move forward with the prototype. However, this is very unlikely be cause they did not publish sufficiently last year.'
>>> punkt.tokenize(text)
['If David et al. get the financing, we can move forward with the prototype.', 
'However, this is very unlikely be cause they did not publish sufficiently last year.']

ولكن ربما تكون فكرة جيدة أن يكون لديك رمز محسن للجملة (# 2008 ، # 1214) مثل ما فعلناه بكلمة tokenizer (# 2355).

على سبيل المثال ، يمكننا بسهولة كل nltk.corpus.nonbreaking_prefixes إلى punkt._params.abbrev_types كخطوة أولى.

ال 3 كومينتر

اختراق سريع ، باتباع # 2154

>>> import nltk
>>> punkt = nltk.data.load('tokenizers/punkt/english.pickle')
>>> punkt._params.abbrev_types.add('al')
>>> text = 'If David et al. get the financing, we can move forward with the prototype. However, this is very unlikely be cause they did not publish sufficiently last year.'
>>> punkt.tokenize(text)
['If David et al. get the financing, we can move forward with the prototype.', 
'However, this is very unlikely be cause they did not publish sufficiently last year.']

ولكن ربما تكون فكرة جيدة أن يكون لديك رمز محسن للجملة (# 2008 ، # 1214) مثل ما فعلناه بكلمة tokenizer (# 2355).

على سبيل المثال ، يمكننا بسهولة كل nltk.corpus.nonbreaking_prefixes إلى punkt._params.abbrev_types كخطوة أولى.

كنت على وشك إضافة مشكلة على هذا المنوال ، لكنني رأيت أنك قد هزمتني بها. إذا / عندما يتجول الأشخاص لإصلاح هذا ، أقترح مراجعة قائمة الاختصارات اللاتينية هنا:
https://en.wikipedia.org/wiki/List_of_Latin_abbreviations

من الناحية الفنية ، تمثل هذه الاختصارات في صيغتها المكتوبة بالكامل وغير المختصرة _تعبيرات متعددة الكلمات_ (_MWEs_) ، أليس كذلك؟ أعني ، حسنًا ، من الناحية الفنية هم (أيضًا) يمثلون _قوالب فراسال ثابتة_ ، لكن هذا لا يغير حالة MWE الخاصة بهم ، لذلك ، أتساءل عما إذا كان بإمكان # 2202 المساعدة في هذه المشكلة (على الرغم من أنني أشعر أن الإجابة ستنخفض إلى "لا ") 🤔

(ملاحظة ، حقائق مرحة: "& al." اختصار قانوني لـ "وآخرون" ، لأن "& ج." هو اختصار قانوني لـ "إلخ")

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات