Skip to content

Commit f33e095

Browse files
docs: add negative feedback documentation (#134)
1 parent 5646763 commit f33e095

7 files changed

Lines changed: 173 additions & 23 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Gorse Docs
22

3-
[![Netlify Status](https://api.netlify.com/api/v1/badges/2480ea13-f8c7-4c84-aa77-51f105ac5bbf/deploy-status)](https://app.netlify.com/sites/gorse-io/deploys)
43

54
Official documents for Gorse recommender system.
65

Lines changed: 94 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,94 @@
1-
import { type FunctionalComponent, h } from "vue";
2-
3-
const TwitterLink: FunctionalComponent = () =>
4-
h(
5-
"div",
6-
{ class: "vp-nav-item vp-action" },
7-
h("a", {
8-
class: "vp-action-link",
9-
href: "https://gorse.io/weixin.jpg",
10-
target: "_blank",
11-
rel: "noopener noreferrer",
12-
"aria-label": "wechat",
13-
innerHTML:
14-
'<i class="iconfont icon-wechat-fill"></i>',
15-
})
16-
);
17-
18-
TwitterLink.displayName = "DiscordLink";
19-
20-
export default TwitterLink;
1+
import { defineComponent, h, onBeforeUnmount, onMounted, ref } from "vue";
2+
3+
export default defineComponent({
4+
name: "WeChatLink",
5+
setup() {
6+
const containerRef = ref<HTMLElement | null>(null);
7+
const showPopup = ref(false);
8+
9+
const togglePopup = () => {
10+
showPopup.value = !showPopup.value;
11+
};
12+
13+
const closePopup = () => {
14+
showPopup.value = false;
15+
};
16+
17+
const handleDocumentClick = (event: MouseEvent) => {
18+
const target = event.target;
19+
20+
if (
21+
showPopup.value &&
22+
target instanceof Node &&
23+
containerRef.value &&
24+
!containerRef.value.contains(target)
25+
) {
26+
closePopup();
27+
}
28+
};
29+
30+
onMounted(() => {
31+
document.addEventListener("click", handleDocumentClick);
32+
});
33+
34+
onBeforeUnmount(() => {
35+
document.removeEventListener("click", handleDocumentClick);
36+
});
37+
38+
return () =>
39+
h(
40+
"div",
41+
{
42+
ref: containerRef,
43+
class: "vp-nav-item vp-action wechat-container",
44+
style: { position: "relative" },
45+
},
46+
[
47+
h("a", {
48+
class: "vp-action-link",
49+
href: "#",
50+
"aria-label": "wechat",
51+
onClick: (e: Event) => {
52+
e.preventDefault();
53+
togglePopup();
54+
},
55+
innerHTML: '<i class="iconfont icon-wechat-fill"></i>',
56+
}),
57+
showPopup.value
58+
? h(
59+
"div",
60+
{
61+
class: "wechat-popup",
62+
style: {
63+
position: "absolute",
64+
top: "100%",
65+
right: "0",
66+
marginTop: "8px",
67+
padding: "16px",
68+
zIndex: "100",
69+
},
70+
},
71+
[
72+
h("img", {
73+
src: "https://gorse.io/weixin.jpg",
74+
alt: "WeChat QR Code",
75+
style: {
76+
width: "150px",
77+
height: "150px",
78+
display: "block",
79+
},
80+
}),
81+
h(
82+
"div",
83+
{
84+
class: "wechat-popup-text",
85+
},
86+
"扫码关注公众号"
87+
),
88+
]
89+
)
90+
: null,
91+
]
92+
);
93+
},
94+
});

src/.vuepress/styles/index.scss

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
11
// place your custom styles here
2+
3+
// WeChat popup styles
4+
.wechat-container {
5+
position: relative;
6+
}
7+
8+
.wechat-popup {
9+
animation: fadeIn 0.2s ease-in-out;
10+
border: 1px solid var(--vp-c-border);
11+
border-radius: 8px;
12+
background: var(--vp-c-bg);
13+
box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
14+
text-align: center;
15+
}
16+
17+
.wechat-popup img {
18+
border-radius: 4px;
19+
}
20+
21+
.wechat-popup-text {
22+
margin-top: 8px;
23+
font-size: 14px;
24+
color: var(--vp-c-text-mute);
25+
}
26+
27+
@keyframes fadeIn {
28+
from {
29+
opacity: 0;
30+
transform: translateY(-8px);
31+
}
32+
to {
33+
opacity: 1;
34+
transform: translateY(0);
35+
}
36+
}

src/docs/concepts/data-source.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,25 @@ Before inserting feedback into the Gorse recommender system, it is necessary to
8686
- **Read Feedback:** The user sees the item.
8787
- **Positive feedback:** The user action that is expected to do by the service provider.
8888

89+
### Negative Feedback
90+
91+
Negative feedback represents explicit user dislike or disinterest in an item. Unlike read feedback (which indicates the user simply viewed an item), negative feedback explicitly tells the recommender system that the user does not want to see similar items in the future.
92+
93+
Common examples of negative feedback include:
94+
- **Dislike button**: User clicks a "dislike" or "thumbs down" button
95+
- **Not interested**: User selects "not interested" or "hide this" option
96+
- **Explicit removal**: User removes an item from their recommendations
97+
98+
Negative feedback has the **highest priority** in the recommendation system. When a user gives negative feedback to an item:
99+
- The item will never be recommended to that user again
100+
- Similar items will be deprioritized in recommendations
101+
102+
To configure negative feedback, add the feedback type to `negative_feedback_types` in the configuration:
103+
104+
::: warning
105+
Negative feedback should be used sparingly. Only configure truly negative actions as negative feedback. Actions like "skip" or "close" should be treated as read feedback, not negative feedback.
106+
:::
107+
89108
### Insert Feedback
90109

91110
There are two ways to insert feedback into the Gorse recommender system: inserting new feedback and updating existing feedback. Inserting new feedback is done via the `PUT /api/feedback` API, while updating existing feedback is done via the `POST /api/feedback` API. Both APIs accept a list of feedback in JSON format.
@@ -162,6 +181,7 @@ There are several configuration options related to data source in Gorse:
162181

163182
- `positive_feedback_types`: A list of feedback types that are considered positive feedback.
164183
- `read_feedback_types`: A list of feedback types that are considered read feedback.
184+
- `negative_feedback_types`: A list of feedback types that are considered negative feedback.
165185
- `positive_feedback_ttl`: Time-to-live for positive feedback in days. After this period, positive feedback will be ignored in recommendations. Default value: `0` (no expiration).
166186
- `item_ttl`: Time-to-live for items in days. After this period, items will be automatically hidden from recommendations. Default value: `0` (no expiration).
167187

@@ -171,11 +191,12 @@ TTL is used to automatically remove old feedback and items from the recommender
171191

172192
## Example
173193

174-
In the demo project [GitRec](https://gitrec.gorse.io/), the following configuration is used to define positive feedback as "star", "like", and "read" with a value greater than or equal to 3. Read feedback is defined as "read". Both positive feedback and items do not expire.
194+
In the demo project [GitRec](https://gitrec.gorse.io/), the following configuration is used to define positive feedback as "star", "like", and "read" with a value greater than or equal to 3. Read feedback is defined as "read". Negative feedback is defined as "dislike". Both positive feedback and items do not expire.
175195

176196
```toml
177197
[recommend.data_source]
178198
positive_feedback_types = ["star","like","read>=3"]
199+
negative_feedback_types = ["dislike"]
179200
read_feedback_types = ["read"]
180201
positive_feedback_ttl = 0
181202
item_ttl = 0

src/docs/config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ Configuration for [data source](./concepts/data-source) of recommenders.
149149
|---------------------------|--------|---------|-----------------------------------|
150150
| `positive_feedback_types` | string | | Types of positive feedback |
151151
| `read_feedback_types` | string | | Type of read feedback |
152+
| `negative_feedback_types` | string | | Types of negative feedback |
152153
| `positive_feedback_ttl` | string | `0` | Time-to-live of positive feedback |
153154
| `item_ttl` | string | `0` | Time-to-live of items |
154155

src/zh/docs/concepts/data-source.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,23 @@ type Feedback struct {
8686
- **已读反馈:** 用户看到物品。
8787
- **积极反馈:** 服务提供商期望用户执行的操作。
8888

89+
### 负反馈
90+
91+
负反馈表示用户对物品的明确不喜欢或不感兴趣。与已读反馈(仅表示用户查看了物品)不同,负反馈明确告诉推荐系统用户将来不想看到类似的物品。
92+
93+
常见的负反馈示例包括:
94+
- **不喜欢按钮**:用户点击"不喜欢"或"踩"按钮
95+
- **不感兴趣**:用户选择"不感兴趣"或"隐藏此内容"选项
96+
- **明确移除**:用户从推荐中移除物品
97+
98+
负反馈在推荐系统中具有**最高优先级**。当用户对物品给出负反馈时:
99+
- 该物品将永远不会再次推荐给该用户
100+
- 相似物品在推荐中的优先级会降低
101+
102+
::: warning
103+
负反馈应谨慎使用。只应将真正负面的操作配置为负反馈。如"跳过"或"关闭"等操作应视为已读反馈,而非负反馈。
104+
:::
105+
89106
### 插入反馈
90107

91108
有两种方法可以将反馈插入 Gorse 推荐系统:插入新反馈和更新现有反馈。插入新反馈通过 `PUT /api/feedback` API 完成,而更新现有反馈通过 `POST /api/feedback` API 完成。两个 API 都接受 JSON 格式的反馈列表。
@@ -162,6 +179,7 @@ Gorse 中有几个与数据源相关的配置选项:
162179

163180
- `positive_feedback_types`: 被视为积极反馈的反馈类型列表。
164181
- `read_feedback_types`: 被视为已读反馈的反馈类型列表。
182+
- `negative_feedback_types`: 被视为负反馈的反馈类型列表。
165183
- `positive_feedback_ttl`: 积极反馈的生存时间(天)。在此期限后,积极反馈将在推荐中被忽略。默认值:`0`(无过期)。
166184
- `item_ttl`: 物品的生存时间(天)。在此期限后,物品将自动从推荐中隐藏。默认值:`0`(无过期)。
167185

@@ -171,12 +189,13 @@ TTL 用于自动从推荐系统中删除旧的反馈和物品,以确保推荐
171189

172190
## 示例
173191

174-
在演示项目 [GitRec](https://gitrec.gorse.io/) 中,使用以下配置将积极反馈定义为star”、“like和值大于或等于 3 的read。已读反馈定义为read。积极反馈和物品都不会过期。
192+
在演示项目 [GitRec](https://gitrec.gorse.io/) 中,使用以下配置将积极反馈定义为"star"、"like"和值大于或等于 3 的"read"。已读反馈定义为"read"。负反馈定义为"dislike"。积极反馈和物品都不会过期。
175193

176194
```toml
177195
[recommend.data_source]
178196
positive_feedback_types = ["star","like","read>=3"]
179197
read_feedback_types = ["read"]
198+
negative_feedback_types = ["dislike"]
180199
positive_feedback_ttl = 0
181200
item_ttl = 0
182201
```

src/zh/docs/config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ chhttps://user:password@host[:port]/database?param1=value1&...&paramN=valueN
149149
|---------------------------|--------|-----|-----------|
150150
| `positive_feedback_types` | string | | 积极反馈的类型 |
151151
| `read_feedback_types` | string | | 已读反馈的类型 |
152+
| `negative_feedback_types` | string | | 负反馈的类型 |
152153
| `positive_feedback_ttl` | string | `0` | 积极反馈的生存时间 |
153154
| `item_ttl` | string | `0` | 物品的生存时间 |
154155

0 commit comments

Comments
 (0)