Skip to content

Commit

Permalink
refactor: update docs and adjust pages (#17)
Browse files Browse the repository at this point in the history
* new doc

* refactor: update docs

* refactor: update pages

---------

Co-authored-by: fuyu.bfy <fuyu.bfy@antgroup.com>
  • Loading branch information
Aarebecca and baifuyu authored Jan 9, 2024
1 parent 6015839 commit c5440ec
Show file tree
Hide file tree
Showing 59 changed files with 5,031 additions and 194 deletions.
18 changes: 18 additions & 0 deletions .dumi/components/Redirect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Spin } from 'antd';
import { useLocale } from 'dumi';
import { useEffect } from 'react';

export const Redirect = ({ url }: { url: string }) => {
const { id: lang } = useLocale();

useEffect(() => {
window.location.replace(url);
}, []);

return (
<div style={{ display: 'flex', justifyContent: 'center', gap: 15 }}>
<Spin />
{lang === 'zh-CN' ? '跳转中...' : 'Redirecting...'}
</div>
);
};
9 changes: 9 additions & 0 deletions .dumi/pages/openkg.en-US.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* title: OpenKG
* nav:
* order: 5
*/

import OpenKG from './openkg';

export default OpenKG;
11 changes: 11 additions & 0 deletions .dumi/pages/openkg.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* title: OpenKG
* nav:
* order: 5
*/

import { Redirect } from '../components/Redirect';

export default () => {
return <Redirect url="http://openkg.cn/" />;
};
37 changes: 0 additions & 37 deletions .dumi/theme/layouts/GlobalLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,48 +1,11 @@
import { useLocale, useOutlet, usePrefersColor } from 'dumi';
import { Provider } from 'dumi-theme-openfinai';
import { useEffect, useRef } from 'react';

// insert github and openKG in navbar
const createLink = (name: string, link: string, index: number) => {
const nav = document.getElementsByClassName('dumi-default-navbar')?.[0];
if (!nav) return;

const xpath = `//*[text()='${name}']`;
const element = document.evaluate(
xpath,
nav,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null,
).singleNodeValue;
if (element) return;

const li = document.createElement('li');
const a = document.createElement('a');
a.innerText = name;
a.href = link;
a.target = '_blank';
a.rel = 'noopener noreferrer';
li.appendChild(a);
nav.insertBefore(li, nav.childNodes[index]);

return true;
};

