Knowledge Oriented Programming Language

Related tags

Text Data & NLP KoPL
Overview

KoPL: 面向知识的推理问答编程语言

安装 | 快速开始 | 文档

KoPL全称 Knowledge oriented Programing Language, 是一个为复杂推理问答而设计的编程语言。我们可以将自然语言问题表示为由基本函数组合而成的KoPL程序,程序运行的结果就是问题的答案。目前,KoPL的27个基本函数覆盖对多种知识元素(如概念、实体、关系、属性、修饰符等)的操作,并支持多种问题类型(如计数、事实验证、比较等)的查询。KoPL提供透明的复杂问题推理过程,易于理解和使用。KoPL面向知识库、文本等不同形式的知识资源,可扩展性强。

下面的代码演示了如何使用Python代码,实现对一个自然语言问题的推理问答。

from kopl.kopl import KoPLEngine
from kopl.test.test_example import example_kb

engine = KoPLEngine(example_kb) # 创建可以在example_kb这个知识库上进行操作的engine示例

# 查询问题:Who is taller, LeBron James Jr. or his father?
ans = engine.SelectBetween( # 在两个实体中,查询'height'更大的实体
  engine.Find('LeBron James Jr.'), # 找到实体'LeBron James Jr'
  engine.Relate( # 找到与'LeBron James Jr'的'father
    engine.Find('LeBron James Jr.'), # 找到实体'LeBron James Jr'
    'father', # 关系标签
    'forward' # ’forward‘代表'LeBron James Jr'为头实体
  ),
  'height', # 属性标签
  'greater' # 查询属性值更大的实体
)

print(ans) # ans是实体名字列表

在这个示例里,我们查询LeBron James Jr.和他的父亲谁更高,KoPL程序给出了正确的答案: LeBron James!

安装

KoPL支持Linux (e.g., Ubuntu/CentOS),macOS,Windows。

其依赖为:

  • python >= 3.6

  • tqdm >= 4.62

KoPL提供pip安装, 下面将展示Ubuntu的安装命令:

  $ pip install KoPL

运行下面的代码

import kopl

from kopl.test.test_example import *

run_test()

如果测试运行成功,恭喜您已经安装成功。

快速开始

您可以准备自己的知识库,使用KoPL实现推理问答。知识库的格式请参考 知识库。 更多使用KoPL程序进行的简单问答请参考 简单问答,复杂问答请参考 复杂问答

您也可以使用我们为您提供的查询服务,快速开启KoPL之旅。

文档

我们为您提供了KoPL文档,详细介绍了KoPL面向的知识元素,KoPL的基本函数,KoPL引擎的API。

You might also like...
PIZZA - a task-oriented semantic parsing dataset

The PIZZA dataset continues the exploration of task-oriented parsing by introducing a new dataset for parsing pizza and drink orders, whose semantics cannot be captured by flat slots and intents.

Code for paper "Role-oriented Network Embedding Based on Adversarial Learning between Higher-order and Local Features"

Role-oriented Network Embedding Based on Adversarial Learning between Higher-order and Local Features Train python main.py --dataset brazil-flights C

A python framework to transform natural language questions to queries in a database query language.

__ _ _ _ ___ _ __ _ _ / _` | | | |/ _ \ '_ \| | | | | (_| | |_| | __/ |_) | |_| | \__, |\__,_|\___| .__/ \__, | |_| |_| |___/

A Domain Specific Language (DSL) for building language patterns. These can be later compiled into spaCy patterns, pure regex, or any other format
A Domain Specific Language (DSL) for building language patterns. These can be later compiled into spaCy patterns, pure regex, or any other format

RITA DSL This is a language, loosely based on language Apache UIMA RUTA, focused on writing manual language rules, which compiles into either spaCy co

Indobenchmark are collections of Natural Language Understanding (IndoNLU) and Natural Language Generation (IndoNLG)

Indobenchmark Toolkit Indobenchmark are collections of Natural Language Understanding (IndoNLU) and Natural Language Generation (IndoNLG) resources fo

LegalNLP - Natural Language Processing Methods for the Brazilian Legal Language

LegalNLP - Natural Language Processing Methods for the Brazilian Legal Language ⚖️ The library of Natural Language Processing for Brazilian legal lang

A design of MIDI language for music generation task, specifically for Natural Language Processing (NLP) models.

MIDI Language Introduction Reference Paper: Pop Music Transformer: Beat-based Modeling and Generation of Expressive Pop Piano Compositions: code This

This is the Alpha of Nutte language, she is not complete yet / Essa é a Alpha da Nutte language, não está completa ainda

nutte-language This is the Alpha of Nutte language, it is not complete yet / Essa é a Alpha da Nutte language, não está completa ainda My language was

Simple Python script to scrape youtube channles of "Parity Technologies and Web3 Foundation" and translate them to well-known braille language or any language

Simple Python script to scrape youtube channles of "Parity Technologies and Web3 Foundation" and translate them to well-known braille language or any

Owner
THU-KEG
THU-KEG
A Survey of Natural Language Generation in Task-Oriented Dialogue System (TOD): Recent Advances and New Frontiers

A Survey of Natural Language Generation in Task-Oriented Dialogue System (TOD): Recent Advances and New Frontiers

Libo Qin 132 Nov 25, 2022
EMNLP'2021: Can Language Models be Biomedical Knowledge Bases?

BioLAMA BioLAMA is biomedical factual knowledge triples for probing biomedical LMs. The triples are collected and pre-processed from three sources: CT

DMIS Laboratory - Korea University 41 Nov 18, 2022
Watson Natural Language Understanding and Knowledge Studio

Material de demonstração dos serviços: Watson Natural Language Understanding e Knowledge Studio Visão Geral: https://www.ibm.com/br-pt/cloud/watson-na

Vanderlei Munhoz 4 Oct 24, 2021
The swas programming language

The Swas programming language This is a language that was made for fun. Installation Step 0: Make sure you have python installed Step 1. Clone this re

Swas.py 19 Jul 18, 2022
Implementation of Natural Language Code Search in the project CodeBERT: A Pre-Trained Model for Programming and Natural Languages.

CodeBERT-Implementation In this repo we have replicated the paper CodeBERT: A Pre-Trained Model for Programming and Natural Languages. We are interest

Tanuj Sur 4 Jul 1, 2022
A programming language with logic of Python, and syntax of all languages.

Pytov The idea was to take all well known syntaxes, and combine them into one programming language with many posabilities. Installation Install using

Yuval Rosen 14 Dec 7, 2022
PUA Programming Language written in Python.

pua-lang PUA Programming Language written in Python. Installation git clone https://github.com/zhaoyang97/pua-lang.git cd pua-lang pip install . Try

zy 4 Feb 19, 2022
Stack based programming language that compiles to x86_64 assembly or can alternatively be interpreted in Python

lang lang is a simple stack based programming language written in Python. It can

Christoffer Aakre 1 May 30, 2022
Opal-lang - A WIP programming language based on Python

thanks to aphitorite for the beautiful logo! opal opal is a WIP transcompiled pr

null 3 Nov 4, 2022