Package 'TangPoemR'

Title: Write Chinese Tang Poems
Description: Write Chinese Tang Poems automatically.
Authors: Yanni Li, Yongyuan Liang
Maintainer: Yongyuan Liang <[email protected]>
License: GPL (>= 2)
Version: 0.1.0
Built: 2024-12-14 06:27:31 UTC
Source: CRAN

Help Index


Write Chinese Tang Poems

Description

The package helps generate Chinese Tang poems automatically.

Details

We created our poems dataset from Three Hundred Tang Poems:

#import the file "Three Hundred Tang Poems"

fileName <-"Three Hundred Tang Poems.txt"

SC <- readChar(fileName, file.info(fileName)$size)

#the process of text segmentation

library(jiebaR)

cc = worker()

analysis <- as.data.frame(table(cc[SC]))

names(analysis) <- c("word","freq")

analysis$word <- as.character(analysis$word)

#set the example poems sp5, sp7

tagger <- worker("tag")

sp5_2 <- tagger <= sp5

sp7_2 <- tagger <= sp7

example <- subset(analysis, freq >1 & nchar(word) <3 & freq < 300)

#extract the examples' parts of speech

cixing5 <- attributes(sp5_2)$names

cixing7 <- attributes(sp7_2)$names

#get the dataset

example_2 <- tagger <= example$word

Now, with our dataset, this package can automatically generate Chinese Tang poems of our specified length(5 or 7).

Value

no return

Note

The package helps people experience Chinese ancient poetry culture with R.

Author(s)

Yanni Li, Yongyuan Liang

References

nothing

See Also

nothing

Examples

write_tangpoem(5)

Write Chinese Tang Poems

Description

This package write Chinese Tang Poems automatically

Usage

write_tangpoem(n)

Arguments

n

should be the length of the poem

Examples

write_tangpoem(5)