export default () => {
const { id: lang } = useLocale();
const createLinkIntervalRef = useRef<number>();
const outlet = useOutlet();
const [prefersColor] = usePrefersColor();

useEffect(() => {
createLinkIntervalRef.current = window.setInterval(() => {
createLink('GitHub', 'https://github.com/OpenSPG/openspg', 1);
const result = createLink('OpenKG', 'http://openkg.cn/', 5);
if (result) clearInterval(createLinkIntervalRef.current);
}, 50);
}, []);

return (
<Provider
lang={lang}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CSF0000000254,北大*药*份限公司,"医疗器械批发,医药批发,制药,

The code for importing `Company` instances is as follows, with detailed explanations provided in the comments:

```python
````python
# -*- coding: utf-8 -*-

from knext.core.builder.pipeline.builder_job import BuilderJob
Expand All @@ -33,7 +33,7 @@ class Company(BuilderJob):
parallelism = 6

```
Create a construction task pipeline, which should have a source node and a sink node.
Create a construction task pipeline, which should have a source node and a sink node.
Here, the mapping node is a structured data mapping node.
```
def build(self):
Expand Down Expand Up @@ -86,7 +86,7 @@ class CompanyFundTrans(BuilderJob):

return source >> mapping >> sink

```
````

To submit the task, execute the following command:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CSF0000000254,北大*药*份限公司,"医疗器械批发,医药批发,制药,

导入company的代码如下,详细内容如注释:

```python
````python
# -*- coding: utf-8 -*-

from knext.core.builder.pipeline.builder_job import BuilderJob
Expand Down Expand Up @@ -85,7 +85,7 @@ class CompanyFundTrans(BuilderJob):

return source >> mapping >> sink

```
````

在knext中执行如下命令提交任务:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ CSF0000002238,三角*胎股*限公司,"轮胎,全钢子午线轮胎"
- name: The name of the company.
- products: The products produced by the company, separated by ','.


## 3 Transfer relation between companys (Company_fundTrans_Company.csv)

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ order: 1

## 1 Schema details

Schema tutorial of OpenSPG, please refer to [spgschema_tutorial](../../tutorial/spgschema/index.en-US.md). <br>
Schema tutorial of OpenSPG, please refer to [spgschema_tutorial](../../tutorial_deprecated/spgschema/index.en-US.md). <br>
For modeling of the Enterprise Supply Chain Knowledge Graph, please refer to the documentation:[schema description](https://github.com/OpenSPG/openspg/blob/master/python/knext/examples/supplychain/schema/supplychain.schema). <br>
Execute the following script to complete schema creation: <br>

Expand Down Expand Up @@ -48,7 +48,7 @@ Product(产品): EntityType
name(产品名): Text
relations:
isA(上位产品): Product

Company(企业): EntityType
relations:
product(经营产品): Product
Expand All @@ -66,8 +66,8 @@ CSF0000000254,北大*药*份限公司,其他化学药品

This approach has two disadvantages: <br>

1) The raw data needs to be cleaned and converted into multiple rows. <br>
2) It requires adding and maintaining relation data. When the original data changes, the existing relations need to be deleted and new data needs to be added, which can lead to data errors. <br>
1. The raw data needs to be cleaned and converted into multiple rows. <br>
2. It requires adding and maintaining relation data. When the original data changes, the existing relations need to be deleted and new data needs to be added, which can lead to data errors. <br>

#### 2.1.3 Modeling based on SPG semantic attributes

Expand All @@ -77,7 +77,7 @@ The modeling can be done as follows: <br>
```yaml
Product(产品): ConceptType
hypernymPredicate: isA

Company(企业): EntityType
properties:
product(经营产品): Product
Expand Down Expand Up @@ -151,7 +151,7 @@ OpenSPG distinguishes between concepts and entities to decouple semantics from d
```yaml
Product(产品): ConceptType
hypernymPredicate: isA

Company(企业): EntityType
properties:
product(经营产品): Product
Expand All @@ -167,12 +167,12 @@ The representation of events with multiple elements is indeed a type of lossless
```yaml
Event(事件):
properties:
eventTime(发生时间): Long
subject(涉事主体): Text
object(客体): Text
place(地点): Text
industry(涉事行业): Text
properties:
eventTime(发生时间): Long
subject(涉事主体): Text
object(客体): Text
place(地点): Text
industry(涉事行业): Text
```
This representation method is unable to capture the multidimensional associations of real events. OpenSPG provides event modeling that enables the association of multiple elements in an event, as shown below.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ order: 1

## 1 建模文件

建模描述文档参见[spg schema](../../tutorial/spgschema/index.md)
建模描述文档参见[spg schema](../../tutorial_deprecated/spgschema/index.md)

建模参考文件[企业供应链图谱schema](https://github.com/OpenSPG/openspg/blob/master/python/knext/examples/supplychain/schema/supplychain.schema)

Expand Down Expand Up @@ -49,7 +49,7 @@ Product(产品): EntityType
name(产品名): Text
relations:
isA(上位产品): Product

Company(企业): EntityType
relations:
product(经营产品): Product
Expand All @@ -71,15 +71,14 @@ CSF0000000254,北大*药*份限公司,其他化学药品

2)需要新增维护关系数据,当原始数据发生变更时,需要删除原有关系,再新增数据,容易导致数据错误。


#### 2.1.3 基于SPG语义属性建模

SPG支持语义属性,可简化知识构建,如下:

```yaml
Product(产品): ConceptType
hypernymPredicate: isA

Company(企业): EntityType
properties:
product(经营产品): Product
Expand Down Expand Up @@ -153,7 +152,7 @@ SPG区分了概念和实体,用于解耦语义和数据,如下:
```yaml
Product(产品): ConceptType
hypernymPredicate: isA

Company(企业): EntityType
properties:
product(经营产品): Product
Expand All @@ -170,12 +169,12 @@ Company(企业): EntityType
```yaml
Event(事件):
properties:
eventTime(发生时间): Long
subject(涉事主体): Text
object(客体): Text
place(地点): Text
industry(涉事行业): Text
properties:
eventTime(发生时间): Long
subject(涉事主体): Text
object(客体): Text
place(地点): Text
industry(涉事行业): Text
```
这种表达方式,是无法体现真实事件的多元关联性,SPG提供了事件建模,可实现事件多元要素的关联,如下:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ order: 4

Requirement: In enterprise credit rating, the following decision factors are needed: <br>

1) Primary supplier relations <br>
2) Industry of the products produced by the enterprise <br>
3) Transfer transaction records of funds for the past 1 month, 3 months, and 6 months <br>
4) Difference in funds flow for the past 1 month, 3 months, and 6 months <br>
5) Information on related companies controlled by the ultimate beneficial owner <br>
1. Primary supplier relations <br>
2. Industry of the products produced by the enterprise <br>
3. Transfer transaction records of funds for the past 1 month, 3 months, and 6 months <br>
4. Difference in funds flow for the past 1 month, 3 months, and 6 months <br>
5. Information on related companies controlled by the ultimate beneficial owner <br>

However, in the original knowledge graph, only fund transfer transactions and legal representative information are available, making it impossible to directly obtain the above features. This example demonstrates how to use OpenSPG to obtain these 5 features.

