Skip to content

Commit

Permalink
Small fixes and improvmenets
Browse files Browse the repository at this point in the history
  • Loading branch information
Ackuq committed Sep 17, 2023
1 parent e50a435 commit 9ff93eb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 20 deletions.
41 changes: 26 additions & 15 deletions packages/party-data/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import {
readSubjects,
updateStandpoint,
} from ".";
import type { Standpoint } from "./client";

const promptTemplate = (
standpoint: Standpoint,
) => `Please categorize the following standpoint
URL: ${standpoint.url}
Title: ${standpoint.title}
Opinions:
${standpoint.opinions.map((opinion) => ` * ${opinion}`).join("\n")}
`;

async function categorize() {
const subjects = readSubjects();
Expand All @@ -15,22 +25,20 @@ async function categorize() {
}));

for (const standpoint of standpoints) {
const prompt = promptTemplate(standpoint);
const choice = await select(
{
message: `
URL: ${standpoint.url}
Title: ${standpoint.title}
Opinions:
${standpoint.opinions.map((opinion) => `\t${opinion}`).join("\n")}`,
message: prompt,
choices: [
new Separator(),
{
name: "-- Skip --",
value: undefined,
},
new Separator(),
...subjectChoices,
],
pageSize: subjectChoices.length,
pageSize: subjects.length + 3,
},
{ clearPromptOnDone: true },
);
Expand All @@ -44,15 +52,18 @@ enum Action {
}

async function main() {
const choice = await select({
message: "What do you want to do",
choices: [
{
value: Action.Categorize,
description: "Categorize uncategorized standpoints",
},
],
});
const choice = await select(
{
message: "What do you want to do",
choices: [
{
value: Action.Categorize,
description: "Categorize uncategorized standpoints",
},
],
},
{ clearPromptOnDone: true },
);
switch (choice) {
case Action.Categorize:
categorize();
Expand Down
14 changes: 9 additions & 5 deletions packages/party-data/parties/s.json
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,8 @@
"title": "Försvar och krisberedskap",
"url": "https://www.socialdemokraterna.se/var-politik/a-till-o/forsvar-och-krisberedskap",
"fetchDate": "2023-09-17T17:52:38.797Z",
"party": "s"
"party": "s",
"subject": "Försvar"
},
"https://www.socialdemokraterna.se/var-politik/a-till-o/foraldraforsakring": {
"opinions": [
Expand All @@ -718,7 +719,8 @@
"title": "Föräldraförsäkring",
"url": "https://www.socialdemokraterna.se/var-politik/a-till-o/foraldraforsakring",
"fetchDate": "2023-09-17T17:52:39.225Z",
"party": "s"
"party": "s",
"subject": "Familjen"
},
"https://www.socialdemokraterna.se/var-politik/a-till-o/gymnasieskola": {
"opinions": [
Expand Down Expand Up @@ -769,7 +771,8 @@
"title": "Havsmiljö",
"url": "https://www.socialdemokraterna.se/var-politik/a-till-o/havsmiljo",
"fetchDate": "2023-09-17T17:52:37.629Z",
"party": "s"
"party": "s",
"subject": "Miljö och klimat"
},
"https://www.socialdemokraterna.se/var-politik/a-till-o/hbtq-fragor": {
"opinions": [
Expand All @@ -784,7 +787,8 @@
"title": "HBTQ+frågor",
"url": "https://www.socialdemokraterna.se/var-politik/a-till-o/hbtq-fragor",
"fetchDate": "2023-09-17T17:52:37.733Z",
"party": "s"
"party": "s",
"subject": "Jämställdhet och diskriminering"
},
"https://www.socialdemokraterna.se/var-politik/a-till-o/heltid-och-deltid": {
"opinions": [
Expand Down Expand Up @@ -2025,4 +2029,4 @@
"fetchDate": "2023-09-17T17:52:38.986Z",
"party": "s"
}
}
}

0 comments on commit 9ff93eb

Please sign in to comment.