改变你对文本生成程序的误解!用C++标准库,MinGW情况下,写一个文本生成器(一种AI)

声明:我这个不是那种“文本生成器”

我之前见过那种“自动写作文”的程序,无非就是这样的文章:

在这里插入图片描述

文章写的只有主题,没有内容

我曾多次向我的朋友提问他们看没看过那种AI写作的代码,而给我的回复很简单:你弄那玩楞干哈?装*?那玩楞我见过,写的文章空有其表,没有其实;你别在上面浪费时间!咱学的是C++,写不出来真正的AI !

我起先认为他们错了,因为当时我在脑子里已经有了一个AI的构思,然后我到处查资料,却发现,C++标准库貌似确实无法支撑一个AI正常地诞生,那…我用第三方库可以吗?

貌似不太可行,我用的是MinGW编译器,而目前的硬盘空间不足以支持我安装VSC++

在这里插入图片描述
在这里插入图片描述

难道,我要就此放弃了吗?

不!

第三方库也是人写出来的呀,我可以自己手搓啊!

然后,我就开始了编写

首先,我寻思这能够跟GPT媲美的AI我肯定是写不出来

那可以退而求其次,做一个文本生成器呀

其次,我想这AI开发出来之后也不一定能用,——没有数据库

我首先想到的是:“装一个数据库”

but,我当时貌似忘记了我MinGW的事情

然后,我想:数据库也是人写的,我没法跟人家写的一样好,照葫芦画瓢总该会吧?

然后我就着手进入这个项目了

我用了3个库文件,分别是:

  1. scentences_templete.h
  2. word_classes.h
  3. word_read.h

我并没有写主程序,我只是把库文件写出来了,大家一读就知道怎么用了

现在,到了喜闻乐见的开源时间

word_classes.h

#include<iostream>
#include<cstring>
#include<map>

#define __REAL__ 1
#define __XI__ 2
#define __COUNTABLE__ 3
#define __UNCOUNTABLE__ 4
#define __SIZE_BIG__ 5
#define __SIZE_SMALL__ 6
#define __TIME_MONTH__ 7
#define __TIME_DAY__ 8
#define __TIME_SPECIAL_DAY__ 9
#define __TIME_CLEAR_TIME__ 10
#define __OBJECT_HUMAN__ 11
#define __OBJECT_HUMAN_THING__ 13
#define __OBJECT_THING__ 12
#define __commendatory__ 13
#define __derogatory__ 14
#define __medium__ 15
#define __TYPE_1__ 15
#define __TYPE_2__ 16
#define __TYPE_3__ 17
#define __TYPE_4__ 28
#define __LONELY__ 18
#define __PL_ 19
#define __WHAT_WHAT__ 20
#define __WHAT_WHO__ 21
#define __WHAT_HOW__ 22
#define __WHAT_WHICH__ 23
#define __WHAT_HOWMUCH__ 24
#define __WHAT_HOWLONG__ 25
#define __WHAT_WHATTIME__ 26
#define __WHAT_WHY__ 27
#define __writer__ "YZX,CSDN-蒟蒻&大佬"
using namespace std;

class V;
class N;
class PL;
class TM;
class ADJ;
class ADV;
class PRON;
class PREP;
class WORDS;

class V{
   
	public:
		string shap;
		int type;//实义/系动词
		string TPSF;//三单
		string ED;//过去
		string ING;//进行
		string DONE;//过去分词
};
class N{
   
	public:
		string shap;
		string pl;//复数
		int C_UC;//是否可数
};
class PL{
   //地点
	public:
		string shap;
		int _size_type;
};
class TM{
   //时间
	public:
		string shap;
		int time_type;
};
class ADJ{
   
	public:
		string shap;
		int object;
		int YN_commendatory;//褒贬
};
class ADV{
   
	public:
//		ADJ*adj;//对应的形容词***指针问题无法解决
		string shap;
};
class PRON{
   
	public:
		string Main;//主格
		string Accusative;//宾格
		string n_Pos_pron;//名词性物主代词
		string adj_Pos_pron;//形容词性物主代词
		int type;//第几人称
		bool num;//单数复数
};
class PREP{
   //介词
	public:
		string shap;
		int _size_type;//所形容地点的种类
		int time_type;//所形容时间的种类
};
class CON{
   //连词
	public:
		string shap;
};
class WORDS{
   
	public:
		string WRITER="YZX,CSDN-蒟蒻&大佬";
		int adj_num;
		int adv_num;
		int verb_num;
		int nouns_num;
		int pls_num;
		int tm_num;
		int pron_num;
		int prep_num;
		int what_num;
		int con_num;
		string VERBS[1000];//
		map<string,V>verbs;//
		string NOUNS[1000];//
		map<string,N>nouns;//
		string PLS[1000];//
		map<string,PL>pls;//
		string TMS[1000];//
		map<string,TM>times;//
		string ADJS[1000];//
		map<string,ADJ>adjs;//
		string ADVS[1000];//
		map<string,ADV>advs;//
		string PRONS[100];//
		map<string,PRON>prons;//
		string PREPS[1000];//
		map<string,PREP>preps;//
		string WHATS[100];//
		string CONS[100];//
};

scentences_templete.h

#include"word_classes.h"
#include<time.h>
#include<random>
#define __SCENTENCES_1__ 1
#define __SCENTENCES_2__ 2
#define __SCENTENCES_3__ 3
#define __STM_ED__ 1
#define __STM_WILL__ 1
#define __STM_NOW__ 2
#define __STM_ING__ 3
#define NUM 9
using namespace std;
random_device rnd;
mt19937 generator(rnd());
string templates(WORDS word){
   
	string ret;
	PRON subject;
	int subject_type=rand()%5+1;
	if(subject_type==1){
   
		subject_type=__TYPE_1__;
		if(rand()%2==1){
   
			subject=word.prons["I"];
		}
		else{
   
			subject=word.prons["we"];
		}
	}
	else if(subject_type==2
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值