From 36f9606188019a77174bac723c9caacd32d9ba79 Mon Sep 17 00:00:00 2001 From: kavos Date: Sun, 18 Aug 2024 12:31:12 +0900 Subject: [PATCH] python code --- src/tag/keytest.py | 1 + src/tag/keyword.py | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 src/tag/keytest.py create mode 100644 src/tag/keyword.py diff --git a/src/tag/keytest.py b/src/tag/keytest.py new file mode 100644 index 0000000..b692a14 --- /dev/null +++ b/src/tag/keytest.py @@ -0,0 +1 @@ +import pke diff --git a/src/tag/keyword.py b/src/tag/keyword.py new file mode 100644 index 0000000..91c93c1 --- /dev/null +++ b/src/tag/keyword.py @@ -0,0 +1,9 @@ +import pke + +extractor = pke.unsupervised.TopicRank() + +def keyword_extract(text, n): + extractor.load_document(input=text, language='ja') + extractor.candidate_selection(pos={'NOUN', 'PROPN'}) + extractor.candidate_weighting() + return extractor.get_n_best(n=n) \ No newline at end of file