Expand Down Expand Up @@ -189,8 +189,8 @@ Obtaining specific features of a particular company through GQL using the follow
MATCH
(s:SupplyChain.Company)
RETURN
s.id, s.fundTrans1Month, s.fundTrans3Month,
s.fundTrans6Month, s.fundTrans1MonthIn, s.fundTrans3MonthIn,
s.id, s.fundTrans1Month, s.fundTrans3Month,
s.fundTrans6Month, s.fundTrans1MonthIn, s.fundTrans3MonthIn,
s.fundTrans6MonthIn, s.cashflowDiff1Month, s.cashflowDiff3Month, s.cashflowDiff6Month
```

Expand Down Expand Up @@ -218,6 +218,7 @@ RETURN
## Scenario 2: Change in the company's supply chain

Suppose that there is a change in the products produced by the company:

```
"钱****份限公司"发布公告,生产产品“三轮摩托车,二轮摩托车”变更为“两轮摩托车”,则"三角**轮胎股份"和钱"****份限公司"的主供应链关系自动断裂,"三角**轮胎股份"和"钱****份限公司"不再具有主供应链关系
```
Expand Down Expand Up @@ -267,7 +268,7 @@ Butadiene rubber costs rise, classified as an event of price increase in the sup
The logical rule expression is as follows: <br>

```
// When the attributes of ProductChainEvent satisfy the condition of price increase,
// When the attributes of ProductChainEvent satisfy the condition of price increase,
// the event is classified as a price increase event.
Define (e:ProductChainEvent)-[p:belongTo]->(o:`TaxonofProductChainEvent`/`价格上涨`) {
Structure {
Expand All @@ -287,7 +288,7 @@ Define (s:`TaxonofProductChainEvent`/`价格上涨`)-[p:leadTo]->(o:`TaxonofComp
Structure {
//1. Find the subject of the supply chain event, which is butadiene rubber in this case
//2. Identify the downstream products of butadiene rubber, which are bias tires in this case
//3. Identify all the companies that produce bias tires, which is "Triangle** Tire Co., Ltd." in this case
//3. Identify all the companies that produce bias tires, which is "Triangle** Tire Co., Ltd." in this case
(s)-[:subject]->[prod:Product]-[:hasSupplyChain]->(down:Product)<-[:product]-(c:Company)
}
Constraint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ Define (s:Compnay)-[p:sameLegalReprensentative]->(o:Company) {
MATCH
(s:SupplyChain.Company)
RETURN
s.id, s.fundTrans1Month, s.fundTrans3Month,
s.fundTrans6Month, s.fundTrans1MonthIn, s.fundTrans3MonthIn,
s.id, s.fundTrans1Month, s.fundTrans3Month,
s.fundTrans6Month, s.fundTrans1MonthIn, s.fundTrans3MonthIn,
s.fundTrans6MonthIn, s.cashflowDiff1Month, s.cashflowDiff3Month, s.cashflowDiff6Month
```

Expand Down Expand Up @@ -212,6 +212,7 @@ RETURN
## 场景2:企业供应链发生变化

假设供应链发生如下变化: <br>

```
"钱****份限公司"发布公告,生产产品“三轮摩托车,二轮摩托车”变更为“两轮摩托车”,则"三角**轮胎股份"和钱"****份限公司"的主供应链关系自动断裂,"三角**轮胎股份"和"钱****份限公司"不再具有主供应链关系
```
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Python code style generally requires adherence to the PEP 8 standard.

If you are using PyCharm for development, you can use the [BlackConnect](https://black.readthedocs.io/en/stable/integrations/editors.html) plugin to format your code.


#### Docstring

Use the Google style format for docstrings.
Expand All @@ -52,35 +51,36 @@ For issues related to functionality optimization, feature expansion, bug fixes,

## Development Process

* Switch to your development branch
- Switch to your development branch

```bash
git checkout -b your-branch
....
git add xxx
git commit -m "xxx"
```

* Develop your feature
- Develop your feature

* Add unit tests
- Add unit tests

* Submit a Pull Request (PR)
- Submit a Pull Request (PR)

* Handle conflicts
- Handle conflicts

```bash
git checkout your-branch
git rebase master # Make sure your local master branch is up to date
```

* Code review
- Code review

The code you submitted requires a code review to be mergeed into the master branch. Please be patient and wait.
We will assign relevant colleagues for code review.
If there is no response to your PR within two working days, please mention the relevant colleagues in your PR.
The comments related to the code review will be directly posted on the relevant PR or issue. If you find the suggestions reasonable, please update your code accordingly.

* Merge into the master branch
- Merge into the master branch

After the code review, we will arrange for further review by another colleague to ensure that each PR has at least two approvals before merging into the master.
During this process, there may be some suggestions for modifications. Please be patient and make the necessary changes.
Expand Down
Loading

0 comments on commit c5440ec

Please sign in to comment.