-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakePatentSabae.js
More file actions
31 lines (29 loc) · 1.02 KB
/
makePatentSabae.js
File metadata and controls
31 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { dir2array } from "https://js.sabae.cc/dir2array.js";
import { ZenkakuAlpha } from "https://code4fukui.github.io/mojikiban/ZenkakuAlpha.js";
import { CSV } from "https://js.sabae.cc/CSV.js";
const savePatent = async (path, type_ja, type) => {
const fns = await dir2array(path);
const res = [];
for (const f of fns) {
if (!f.endsWith(".json")) {
continue;
}
const d = JSON.parse(await Deno.readTextFile(path + f));
const set = {};
for (const p of d.patent) {
if (p.patent_type == type_ja) {
const title = ZenkakuAlpha.toHan(p.title);
const company = ZenkakuAlpha.toHan(d.name);
set[p.title] = { date: p.application_date, title, company };
}
}
for (const name in set) {
res.push(set[name]);
}
}
res.sort((a, b) => -a.date.localeCompare(b.date));
await Deno.writeTextFile(path + "../" + type + ".csv", CSV.stringify(res));
};
const path = "data/18207/info/";
await savePatent(path, "商標", "trademark");
await savePatent(path, "特許", "patent");