الإصدار 5.12.5
يعرض محلل النحاس الرابط الهيكل اللغوي (اللغة الطبيعية) للغة الفرعية الإنجليزية والتايلاندية والروسية والعربية والفارسية والمحدودة من اللغات الأخرى. هذا الهيكل هو رسم بياني للروابط المكتوبة (الحواف) بين الكلمات في الجملة. يمكن للمرء الحصول على HPSG التقليدية (المكونة) وأسلوب التبعية من قواعد الارتباط من خلال تطبيق مجموعة من القواعد للتحويل إلى هذه التنسيقات المختلفة. هذا ممكن لأن قواعد الارتباط تنطلق قليلاً "أعمق" في بنية "Sytactico-Semantic" للجمل: فهي توفر معلومات أكثر وضوحًا وتفصيلاً أكثر بكثير مما هو متاح بشكل شائع في المحلات التقليدية.
تم تطوير نظرية التحليل النحوي Link في الأصل في عام 1991 من قبل Davy Temperley و John Lafferty و Daniel Sleator ، في ذلك الوقت أساتذة اللغويات وعلوم الكمبيوتر في جامعة كارنيجي ميلون. توفر المنشورات الثلاثة الأولية في هذه النظرية أفضل مقدمة ونظرة عامة ؛ منذ ذلك الحين ، كانت هناك مئات من المنشورات تستكشف الأفكار وفحصها وتوسيعها.
على الرغم من أنه استنادًا إلى قاعدة كود Carnegie-Mellon الأصلية ، تطورت حزمة القواعد النحوية الحالية بشكل كبير وتختلف اختلافًا كبيرًا عن الإصدارات السابقة. كانت هناك إصلاحات أخطاء لا حصر لها. تم تحسين الأداء من خلال عدة أوامر من الحجم. الحزمة متعددة الخيوط بالكامل ، وتمكين UTF-8 بالكامل ، وتم تنظيفها من أجل الأمان ، مما يتيح النشر السحابي. تم تحسين تغطية التحليل باللغة الإنجليزية بشكل كبير ؛ تمت إضافة لغات أخرى (أبرزها ، التايلاندية والروسية). هناك مجموعة كبيرة من الميزات الجديدة ، بما في ذلك دعم التشكل واللهجات ونظام الوزن (التكلفة) ذي الحبيبات الدقيقة ، مما يتيح سلوكًا يشبه المتجهات. يوجد رمز جديد ومتطور مصمم خصيصًا للمورفولوجيا: يمكن أن يقدم تقسيمًا بديلاً للكلمات الغامضة من الناحية المورفولوجية. يمكن تحديث القواميس في وقت التشغيل ، مما يتيح أنظمة تؤدي تعلم القواعد المستمرة لتحليلها في نفس الوقت. وهذا هو ، تحديثات القاموس والتحليل آمنة من الخيط. يمكن التعرف على فئات الكلمات باستخدام regexes. يتم دعم تحليل الرسم البياني العشوائي العشوائي بالكامل ؛ هذا يسمح بأخذ عينات موحدة لمساحة الرسوم البيانية المستوية. يمكن العثور على تقرير مفصل لما تم تغييره في Changelog.
يتم إصدار هذا الرمز بموجب ترخيص LGPL ، مما يجعله متاحًا بحرية للاستخدام الخاص والتجاري ، مع قيود قليلة. وترد شروط الترخيص في ملف الترخيص المدرج في هذا البرنامج.
يرجى الاطلاع على صفحة الويب الرئيسية لمزيد من المعلومات. هذا الإصدار هو استمرار لمحلل CMU الأصلي.
اعتبارًا من الإصدار 5.9.0 ، يتضمن النظام نظامًا تجريبيًا لإنشاء جمل. يتم تحديدها باستخدام واجهة برمجة تطبيقات "ملء الفراغات" ، حيث يتم استبدال الكلمات في مواقع البطاقات البرية ، كلما كانت النتيجة جملة صالحة من الناحية النحوية. التفاصيل الإضافية في صفحة MAN: man link-generator (في دليل man الفرعي).
يتم استخدام هذا المولد في مشروع تعلم اللغة OpenCog ، والذي يهدف إلى تعلم قواعد الارتباط تلقائيًا من Corpora ، باستخدام تقنيات نظرية المعلومات الجديدة والمبتكرة ، تشبه إلى حد ما تلك الموجودة في الشبكات العصبية الاصطناعية (التعلم العميق) ، ولكن باستخدام تمثيل رمزي صريح.
يشتمل المحللون على API في لغات البرمجة المختلفة المختلفة ، بالإضافة إلى أداة سطر أوامر مفيدة للعب معها. إليك بعض الإخراج النموذجي:
linkparser> This is a test!
Linkage 1, cost vector = (UNUSED=0 DIS= 0.00 LEN=6)
+-------------Xp------------+
+----->WV----->+---Ost--+ |
+---Wd---+-Ss*b+ +Ds**c+ |
| | | | | |
LEFT-WALL this.p is.v a test.n !
(S (NP this.p) (VP is.v (NP a test.n)) !)
LEFT-WALL 0.000 Wd+ hWV+ Xp+
this.p 0.000 Wd- Ss*b+
is.v 0.000 Ss- dWV- O*t+
a 0.000 Ds**c+
test.n 0.000 Ds**c- Os-
! 0.000 Xp- RW+
RIGHT-WALL 0.000 RW-
يوضح هذا العرض المزدحم إلى حد ما العديد من الأشياء المثيرة للاهتمام. على سبيل المثال ، يربط رابط Ss*b الفعل والموضوع ، ويشير إلى أن الموضوع فريد. وبالمثل ، يربط ارتباط Ost الفعل والكائن ، ويشير أيضًا إلى أن الكائن فريد. نقاط رابط WV (الفعل) عند رأس الحكم ، بينما يشير رابط Wd إلى رأس الرأس. يتصل رابط Xp بالعلامات الترقيم. يربط رابط Ds**c الاسم بالمحدد: إنه يؤكد مرة أخرى أن الاسم فريد ، وأيضًا أن الاسم يبدأ بساكن. (يتم استخدام رابط PH ، غير المطلوب هنا ، لإجبار الاتفاق الصوتي ، والتمييز بين "A" من "A"). تم توثيق أنواع الارتباطات هذه في وثائق الارتباط باللغة الإنجليزية.
الجزء السفلي من الشاشة هو قائمة "الانفصال" المستخدمة لكل كلمة. الانفصال هي ببساطة قائمة بالموصلات التي تم استخدامها لتشكيل الروابط. إنها مثيرة للاهتمام بشكل خاص لأنها بمثابة شكل جيد للغاية من "جزء من الكلام". وهكذا ، على سبيل المثال: يشير S- O+ Disjunct إلى فعل متعالي: إنه فعل يأخذ موضوعًا وكائنًا. تشير الترميز الإضافي أعلاه إلى أن "IS" لا يتم استخدامه فقط كفعل متعدي ، ولكنه يشير أيضًا إلى تفاصيل أدق: الفعل المتحول الذي أخذ موضوعًا فريدًا ، وقد استخدم (يمكن استخدامه باسم) فعل رئيس الجملة. قيمة النقطة العائمة هي "تكلفة" التفكيك ؛ إنه يلتقط فكرة التسجيل في هذا الاستخدام النحوي. بقدر ما ترتبط أجزاء من الكلام مع الكلمات ذات الكلمات ، وكذلك ترتبط أجزاء من أجزاء الكلام مع الفرق الدقيقة وتدرجات من المعنى.
يدعم محلل الرابط-جرام أيضًا التحليل المورفولوجي. هنا مثال باللغة الروسية:
linkparser> это теста
Linkage 1, cost vector = (UNUSED=0 DIS= 0.00 LEN=4)
+-----MVAip-----+
+---Wd---+ +-LLCAG-+
| | | |
LEFT-WALL это.msi тест.= =а.ndnpi
يربط رابط LL الجذع "тест" باللاحقة ". يرتبط رابط MVA فقط باللاحقة ، لأنه ، باللغة الروسية ، فإن اللواحق التي تحمل جميع البنية النحوية ، وليس السيقان. تم توثيق lexis الروسي هنا.
تم تطوير القاموس التايلاندي الآن بالكامل ، ويغطي اللغة بأكملها بشكل فعال. مثال في التايلاندية:
linkparser> นายกรัฐมนตรี ขึ้น กล่าว สุนทรพจน์
Linkage 1, cost vector = (UNUSED=0 DIS= 2.00 LEN=2)
+---------LWs--------+
| +<---S<--+--VS-+-->O-->+
| | | | |
LEFT-WALL นายกรัฐมนตรี.n ขึ้น.v กล่าว.v สุนทรพจน์.n
يربط رابط VS اثنين من الأفعال "و" กล่าว "في بناء الفعل التسلسلي. تم توثيق ملخص لأنواع الارتباطات هنا. يمكن العثور على الوثائق الكاملة لقواعد الرابط التايلاندي هنا.
كما تقبل Thai Link Grammar مدخلات ذات علامات POS ذات العلامات المميزة. يمكن شرح كل كلمة مع علامة POS Link. على سبيل المثال:
linkparser> เมื่อวานนี้.n มี.ve คน.n มา.x ติดต่อ.v คุณ.pr ครับ.pt
Found 1 linkage (1 had no P.P. violations)
Unique linkage, cost vector = (UNUSED=0 DIS= 0.00 LEN=12)
+---------------------PT--------------------+
+---------LWs---------+---------->VE---------->+ |
| +<---S<---+-->O-->+ +<--AXw<-+--->O--->+ |
| | | | | | | |
LEFT-WALL เมื่อวานนี้.n[!] มี.ve[!] คน.n[!] มา.x[!] ติดต่อ.v[!] คุณ.pr[!] ครับ.pt[!]
يمكن العثور على وثائق كاملة للقاموس التايلاندي هنا.
يقبل القاموس التايلاندي علامات LST20 لـ POS والكيانات المسماة ، لسد الفجوة بين أدوات NLP الأساسية وحامل الارتباط. على سبيل المثال:
linkparser> linkparser> วันที่_25_ธันวาคม@DTM ของ@PS ทุก@AJ ปี@NN เป็น@VV วัน@NN คริสต์มาส@NN
Found 348 linkages (348 had no P.P. violations)
Linkage 1, cost vector = (UNUSED=0 DIS= 1.00 LEN=10)
+--------------------------------LWs--------------------------------+
| +<------------------------S<------------------------+
| | +---------->PO--------->+ |
| +----->AJpr----->+ +<---AJj<--+ +---->O---->+------NZ-----+
| | | | | | | |
LEFT-WALL วันที่_25_ธันวาคม@DTM[!] ของ@PS[!].pnn ทุก@AJ[!].jl ปี@NN[!].n เป็น@VV[!].v วัน@NN[!].na คริสต์มาส@NN[!].n
لاحظ أن كل كلمة أعلاه يتم شرحها باستخدام علامات POS LST20 وعلامات NE. يمكن العثور على وثائق كاملة لكل من علامات POS Link و LST20 TagSets هنا. يمكن العثور على مزيد من المعلومات حول LST20 ، EG Guideline وإحصاءات البيانات ، هنا.
any لغة تدعم الرسوم البيانية المستوية العشوائية التي تم أخذ عينات منها بشكل موحد:
linkparser> asdf qwer tyuiop fghj bbb
Found 1162 linkages (1162 had no P.P. violations)
+-------ANY------+-------ANY------+
+---ANY--+--ANY--+ +---ANY--+--ANY--+
| | | | | |
LEFT-WALL asdf[!] qwer[!] tyuiop[!] fghj[!] bbb[!]
لغة ady تفعل بالمثل ، مما يؤدي إلى تقسيم مورفولوجي عشوائي:
linkparser> asdf qwerty fghjbbb
Found 1512 linkages (1512 had no P.P. violations)
+------------------ANY-----------------+
+-----ANY----+-------ANY------+ +---------LL--------+
| | | | |
LEFT-WALL asdf[!ANY-WORD] qwerty[!ANY-WORD] fgh[!SIMPLE-STEM].= =jbbb[!SIMPLE-SUFF]
يمكن العثور على نظرة عامة ممتدة وملخص في صفحة Link Grammar Wikipedia ، والتي تلامس معظم الاستيراد ، الجوانب الأساسية للنظرية. ومع ذلك ، فليس بديلًا للأوراق الأصلية المنشورة حول هذا الموضوع:
هناك العديد من الأوراق والمراجع المدرجة على موقع قواعد الرابط الأساسي
انظر أيضًا وثائق API C/C ++. يمكن العثور على روابط لغات البرمجة الأخرى ، بما في ذلك Python3 و Java و Node.js ، في دليل الارتباط. (هناك مجموعتان من روابط JavaScript: مجموعة واحدة لواجهة برمجة تطبيقات المكتبة ، ومجموعة أخرى لمحلل سطر الأوامر.)
| محتوى | وصف |
|---|---|
| رخصة | الترخيص الذي يصف شروط الاستخدام |
| Changelog | خلاصة التغييرات الحديثة. |
| تكوين | البرنامج النصي لتكوين GNU |
| Autogen.sh | أداة تكوين المطور |
| رابط-جرام/*. ج | البرنامج. (مكتوب في ANSI-C) |
| ---- | ---- |
| الروابط/autoit/ | روابط لغة تلقائية اختيارية. |
| روابط/جافا/ | روابط لغة جافا الاختيارية. |
| روابط/JS/ | روابط لغة JavaScript الاختيارية. |
| روابط/lisp/ | روابط لغة LISP المشتركة الاختيارية. |
| روابط/node.js/ | اختياري node.js روابط لغة. |
| روابط/ocaml/ | روابط لغة OCAML اختيارية. |
| روابط/بيثون/ | روابط لغة Python3 الاختيارية. |
| روابط/أمثلة بيثون/ | جناح اختبار Link-Grammar ولغة Python مثال الاستخدام الملزم. |
| الارتباطات/swig/ | ملف واجهة SWIG ، لواجهات FFI الأخرى. |
| روابط/فالا/ | روابط لغة فالا الاختيارية. |
| ---- | ---- |
| البيانات/en/ | قواميس اللغة الإنجليزية. |
| البيانات/EN/4.0.DICT | الملف الذي يحتوي على تعريفات القاموس. |
| البيانات/EN/4.0. المعرفة | ملف المعرفة بعد المعالجة. |
| البيانات/EN/4.0.Constituents | ملف المعرفة المكون. |
| البيانات/EN/4.0.AFFIX | ملف اللجنة (بادئة/لاحقة). |
| البيانات/EN/4.0.regex | مورفولوجيا تعبير منتظم تخمين. |
| البيانات/en/tiny.dict | مثال صغير القاموس. |
| البيانات/en/الكلمات/ | دليل مليء بقوائم الكلمات. |
| البيانات/en/corpus*.batch | مثال كوربورا المستخدمة للاختبار. |
| ---- | ---- |
| البيانات/RU/ | قاموس روسي كامل |
| البيانات/Th/ | قاموس تايلاندي كامل (أكثر من 100000 كلمة) |
| البيانات/AR/ | قاموس عربي كامل إلى حد ما |
| البيانات/FA/ | قاموس فارسي (الفارسي) |
| البيانات/de/ | قاموس ألماني صغير |
| البيانات/lt/ | قاموس ليتواني نموذج أولي صغير |
| البيانات/المعرف/ | قاموس إندونيسي صغير النموذج الأولي |
| البيانات/VN/ | قاموس فيتنامي نماذج أولية صغيرة |
| البيانات/هو/ | قاموس العبرية التجريبية |
| البيانات/kz/ | قاموس كازاخاخستري تجريبي |
| البيانات/TR/ | قاموس تركي تجريبي |
| ---- | ---- |
| التشكل/AR/ | محلل التشكل العربي |
| التشكل/فا/ | محلل التشكل الفارسي |
| ---- | ---- |
| تصحيح/ | معلومات حول تصحيح المكتبة |
| MSVC/ | ملفات مشروع Microsoft Visual-C |
| mingw/ | معلومات عن استخدام MingW تحت MSYS أو Cygwin |
يتم توزيع النظام باستخدام تنسيق tar.gz التقليدي ؛ يمكن استخلاصه باستخدام أمر tar -zxf link-grammar.tar.gz في سطر الأوامر.
يمكن تنزيل كرة قطران من أحدث إصدار من:
https://www.gnucash.org/link-grammar/downloads/
تم توقيع الملفات رقميًا للتأكد من عدم وجود فساد لمجموعة البيانات أثناء التنزيل ، وللمساعدة في ضمان عدم إجراء تغييرات خبيثة على الأطراف الثالثة. يمكن التحقق من التوقيعات مع أمر GPG:
gpg --verify link-grammar-5.12.5.tar.gz.asc
التي يجب أن تولد الإخراج مماثلة (باستثناء التاريخ):
gpg: Signature made Thu 26 Apr 2012 12:45:31 PM CDT using RSA key ID E0C0651C
gpg: Good signature from "Linas Vepstas (Hexagon Architecture Patches) <[email protected]>"
gpg: aka "Linas Vepstas (LKML) <[email protected]>"
بالتناوب ، يمكن التحقق من sums فحص MD5. هذه لا توفر أمان تشفير ، لكنها يمكن أن تكتشف الفساد البسيط. للتحقق من شيكات الاختيار ، قم بإصدار md5sum -c MD5SUM في سطر الأوامر.
يمكن التحقق من العلامات الموجودة في git عن طريق تنفيذ ما يلي:
gpg --recv-keys --keyserver keyserver.ubuntu.com EB6AA534E0C0651C
git tag -v link-grammar-5.10.5
لتجميع المكتبة المشتركة وبرنامج التوضيح المشترك في خط الأوامر ، النوع:
./configure
make
make check
للتثبيت ، قم بتغيير المستخدم إلى "الجذر" والقول
make install
ldconfig
سيؤدي ذلك إلى تثبيت مكتبة liblink-grammar.so في /usr/local/lib ، وملفات الرأس في /usr/local/include/link-grammar ، والقواميس في /usr/local/share/link-grammar . سيقوم تشغيل ldconfig بإعادة بناء ذاكرة التخزين المؤقت للمكتبة المشتركة. للتحقق من أن التثبيت كان ناجحًا ، قم بتشغيله (كمستخدم غير الجذر)
make installcheck
تحتوي مكتبة Link-Grammar على ميزات اختيارية يتم تمكينها تلقائيًا في حالة اكتشاف configure مكتبات معينة. هذه المكتبات اختيارية على معظم الأنظمة ، وإذا كانت الميزة التي تضيفها مطلوبة ، فمن الضروري تثبيت المكتبات المقابلة قبل تشغيل configure .
قد تختلف أسماء حزم المكتبة على الأنظمة المختلفة (استشر Google إذا لزم الأمر ...). على سبيل المثال ، قد تتضمن الأسماء -devel بدلاً من -dev ، أو تكون بدونها تمامًا. قد تكون أسماء المكتبة بدون بادئة lib .
libsqlite3-dev (للقاموس المدعوم من SQLite)libz1g-dev أو libz-devel (اللازمة حاليًا للميميات minisat2 المجمعة)libedit-dev (انظر editline)libhunspell-dev أو libaspell-dev (والقاموس الإنجليزي المقابل).libtre-dev أو libpcre2-dev (أسرع بكثير من تطبيق libc regex ، والمطلوب للصحة على freebsd و cygwin).libpcre2-dev . يجب استخدامه على أنظمة معينة (كما هو محدد في أقسام البناء الخاصة بهم). إذا تم تثبيت libedit-dev ، فيمكن استخدام مفاتيح الأسهم لتحرير الإدخال إلى أداة الترابط ؛ سوف تتذكر مفاتيح الأسهم لأعلى ولأسفل الإدخالات السابقة. تريد هذا يجعل الاختبار والتحرير أسهل بكثير.
يتم تضمين نسختين من روابط node.js. نسخة واحدة تلتف المكتبة. يستخدم الآخر emscripten للف أداة سطر الأوامر. روابط المكتبة في bindings/node.js بينما يكون غلاف emscripten في bindings/js .
هذه مصممة باستخدام npm . أولاً ، يجب عليك بناء مكتبة C الأساسية. ثم افعل ما يلي:
cd bindings/node.js
npm install
npm run make
سيؤدي ذلك إلى إنشاء روابط المكتبة وأيضًا إجراء اختبار وحدة صغير (يجب أن يمر). يمكن العثور على مثال في bindings/node.js/examples/simple.js .
لركب خط الأوامر ، افعل ما يلي:
cd bindings/js
./install_emsdk.sh
./build_packages.sh
تم تصميم روابط Python3 افتراضيًا ، شريطة تثبيت حزم تطوير Python المقابلة. (لم تعد روابط Python2 مدعومة.)
هذه الحزم هي:
python3-develpython3-dev ملاحظة: قبل إصدار configure (انظر أدناه) ، يجب عليك التحقق من أنه يمكن استدعاء إصدارات Python المطلوبة باستخدام PATH .
استخدام روابط Python اختيارية ؛ لا تحتاج إلى هذه إذا لم تكن تخطط لاستخدام الرابط مع Python. إذا كنت ترغب في تعطيل روابط Python ، فاستخدم:
./configure --disable-python-bindings
توفر وحدة linkgrammar.py واجهة عالية المستوى في Python. توفر نصوص example.py و sentence-check.py scripts عرضًا تجريبيًا ، tests.py وحدة الاختبارات.
make install pythondir=/where/to/install بشكل افتراضي ، محاولة Makefile لبناء روابط Java. استخدام روابط Java اختيارية ؛ لا تحتاج إلى هذه إذا لم تكن تخطط لاستخدام الرابط مع Java. يمكنك تخطي بناء روابط Java عن طريق التعطيل على النحو التالي:
./configure --disable-java-bindings
إذا لم يتم العثور على jni.h ، أو إذا لم يتم العثور على ant ، فلن يتم بناء روابط Java.
ملاحظات حول العثور على jni.h :
تضع بعض توزيعات Java JVM الشائعة (وأبرزها ، تلك الموجودة في Sun) هذا الملف في مواقع غير عادية ، حيث لا يمكن العثور عليها تلقائيًا. لعلاج هذا ، تأكد من ضبط متغير البيئة JAVA_HOME بشكل صحيح. يبحث البرنامج النصي التكوين عن jni.h في $JAVA_HOME/Headers وفي $JAVA_HOME/include ؛ كما يفحص المواقع المقابلة لـ $JDK_HOME . إذا كان لا يزال من الممكن العثور على jni.h ، حدد الموقع مع متغير CPPFLAGS : على سبيل المثال ،
export CPPFLAGS="-I/opt/jdk1.5/include/:/opt/jdk1.5/include/linux"
أو
export CPPFLAGS="-I/c/java/jdk1.6.0/include/ -I/c/java/jdk1.6.0/include/win32/"
يرجى ملاحظة أن استخدام /opt غير قياسي ، وسوف تفشل معظم أدوات النظام في العثور على حزم مثبتة هناك.
يمكن الإفراط في الإفراط في إزاحة هدف التثبيت /usr/local باستخدام خيار configure --prefix ؛ لذلك ، على سبيل المثال:
./configure --prefix=/opt/link-grammar
باستخدام pkg-config (انظر أدناه) ، يمكن اكتشاف مواقع التثبيت غير القياسية تلقائيًا.
تتم طباعة خيارات التكوين الإضافية بواسطة
./configure --help
تم اختبار النظام ويعمل بشكل جيد على أنظمة Linux 32 و 64 بت ، FreeBSD ، MacOS ، وكذلك على أنظمة Microsoft Windows. تتبع ملاحظات معينة تعتمد على نظام التشغيل.
يجب على المستخدمين النهائيين تنزيل Tarball (انظر التفريغ والتحقق من التوقيع).
إصدار GitHub الحالي مخصص للمطورين (بما في ذلك أي شخص على استعداد لتقديم إصلاح أو ميزة جديدة أو تحسين). غالبًا ما يكون طرف الفرع الرئيسي غير مستقر ، وقد يكون له في بعض الأحيان رمزًا سيئًا فيه كما هو قيد التطوير. كما يحتاج إلى تثبيت أدوات التطوير غير المثبتة افتراضيًا. نظرًا لهذه السبب ، يتم تثبيط استخدام إصدار GitHub للمستخدمين النهائيين العاديين.
استنساخ: git clone https://github.com/opencog/link-grammar.git
أو قم بتنزيله على أنه zip:
https://github.com/opencog/link-grammar/archive/master.zip
الأدوات التي قد تحتاج إلى التثبيت قبل أن تتمكن
make (قد تكون هناك حاجة إلى متغير gmake )
m4
gcc أو clang
autoconf
libtool
autoconf-archive
pkg-config (يمكن تسمية pkgconf أو pkgconfig )
pip3 (لربط بيثون)
خياري:
swig (لروابط اللغة)
flex
Apache ANT (لربط Java)
graphviz (إذا كنت ترغب في استخدام ميزة عرض الكلمات الرسم البياني)
لا يتضمن إصدار GitHub برنامجًا نصيًا configure . لتوليدها ، استخدم:
autogen.sh
إذا حصلت على أخطاء ، فتأكد من تثبيت حزم التطوير المذكورة أعلاه ، وأن تثبيت النظام الخاص بك محدث. على وجه الخصوص ، قد يسبب مفقود autoconf أو autoconf-archive أخطاء غريبة ومضللة.
لمزيد من المعلومات حول كيفية المتابعة ، تابع في القسم إنشاء النظام والأقسام ذات الصلة بعد ذلك.
لتكوين وضع التصحيح ، استخدم:
configure --enable-debug
يضيف بعض رمز التصحيح والوظائف التي يمكنها طباعة العديد من هياكل البيانات.
الميزة التي قد تكون مفيدة لتصحيح الأخطاء هي عرض الرسم البياني. يتم تمكينه افتراضيًا. لمزيد من التفاصيل حول هذه الميزة ، راجع عرض Word-Graph.
يحتوي التكوين الحالي على مشكلة خلط مكتبة C ++ قياسية عند استخدام gcc (الإصلاح مرحب به). ومع ذلك ، فإن الممارسة الشائعة على FreeBSD هي تجميعها مع clang ، وليس لديها هذه المشكلة. بالإضافة إلى ذلك ، يتم تثبيت حزم الوظيفة الإضافية تحت /usr/local .
لذا ، إليك كيفية configure بالتكوين:
env LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include
CC=clang CXX=clang++ configure
لاحظ أن pcre2 عبارة عن حزمة مطلوبة لأن تطبيق libc REGEX الحالي لا يحتوي على المستوى المطلوب لدعم Regex.
بعض الحزم لها أسماء مختلفة عن الأسماء المذكورة في الأقسام السابقة:
minisat (minisat2) pkgconf (PKG-Config)
يجب أن تجمع قواعد النحو الصلبة في Vanilla وتشغيلها على Apple Macos على ما يرام ، كما هو موضح أعلاه. في هذا الوقت ، لا توجد مشكلات تم الإبلاغ عنها.
إذا لم تكن بحاجة إلى روابط Java ، فيجب عليك التكوين بالتأكيد مع:
./configure --disable-java-bindings
إذا كنت تريد روابط Java ، فتأكد من تعيين متغير بيئة JDK_Home إلى أي مكان <Headers/jni.h> . اضبط متغير Java_home على موقع مترجم Java. تأكد من تثبيت ANT.
إذا كنت ترغب في البناء من Github (انظر المبنى من مستودع GitHub) ، يمكنك تثبيت الأدوات المدرجة هناك باستخدام Homebrew.
هناك ثلاث طرق مختلفة يمكن من خلالها تجميع Grammar على Windows. تتمثل إحدى الطرق في استخدام Cygwin ، والتي توفر طبقة توافق Linux لنظام التشغيل Windows. طريقة أخرى هي استخدام نظام MSVC. الطريقة الثالثة هي استخدام نظام MINGW ، والذي يستخدم مجموعة أدوات GNU لتجميع برامج Windows. يدعم الرمز المصدر أنظمة Windows من Vista On.
تنتج Cygwin Way حاليًا أفضل نتيجة ، حيث تدعم تحرير الخط من خلال إكمال الأوامر وتاريخها ويدعم أيضًا عرض الرسم البياني على X-Windows. (لا يحتوي Mingw حاليًا على libedit ، ولا يدعم منفذ MSVC حاليًا إكمال الأوامر والتاريخ ، وكذلك الإملاء.
تتمثل أسهل طريقة لعمل Link-Grammar على MS Windows في استخدام Cygwin ، وهي بيئة تشبه Linux لنظام التشغيل Windows مما يجعل من الممكن تشغيل البرامج التي تعمل على أنظمة Posix إلى Windows. تنزيل وتثبيت cygwin.
لاحظ أن تثبيت حزمة pcre2 مطلوب لأن تطبيق LIBC Regex غير قادر على ذلك بدرجة كافية.
لمزيد من التفاصيل ، راجع Mingw/README-CYGWIN.MD.
هناك طريقة أخرى لإنشاء Link-Grammar وهي استخدام MingW ، والتي تستخدم مجموعة أدوات GNU لتجميع برامج متوافقة مع POSIX لنظام التشغيل Windows. ربما يكون استخدام Mingw/Msys2 أسهل طريقة للحصول على روابط Java قابلة للتطبيق لنظام التشغيل Windows. قم بتنزيل وتثبيت mingw/msys2 من msys2.org.
لاحظ أن تثبيت حزمة pcre2 مطلوب لأن تطبيق LIBC Regex غير قادر على ذلك بدرجة كافية.
لمزيد من التفاصيل ، راجع Mingw/ReadMe-Mingw64.md.
يمكن العثور على ملفات مشروع Microsoft Visual C/C ++ في دليل msvc . للاطلاع على الاتجاهات ، راجع ملف readme.md هناك.
لتشغيل إصدار البرنامج ، (لنفترض أنه في طريقك):
link-parser [arguments]
هذا يبدأ البرنامج. يحتوي البرنامج على العديد من المتغيرات والخيارات القابلة للتوحيد. يمكن عرضها عن طريق إدخال !var في موجه الترابط. الدخول !help سوف تعرض بعض الأوامر الإضافية.
يتم ترتيب القواميس في الدلائل التي اسمها رمز اللغة المكونة من حرفيين. يبحث برنامج الارتباط بين الارتباط عن دليل اللغة بهذا الترتيب ، مباشرة أو ضمن data أسماء الدليل:
/usr/local/share/link-grammar ).إذا لم يتمكن ارتباط بارز من العثور على القاموس المطلوب ، فاستخدم مستوى الفعل 4 لتصحيح المشكلة ؛ على سبيل المثال:
link-parser ru -verbosity=4
يمكن تحديد مواقع أخرى على سطر الأوامر ؛ على سبيل المثال:
link-parser ../path/to-my/modified/data/en
عند الوصول إلى القواميس في المواقع غير القياسية ، لا يزال يتم افتراض أسماء الملفات القياسية ( أي 4.0.dict ، 4.0.affix ، إلخ ).
القواميس الروسية في data/ru . وهكذا ، يمكن أن يبدأ المحلل الروسي على النحو التالي:
link-parser ru
إذا لم تقم بتوفير وسيطة لربط الترابط ، فإنها تبحث عن لغة وفقًا لإعداد موقعك الحالي. إذا لم تتمكن من العثور على دليل اللغة مثل هذا ، فإنه يتخلف عن "en".
إذا رأيت أخطاء مماثلة لهذا:
Warning: The word "encyclop" found near line 252 of en/4.0.dict
matches the following words:
encyclop
This word will be ignored.
ثم لم يتم تثبيت أماكن UTF-8 إما أو عدم تكوينها. يجب أن تدرج locale -a en_US.utf8 كموقع. إذا لم يكن الأمر كذلك ، فأنت بحاجة إلى dpkg-reconfigure locales و/أو تشغيل update-locale أو ربما apt-get install locales ، أو مجموعات أو متغيرات من هذه ، اعتمادًا على نظام التشغيل الخاص بك.
هناك عدة طرق لاختبار البناء الناتج. إذا تم إنشاء روابط Python ، فيمكن العثور على برنامج اختبار في الملف ./bindings/python-examples/tests.py عند التشغيل ، يجب أن يمر. لمزيد من التفاصيل ، راجع readMe.md في دليل bindings/python-examples .
هناك أيضًا مجموعات متعددة من جمل الاختبار/المثال في دلائل بيانات اللغة ، والتي تحتوي بشكل عام على corpus-*.batch يمكن تشغيل برنامج المحلل في وضع الدُفعات ، لاختبار النظام على عدد كبير من الجمل. يقوم الأمر التالي بتشغيل المحلل على ملف يسمى corpus-basic.batch ؛
link-parser < corpus-basic.batch
خط !batch بالقرب من الجزء العلوي من corpus-basic.batch تشغيل وضع الدُفعة. في هذا الوضع ، يجب رفض الجمل المسمى مع أولي * ويجب قبول تلك التي لا تبدأ بـ A * . يقوم ملف الدُفعات هذا بالإبلاغ عن بعض الأخطاء ، وكذلك الملفات corpus-biolg.batch و corpus-fixes.batch . العمل مستمر لإصلاح هذه.
يحتوي ملف corpus-fixes.batch على عدة آلاف من الجمل التي تم إصلاحها منذ الإصدار الأصلي 4.1 من الرابط. يحتوي corpus-biolg.batch على جمل البيولوجيا/النص الطبي من مشروع Biolg. تحتوي corpus-voa.batch على عينات من Voice of America ؛ تحتوي corpus-failures.batch على عدد كبير من الإخفاقات.
تخضع الأرقام التالية للتغيير ، ولكن في هذا الوقت ، فإن عدد الأخطاء التي يمكن للمرء أن يتوقع ملاحظتها في كل من هذه الملفات تقريبًا على النحو التالي:
en/corpus-basic.batch: 88 errors
en/corpus-fixes.batch: 371 errors
lt/corpus-basic.batch: 15 errors
ru/corpus-basic.batch: 47 errors
يحتوي دليل الارتباط/Python على اختبار وحدة لربط Python. كما أنه يؤدي العديد من الشيكات الأساسية التي تشدد على مكتبات الارتباطات.
هناك واجهة برمجة تطبيقات (واجهة برنامج التطبيق) إلى المحلل. هذا يجعل من السهل دمجها في تطبيقاتك الخاصة. تم توثيق API على موقع الويب.
يمكن استخدام ملف FindLinkGrammar.cmake لاختبار التجميع وإعداده في بيئات البناء القائمة على CMake.
لجعل التجميع والربط أسهل ، يستخدم الإصدار الحالي نظام PKG-Config. لتحديد موقع ملفات رأس الارتباط ، على سبيل المثال pkg-config --cflags link-grammar للحصول على موقع المكتبات ، على سبيل المثال pkg-config --libs link-grammar وهكذا ، على سبيل المثال ، قد يشمل Makefile النموذجي الأهداف:
.c.o:
cc -O2 -g -Wall -c $< `pkg-config --cflags link-grammar`
$(EXE): $(OBJS)
cc -g -o $@ $^ `pkg-config --libs link-grammar`
يوفر هذا الإصدار ملفات Java التي توفر ثلاث طرق للوصول إلى المحلل. أبسط طريقة هي استخدام فئة org.linkgrammar.linkgrammar ؛ هذا يوفر واجهة برمجة تطبيقات Java بسيطة للغاية إلى المحلل.
الاحتمال الثاني هو استخدام فئة LGService. هذا ينفذ خادم شبكة TCP/IP ، مما يوفر نتائج تحليل كرسائل JSON. يمكن لأي عميل قادر على الاتصال بهذا الخادم والحصول على نص محسّن.
الاحتمال الثالث هو استخدام فئة org.linkgrammar.lgremoteclient ، وعلى وجه الخصوص ، طريقة parse (). هذه الفئة هي عميل شبكة يتصل بخادم JSON ، ويحول الاستجابة مرة أخرى إلى النتائج التي يمكن الوصول إليها عبر API Parseresult.
سيتم بناء الكود الموصوف أعلاه إذا تم تثبيت Apache ant .
يمكن بدء خادم الشبكة بالقول:
java -classpath linkgrammar.jar org.linkgrammar.LGService 9000
ما سبق يبدأ الخادم على المنفذ 9000. يتم حذف المنفذ ، يتم طباعة نص المساعدة. يمكن الاتصال بهذا الخادم مباشرة عبر TCP/IP ؛ على سبيل المثال:
telnet localhost 9000
(بالتناوب ، استخدم netcat بدلاً من telnet). بعد الاتصال ، اكتب في:
text: this is an example sentence to parse
ستكون البايتات التي تم إرجاعها رسالة JSON التي توفر أخرق الجملة. بشكل افتراضي ، لا يتم إرسال تحليل ASCII-Art للنص. يمكن الحصول على هذا عن طريق إرسال رسائل النموذج:
storeDiagramString:true, text: this is a test.
سيقوم المحلل بإدارة مدقق إملائي في مرحلة مبكرة ، إذا واجهت كلمة لا تعرفها ، ولا يمكنها التخمين ، بناءً على التشكل. يبحث البرنامج النصي تكوين عن محققات التهجئة Aspell أو Hunspell ؛ إذا تم العثور على بيئة Devel Aspell ، فسيتم استخدام Aspell ، وإلا يتم استخدام Hunspell.
قد يتم تعطيل التخمين الإملائي في وقت التشغيل ، في عميل الترابط مع !spell=0 علامة. أدخل !help لمزيد من التفاصيل.
تحذير: إصدار Aspell 0.60.8 وربما الآخرين لديهم تسرب ذاكرة. إن استخدام تخمين الإملائي في خوادم الإنتاج يتم تثبيته بشدة. إن الحفاظ على تعطيل التخمين ( =0 ) في Parse_Options آمن.
من الآمن استخدام ارتباط الرابط في خيوط متعددة. قد تشترك المواضيع في نفس القاموس. يمكن تعيين خيارات التحليل على أساس كل شيء ، باستثناء عملية الإنقاذ ، وهو عالمي ، تشاركه جميع المواضيع. هذا هو العالمي الوحيد.
يتم التعامل مع المحددات الصوتية قبل الحروف الساكنة/حروف العلة بواسطة نوع رابط PH جديد ، وربط المحدد بالكلمة التي تليها مباشرة. الحالة: تم تقديمه في الإصدار 5.1.0 (أغسطس 2014). في الغالب ، على الرغم من أن العديد من الأسماء الخاصة بحالة خاصة غير مكتملة.
هناك حاجة إلى روابط اتجاهية لبعض اللغات ، مثل اللغات الليتوانية والتركية وغيرها من اللغات المجانية لترتيب الكلمات. الهدف من ذلك هو وجود رابط يشير بوضوح إلى الكلمة التي هي الكلمة الرئيسية ، والتي هي المعال. يتم تحقيق ذلك عن طريق موصلات البادئة بحرف حالة واحدة واحدة: H ، D ، يشير إلى "الرأس" و "التابع". قواعد الربط هي أن H لا يتطابق مع لا شيء أو d ، و D يطابق H أو لا شيء. هذه ميزة جديدة في الإصدار 5.1.0 (أغسطس 2014). يوفر الموقع وثائق إضافية.
على الرغم من أن روابط اللغات باللغة الإنجليزية غير موجهة نحو غير موجهة ، إلا أنه يبدو أنه يمكن إعطاء اتجاه بحكم الواقع أن يتوافق تمامًا مع المفاهيم القياسية لقواعد التبعية.
السهام التبعية لها الخصائص التالية:
مضاد للانعكاس (لا يمكن أن تعتمد كلمة على نفسها ؛ لا يمكن أن تشير إلى نفسها.)
anti-symmetric (إذا كان Word1 يعتمد على Word2 ، فإن Word2 لا يمكن أن يعتمد على Word1) (لذلك ، يعتمد محددات على سبيل المثال على الأسماء ، ولكن لا تعتمد على العكس)
الأسهم ليست متعدية ، ولا مضادة للانتقال: قد تحكم كلمة واحدة من قبل عدة رؤوس. على سبيل المثال:
+------>WV------->+
+-->Wd-->+<--Ss<--+
| | |
LEFT-WALL she thinks.v
وهذا هو ، هناك طريق إلى الموضوع ، "هي" ، مباشرة من الجدار الأيسر ، عبر رابط WD ، وكذلك بشكل غير مباشر ، من الجدار إلى الفعل الجذر ، ومن ثم إلى الموضوع. تشكل حلقات مماثلة مع روابط B و R. هذه الحلقات مفيدة لتقييد عدد المحتملين من الأعمدة: يحدث القيد بالتزامن مع الحكم الوصفي "لا روابط عبر".
هناك العديد من المفاهيم الرياضية ذات الصلة ، ولكن لا شيء يلتقط LG الاتجاهي تمامًا:
تشبه الرسوم البيانية LG الاتجاهية dags ، باستثناء أن LG يسمح فقط جدار واحد (عنصر واحد "أعلى").
تشبه الرسوم البيانية LG الاتجاهية الطلبات الجزئية الصارمة ، باستثناء أن أسهم LG غير متعدية عادة.
تشبه الرسوم البيانية LG الاتجاهية Catena باستثناء أن Catena مضادان تمامًا-المسار إلى أي كلمة فريد من نوعه ، في Catena.
تنص أوراق LG التأسيسية على انتشار الرسوم البيانية. يعتمد هذا على ملاحظة قديمة جدًا لا تعبرها التبعيات تقريبًا باللغات الطبيعية: ببساطة لا يتحدث البشر في جمل حيث تتقاطع الروابط. يوفر فرض قيود البراناري بعد ذلك قيودًا قوية للهندسة والخوارزمية على الأعمدة الناتجة: يتم تقليل العدد الإجمالي للموسيقى التي يجب مراعاتها بشكل حاد ، وبالتالي يمكن زيادة السرعة الإجمالية للتحليل إلى حد كبير.
ومع ذلك ، هناك استثناءات عرضية ونادرة نسبيًا لقاعدة المخطوطة هذه ؛ ويلاحظ مثل هذه الاستثناءات في جميع اللغات تقريبا. يتم تقديم عدد من هذه الاستثناءات للغة الإنجليزية ، أدناه.
وبالتالي ، يبدو من المهم استرخاء قيود المخطوط ، والعثور على شيء آخر تقريبًا صارمًا ، ولكنه لا يزال يسمح باستثناءات نادرة. يبدو أن مفهوم "النقل الترانمي" كما هو محدد من قبل ريتشارد هدسون في نظريته عن "Word Grammar" ، ثم دعا Ben Goertzel ، قد يكون مجرد آلية.
ftp://ftp.phon.ucl.ac.uk/pub/word-grammar/ell2-wg.pdf
http://www.phon.ucl.ac.uk/home/dick/enc/syntax.htm
http://goertzel.org/prowlgrammar.pdf
في الممارسة العملية ، يتيح قيود المخطط استخدام خوارزميات فعالة للغاية في تنفيذ المحلل. وبالتالي ، من وجهة نظر التنفيذ ، نريد الحفاظ على المخطط. لحسن الحظ ، هناك طريقة مريحة لا لبس فيها للحصول على كعكتنا وتناولها أيضًا. يمكن رسم رسم تخطيطي غير مستوي على ورقة باستخدام تدوين الهندسة الكهربائية القياسية: رمز مضحك ، أينما تعبر الأسلاك. يتم تكييف هذا التدوين بسهولة مع موصلات LG ؛ فيما يلي مثال عمل فعلي ، تم تنفيذه بالفعل في قاموس LG English الحالي. يمكن تنفيذ جميع معابر الارتباط بهذه الطريقة! لذلك ليس علينا أن نتخلى بالفعل عن خوارزميات التحليل الحالية للحصول على مخططات غير مستوية. ليس لدينا حتى لتعديلها! يا هلا!
إليكم مثال عمل: "أريد أن أنظر إلى كل شيء وأستمع إلى كل شيء." هذا يريد اثنين من الرابطين J يشير إلى "كل شيء". يحتاج الرسم البياني المطلوب إلى أن يبدو هكذا:
+---->WV---->+
| +--------IV---------->+
| | +<-VJlpi--+
| | | +---xxx------------Js------->+
+--Wd--+-Sp*i+--TO-+-I*t-+-MVp+ +--VJrpi>+--MVp-+---Js->+
| | | | | | | | | |
LEFT-WALL I.p want.v to.r look.v at and.j-v listen.v to.r everything
يريد ما سبق حقًا الحصول على رابط Js من "إلى" إلى "كل شيء" ، لكن ارتباط Js هذا يعبر (يشتبه - يتميز بـ XXX) الرابط إلى التزامن. تشير الأمثلة الأخرى إلى أنه ينبغي للمرء أن يسمح لمعظم الروابط بالعبور عبر الروابط لأسفل بالاقتران.
تتمثل الحافظة في مجال العمل في تقسيم رابط Js إلى قسمين: جزء Jj وجزء Jk ؛ يتم استخدام الاثنين معا لعبور فوق الاقتران. يتم تنفيذ هذا حاليًا في القاموس الإنجليزي ، وهو يعمل.
هذا العمل هو في الواقع عام تمامًا ، ويمكن تمديده إلى أي نوع من عبور الارتباط. لكي ينجح هذا ، سيكون تدوين أفضل ؛ perhaps uJs- instead of Jj- and vJs- instead of Jk- , or something like that ... (TODO: invent better notation.) (NB: This is a kind of re-invention of "fat links", but in the dictionary, not in the code.)
Given that non-planar parses can be enabled without any changes to the parser algorithm, all that is required is to understand what sort of theory describes link-crossing in a coherent grounding. That theory is Dick Hudson's Landmark Transitivity, explained here.
This mechanism works as follows:
First, every link must be directional, with a head and a dependent. That is, we are concerned with directional-LG links, which are of the form x--A-->y or y<--A--x for words x,y and LG link type A.
Given either the directional-LG relation x--A-->y or y<--A--x, define the dependency relation x-->y. That is, ignore the link-type label.
Heads are landmarks for dependents. If the dependency relation x-->y holds, then x is said to be a landmark for y, and the predicate land(x,y) is true, while the predicate land(y,x) is false. Here, x and y are words, while --> is the landmark relation.
Although the basic directional-LG links form landmark relations, the total set of landmark relations is extended by transitive closure. That is, if land(x,y) and land(y,z) then land(x,z). That is, the basic directional-LG links are "generators" of landmarks; they generate by means of transitivity. Note that the transitive closure is unique.
In addition to the above landmark relation, there are two additional relations: the before and after landmark relations. (In English, these correspond to left and right; in Hebrew, the opposite). That is, since words come in chronological order in a sentence, the dependency relation can point either left or right. The previously-defined landmark relation only described the dependency order; we now introduce the word-sequence order. Thus, there are are land-before() and land-after() relations that capture both the dependency relation, and the word-order relation.
Notation: the before-landmark relation land-B(x,y) corresponds to x-->y (in English, reversed in right-left languages such as Hebrew), whereas the after-landmark relation land-A(x,y) corresponds to y<--x. That is, land(x,y) == land-B(x,y) or land-A(x,y) holds as a statement about the predicate form of the relations.
As before, the full set of directional landmarks are obtained by transitive closure applied to the directional-LG links. Two different rules are used to perform this closure:
-- land-B(x,y) and land(y,z) ==> land-B(x,y)
-- land-A(x,y) and land(y,z) ==> land-A(x,y)
Parsing is then performed by joining LG connectors in the usual manner, to form a directional link. The transitive closure of the directional landmarks are then computed. Finally, any parse that does not conclude with the "left wall" being the upper-most landmark is discarded.
Here is an example where landmark transitivity provides a natural solution to a (currently) broken parse. The "to.r" has a disjunct "I+ & MVi-" which allows "What is there to do?" to parse correctly. However, it also allows the incorrect parse "He is going to do". The fix would be to force "do" to take an object; however, a link from "do" to "what" is not allowed, because link-crossing would prevent it.
Fixing this requires only a fix to the dictionary, and not to the parser itself.
Examples where the no-links-cross constraint seems to be violated, in English:
"He is either in the 105th or the 106th battalion."
"He is in either the 105th or the 106th battalion."
Both seem to be acceptable in English, but the ambiguity of the "in-either" temporal ordering requires two different parse trees, if the no-links-cross rule is to be enforced. This seems un-natural. بصورة مماثلة:
"He is either here or he is there."
"He either is here or he is there."
A different example involves a crossing to the left wall. That is, the links LEFT-WALL--remains crosses over here--found :
"Here the remains can be found."
Other examples, per And Rosta:
The allowed--by link crosses cake--that :
He had been allowed to eat a cake by Sophy that she had made him specially
a--book , very--indeed
"a very much easier book indeed"
an--book , easy--to
"an easy book to read"
a--book , more--than
"a more difficult book than that one"
that--have crosses remains--of
"It was announced that remains have been found of the ark of the covenant"
There is a natural crossing, driven by conjunctions:
"I was in hell yesterday and heaven on Tuesday."
the "natural" linkage is to use MV links to connect "yesterday" and "on Tuesday" to the verb. However, if this is done, then these must cross the links from the conjunction "and" to "heaven" and "hell". This can be worked around partly as follows:
+-------->Ju--------->+
| +<------SJlp<----+
+<-SX<-+->Pp->+ +-->Mpn->+ +->SJru->+->Mp->+->Js->+
| | | | | | | | |
I was in hell yesterday and heaven on Tuesday
but the desired MV links from the verb to the time-prepositions "yesterday" and "on Tuesday" are missing -- whereas they are present, when the individual sentences "I was in hell yesterday" and "I was in heaven on Tuesday" are parsed. Using a conjunction should not wreck the relations that get used; but this requires link-crossing.
"Sophy wondered up to whose favorite number she should count"
Here, "up_to" must modify "number", and not "whose". There's no way to do this without link-crossing.
Link Grammar can be understood in the context of type theory. A simple introduction to type theory can be found in chapter 1 of the HoTT book. This book is freely available online and strongly recommended if you are interested in types.
Link types can be mapped to types that appear in categorial grammars. The nice thing about link-grammar is that the link types form a type system that is much easier to use and comprehend than that of categorial grammar, and yet can be directly converted to that system! That is, link-grammar is completely compatible with categorial grammar, and is easier-to-use. See the paper "Combinatory Categorial Grammar and Link Grammar are Equivalent" for details.
The foundational LG papers make comments to this effect; however, see also work by Bob Coecke on category theory and grammar. Coecke's diagrammatic approach is essentially identical to the diagrams given in the foundational LG papers; it becomes abundantly clear that the category theoretic approach is equivalent to Link Grammar. See, for example, this introductory sketch http://www.cs.ox.ac.uk/people/bob.coecke/NewScientist.pdf and observe how the diagrams are essentially identical to the LG jigsaw-puzzle piece diagrams of the foundational LG publications.
If you have any questions, please feel free to send a note to the mailing list.
The source code of link-parser and the link-grammar library is located at GitHub.
For bug reports, please open an issue there.
Although all messages should go to the mailing list, the current maintainers can be contacted at:
Linas Vepstas - <[email protected]>
Amir Plivatsky - <[email protected]>
Dom Lachowicz - <[email protected]>
A complete list of authors and copyright holders can be found in the AUTHORS file. The original authors of the Link Grammar parser are:
Daniel Sleator [email protected]
Computer Science Department 412-268-7563
Carnegie Mellon University www.cs.cmu.edu/~sleator
Pittsburgh, PA 15213
Davy Temperley [email protected]
Eastman School of Music 716-274-1557
26 Gibbs St. www.link.cs.cmu.edu/temperley
Rochester, NY 14604
John Lafferty [email protected]
Computer Science Department 412-268-6791
Carnegie Mellon University www.cs.cmu.edu/~lafferty
Pittsburgh, PA 15213
Some working notes.
Easy to fix: provide a more uniform API to the constituent tree. ie provide word index. Also, provide a better word API, showing word extent, subscript, etc.
There are subtle technical issues for handling capitalized first words. This needs to be fixed. In addition, for now these words are shown uncapitalized in the result linkages. This can be fixed.
Maybe capitalization could be handled in the same way that a/an could be handled! After all, it's essentially a nearest-neighbor phenomenon!
See also issue 690
The proximal issue is to add a cost, so that Bill gets a lower cost than bill.n when parsing "Bill went on a walk". The best solution would be to add a 'capitalization-mark token' during tokenization; this token precedes capitalized words. The dictionary then explicitly links to this token, with rules similar to the a/an phonetic distinction. The point here is that this moves capitalization out of ad-hoc C code and into the dictionary, where it can be handled like any other language feature. The tokenizer includes experimental code for that.
The old for parse ranking via corpus statistics needs to be revived. The issue can be illustrated with these example sentences:
"Please the customer, bring in the money"
"Please, turn off the lights"
In the first sentence, the comma acts as a conjunction of two directives (imperatives). In the second sentence, it is much too easy to mistake "please" for a verb, the comma for a conjunction, and come to the conclusion that one should please some unstated object, and then turn off the lights. (Perhaps one is pleasing by turning off the lights?)
When a sentence fails to parse, look for:
Poor agreement might be handled by giving a cost to mismatched lower-case connector letters.
An common phenomenon in English is that some words that one might expect to "properly" be present can disappear under various conditions. Below is a sampling of these. Some possible solutions are given below.
Expressions such as "Looks good" have an implicit "it" (also called a zero-it or phantom-it) in them; that is, the sentence should really parse as "(it) looks good". The dictionary could be simplified by admitting such phantom words explicitly, rather than modifying the grammar rules to allow such constructions. Other examples, with the phantom word in parenthesis, include:
This can extend to elided/unvoiced syllables:
Elided punctuation:
Normally, the subjects of imperatives must always be offset by a comma: "John, give me the hammer", but here, in muttering an oath, the comma is swallowed (unvoiced).
Some complex phantom constructions:
See also GitHub issue #224.
Actual ellipsis:
Here, the ellipsis stands for a subordinate clause, which attaches with not one, but two links: C+ & CV+ , and thus requires two words, not one. There is no way to have the ellipsis word to sink two connectors starting from the same word, and so some more complex mechanism is needed. The solution is to infer a second phantom ellipsis:
where the first ellipsis is a stand in for the subject of a subordinate clause, and the second stands in for an unknown verb.
Many (unstressed) syllables can be elided; in modern English, this occurs most commonly in the initial unstressed syllable:
Poorly punctuated sentences cause problems: for example:
"Mike was not first, nor was he last."
"Mike was not first nor was he last."
The one without the comma currently fails to parse. How can we deal with this in a simple, fast, elegant way? Similar questions for zero-copula and zero-that sentences.
Consider an argument between a professor and a dean, and the dean wants the professor to write a brilliant review. At the end of the argument, the dean exclaims: "I want the review brilliant!" This is a predicative adjective; clearly it means "I want the review [that you write to be] brilliant." However, taken out of context, such a construction is ungrammatical, as the predictiveness is not at all apparent, and it reads just as incorrectly as would "*Hey Joe, can you hand me that review brilliant?"
"Push button"
"Push button firmly"
The subject is a phantom; the subject is "you".
One possible solution is to perform a one-point compactification. The dictionary contains the phantom words, and their connectors. Ordinary disjuncts can link to these, but should do so using a special initial lower-case letter (say, 'z', in addition to 'h' and 'd' as is currently implemented). The parser, as it works, examines the initial letter of each connector: if it is 'z', then the usual pruning rules no longer apply, and one or more phantom words are selected out of the bucket of phantom words. (This bucket is kept out-of-line, it is not yet placed into sentence word sequence order, which is why the usual pruning rules get modified.) Otherwise, parsing continues as normal. At the end of parsing, if there are any phantom words that are linked, then all of the connectors on the disjunct must be satisfied (of course!) else the linkage is invalid. After parsing, the phantom words can be inserted into the sentence, with the location deduced from link lengths.
A more principled approach to fixing the phantom-word issue is to borrow the idea of re-writing from the theory of operator grammar. That is, certain phrases and constructions can be (should be) re-written into their "proper form", prior to parsing. The re-writing step would insert the missing words, then the parsing proceeds. One appeal of such an approach is that re-writing can also handle other "annoying" phenomena, such as typos (missing apostrophes, eg "lets" vs. "let's", "its" vs. "it's") as well as multi-word rewrites (eg "let's" vs. "let us", or "it's" vs. "it is").
Exactly how to implement this is unclear. However, it seems to open the door to more abstract, semantic analysis. Thus, for example, in Meaning-Text Theory (MTT), one must move between SSynt to DSynt structures. Such changes require a graph re-write from the surface syntax parse (eg provided by link-grammar) to the deep-syntactic structure. By contrast, handling phantom words by graph re-writing prior to parsing inverts the order of processing. This suggests that a more holistic approach is needed to graph rewriting: it must somehow be performed "during" parsing, so that parsing can both guide the insertion of the phantom words, and, simultaneously guide the deep syntactic rewrites.
Another interesting possibility arises with regards to tokenization. The current tokenizer is clever, in that it splits not only on whitespace, but can also strip off prefixes, suffixes, and perform certain limited kinds of morphological splitting. That is, it currently has the ability to re-write single-words into sequences of words. It currently does so in a conservative manner; the letters that compose a word are preserved, with a few exceptions, such as making spelling correction suggestions. The above considerations suggest that the boundary between tokenization and parsing needs to become both more fluid, and more tightly coupled.
Compare "she will be happier than before" to "she will be more happy than before." Current parser makes "happy" the head word, and "more" a modifier w/EA link. I believe the correct solution would be to make "more" the head (link it as a comparative), and make "happy" the dependent. This would harmonize rules for comparatives... and would eliminate/simplify rules for less,more.
However, this idea needs to be double-checked against, eg Hudson's word grammar. I'm confused on this issue ...
Currently, some links can act at "unlimited" length, while others can only be finite-length. eg determiners should be near the noun that they apply to. A better solution might be to employ a 'stretchiness' cost to some connectors: the longer they are, the higher the cost. (This eliminates the "unlimited_connector_set" in the dictionary).
Sometimes, the existence of one parse should suggest that another parse must surely be wrong: if one parse is possible, then the other parses must surely be unlikely. For example: the conjunction and.jg allows the "The Great Southern and Western Railroad" to be parsed as the single name of an entity. However, it also provides a pattern match for "John and Mike" as a single entity, which is almost certainly wrong. But "John and Mike" has an alternative parse, as a conventional-and -- a list of two people, and so the existence of this alternative (and correct) parse suggests that perhaps the entity-and is really very much the wrong parse. That is, the mere possibility of certain parses should strongly disfavor other possible parses. (Exception: Ben & Jerry's ice cream; however, in this case, we could recognize Ben & Jerry as the name of a proper brand; but this is outside of the "normal" dictionary (?) (but maybe should be in the dictionary!))
More examples: "high water" can have the connector A joining high.a and AN joining high.n; these two should either be collapsed into one, or one should be eliminated.
Use WordNet to reduce the number for parses for sentences containing compound verb phrases, such as "give up", "give off", etc.
To avoid a combinatorial explosion of parses, it would be nice to have an incremental parsing, phrase by phrase, using a sliding window algorithm to obtain the parse. Thus, for example, the parse of the last half of a long, run-on sentence should not be sensitive to the parse of the beginning of the sentence.
Doing so would help with combinatorial explosion. So, for example, if the first half of a sentence has 4 plausible parses, and the last half has 4 more, then currently, the parser reports 16 parses total. It would be much more useful if it could instead report the factored results: ie the four plausible parses for the first half, and the four plausible parses for the last half. This would ease the burden on downstream users of link-grammar.
This approach has at psychological support. Humans take long sentences and split them into smaller chunks that "hang together" as phrase- structures, viz compounded sentences. The most likely parse is the one where each of the quasi sub-sentences is parsed correctly.
This could be implemented by saving dangling right-going connectors into a parse context, and then, when another sentence fragment arrives, use that context in place of the left-wall.
This somewhat resembles the application of construction grammar ideas to the link-grammar dictionary. It also somewhat resembles Viterbi parsing to some fixed depth. بمعنى. do a full backward-forward parse for a phrase, and then, once this is done, take a Viterbi-step. That is, once the phrase is done, keep only the dangling connectors to the phrase, place a wall, and then step to the next part of the sentence.
Caution: watch out for garden-path sentences:
The horse raced past the barn fell.
The old man the boat.
The cotton clothing is made of grows in Mississippi.
The current parser parses these perfectly; a viterbi parser could trip on these.
Other benefits of a Viterbi decoder:
One may argue that Viterbi is a more natural, biological way of working with sequences. Some experimental, psychological support for this can be found at http://www.sciencedaily.com/releases/2012/09/120925143555.htm per Morten Christiansen, Cornell professor of psychology.
Consider the sentence "Thieves rob bank" -- a typical newspaper headline. LG currently fails to parse this, because the determiner is missing ("bank" is a count noun, not a mass noun, and thus requires a determiner. By contrast, "thieves rob water" parses just fine.) A fix for this would be to replace mandatory determiner links by (D- or {[[()]] & headline-flag}) which allows the D link to be omitted if the headline-flag bit is set. Here, "headline-flag" could be a new link-type, but one that is not subject to planarity constraints.
Note that this is easier said than done: if one simply adds a high-cost null link, and no headline-flag, then all sorts of ungrammatical sentences parse, with strange parses; while some grammatical sentences, which should parse, but currently don't, become parsable, but with crazy results.
More examples, from And Rosta:
"when boy meets girl"
"when bat strikes ball"
"both mother and baby are well"
A natural approach would be to replace fixed costs by formulas. This would allow the dialect/sociolect to be dynamically changeable. That is, rather than having a binary headline-flag, there would be a formula for the cost, which could be changed outside of the parsing loop. Such formulas could be used to enable/disable parsing specific to different dialects/sociolects, simply by altering the network of link costs.
A simpler alternative would be to have labeled costs (a cost vector), so that different dialects assign different costs to various links. A dialect would be specified during the parse, thus causing the costs for that dialect to be employed during parse ranking.
This has been implemented; what's missing is a practical tutorial on how this might be used.
A good reference for refining verb usage patterns is: "COBUILD GRAMMAR PATTERNS 1: VERBS from THE COBUILD SERIES", from THE BANK OF ENGLISH, HARPER COLLINS. Online at https://arts-ccr-002.bham.ac.uk/ccr/patgram/ and http://www.corpus.bham.ac.uk/publications/index.shtml
Currently tokenize.c tokenizes double-quotes and some UTF8 quotes (see the RPUNC/LPUNC class in en/4.0.affix - the QUOTES class is not used for that, but for capitalization support), with some very basic support in the English dictionary (see "% Quotation marks." there). However, it does not do this for the various "curly" UTF8 quotes, such as 'these' and “these”. This results is some ugly parsing for sentences containing such quotes. (Note that these are in 4.0.affix).
A mechanism is needed to disentangle the quoting from the quoted text, so that each can be parsed appropriately. It's somewhat unclear how to handle this within link-grammar. This is somewhat related to the problem of morphology (parsing words as if they were "mini-sentences",) idioms (phrases that are treated as if they were single words), set-phrase structures (if ... then ... not only... but also ...) which have a long-range structure similar to quoted text (he said ...).
See also GitHub issue #42.
"to be fishing": Link grammar offers four parses of "I was fishing for evidence", two of which are given low scores, and two are given high scores. Of the two with high scores, one parse is clearly bad. Its links "to be fishing.noun" as opposed to the correct "to be fishing.gerund". That is, I can be happy, healthy and wise, but I certainly cannot be fishing.noun. This is perhaps not just a bug in the structure of the dictionary, but is perhaps deeper: link-grammar has little or no concept of lexical units (ie collocations, idioms, institutional phrases), which thus allows parses with bad word-senses to sneak in.
The goal is to introduce more knowledge of lexical units into LG.
Different word senses can have different grammar rules (and thus, the links employed reveal the sense of the word): for example: "I tend to agree" vs. "I tend to the sheep" -- these employ two different meanings for the verb "tend", and the grammatical constructions allowed for one meaning are not the same as those allowed for the other. Yet, the link rules for "tend.v" have to accommodate both senses, thus making the rules rather complex. Worse, it potentially allows for non-sense constructions. If, instead, we allowed the dictionary to contain different rules for "tend.meaning1" and "tend.meaning2", the rules would simplify (at the cost of inflating the size of the dictionary).
Another example: "I fear so" -- the word "so" is only allowed with some, but not all, lexical senses of "fear". So eg "I fear so" is in the same semantic class as "I think so" or "I hope so", although other meanings of these verbs are otherwise quite different.
[Sin2004] "New evidence, new priorities, new attitudes" in J. Sinclair, (ed) (2004) How to use corpora in language teaching, Amsterdam: John Benjamins
See also: Pattern Grammar: A Corpus-Driven Approach to the Lexical Grammar of English
Susan Hunston and Gill Francis (University of Birmingham)
Amsterdam: John Benjamins (Studies in corpus linguistics, edited by Elena Tognini-Bonelli, volume 4), 2000
Book review.
“The Molecular Level of Lexical Semantics”, EA Nida, (1997) International Journal of Lexicography, 10(4): 265–274. متصل
The link-grammar provides several mechanisms to support circumpositions or even more complicated multi-word structures. One mechanism is by ordinary links; see the V, XJ and RJ links. The other mechanism is by means of post-processing rules. (For example, the "filler-it" SF rules use post-processing.) However, rules for many common forms have not yet been written. The general problem is of supporting structures that have "holes" in the middle, that require "lacing" to tie them together.
For a general theory, see catena.
For example, the adposition:
... from [xxx] on.
"He never said another word from then on."
"I promise to be quiet from now on."
"Keep going straight from that point on."
"We went straight from here on."
... from there on.
"We went straight, from the house on to the woods."
"We drove straight, from the hill onwards."
Note that multiple words can fit in the slot [xxx]. Note the tangling of another prepositional phrase: "... from [xxx] on to [yyy]"
More complicated collocations with holes include
"First.. next..."
"If ... then ..."
'Then' is optional ('then' is a 'null word'), for example:
"If it is raining, stay inside!"
"If it is raining, [then] stay inside!"
"if ... only ..." "If there were only more like you!"
"... not only, ... but also ..."
"As ..., so ..." "As it was commanded, so it shall be done"
"Either ... or ..."
"Both ... and ..." "Both June and Tom are coming"
"ought ... if ..." "That ought to be the case, if John is not lying"
"Someone ... who ..."
"Someone is outside who wants to see you"
"... for ... to ..."
"I need for you to come to my party"
The above are not currently supported. An example that is supported is the "non-referential it", eg
"It ... that ..."
"It seemed likely that John would go"
The above is supported by means of special disjuncts for 'it' and 'that', which must occur in the same post-processing domain.
انظر أيضا:
http://www.phon.ucl.ac.uk/home/dick/enc2010/articles/extraposition.htm
http://www.phon.ucl.ac.uk/home/dick/enc2010/articles/relative-clause.htm
"...from X and from Y" "By X, and by Y, ..." Here, X and Y might be rather long phrases, containing other prepositions. In this case, the usual link-grammar linkage rules will typically conjoin "and from Y" to some preposition in X, instead of the correct link to "from X". Although adding a cost to keep the lengths of X and Y approximately equal can help, it would be even better to recognize the "...from ... and from..." pattern.
The correct solution for the "Either ... or ..." appears to be this:
---------------------------+---SJrs--+
+------???----------+ |
| +Ds**c+--SJls-+ +Ds**+
| | | | | |
either.r the lorry.n or.j-n the van.n
The wrong solution is
--------------------------+
+-----Dn-----+ +---SJrs---+
| +Ds**c+--SJn--+ +Ds**+
| | | | | |
neither.j the lorry.n nor.j-n the van.n
The problem with this is that "neither" must coordinate with "nor". That is, one cannot say "either.. nor..." "neither ... or ... " "neither ...and..." "but ... nor ..." The way I originally solved the coordination problem was to invent a new link called Dn, and a link SJn and to make sure that Dn could only connect to SJn, and nothing else. Thus, the lower-case "n" was used to propagate the coordination across two links. This demonstrates how powerful the link-grammar theory is: with proper subscripts, constraints can be propagated along links over large distances. However, this also makes the dictionary more complex, and the rules harder to write: coordination requires a lot of different links to be hooked together. And so I think that creating a single, new link, called ???, will make the coordination easy and direct. That is why I like that idea.
ال ؟؟؟ link should be the XJ link, which-see.
More idiomatic than the above examples: "...the chip on X's shoulder" "to do X a favour" "to give X a look"
The above are all examples of "set phrases" or "phrasemes", and are most commonly discussed in the context of MTT or Meaning-Text Theory of Igor Mel'cuk et al (search for "MTT Lexical Function" for more info). Mel'cuk treats set phrases as lexemes, and, for parsing, this is not directly relevant. However, insofar as phrasemes have a high mutual information content, they can dominate the syntactic structure of a sentence.
The current parse of "he wanted to look at and listen to everything." is inadequate: the link to "everything" needs to connect to "and", so that "listen to" and "look at" are treated as atomic verb phrases.
MTT suggests that perhaps the correct way to understand the contents of the post-processing rules is as an implementation of 'lexical functions' projected onto syntax. That is, the post-processing rules allow only certain syntactical constructions, and these are the kinds of constructions one typically sees in certain kinds of lexical functions.
Alternately, link-grammar suffers from a combinatoric explosion of possible parses of a given sentence. It would seem that lexical functions could be used to rule out many of these parses. On the other hand, the results are likely to be similar to that of statistical parse ranking (which presumably captures such quasi-idiomatic collocations at least weakly).
المرجع. I. Mel'cuk: "Collocations and Lexical Functions", in ''Phraseology: theory, analysis, and applications'' Ed. Anthony Paul Cowie (1998) Oxford University Press pp. 23-54.
More generally, all of link-grammar could benefit from a MTT-izing of infrastructure.
Compare the above commentary on lexical functions to Hebrew morphological analysis. To quote Wikipedia:
This distinction between the word as a unit of speech and the root as a unit of meaning is even more important in the case of languages where roots have many different forms when used in actual words, as is the case in Semitic languages. In these, roots are formed by consonants alone, and different words (belonging to different parts of speech) are derived from the same root by inserting vowels. For example, in Hebrew, the root gdl represents the idea of largeness, and from it we have gadol and gdola (masculine and feminine forms of the adjective "big"), gadal "he grew", higdil "he magnified" and magdelet "magnifier", along with many other words such as godel "size" and migdal "tower".
Instead of hard-coding LL, declare which links are morpho links in the dict.
Version 6.0 will change Sentence to Sentence*, Linkage to Linkage* in the API. But perhaps this is a bad idea...