代码拉取完成,页面将自动刷新
同步操作将从 一个杀手/smart_control 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* @Author: your name
* @Date: 2021-09-02 10:13:47
* @LastEditTime: 2021-09-02 10:50:55
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \smart_control\main\app\etymology.c
*/
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
struct time
{
unsigned short day : 2;
unsigned short sig : 1;
unsigned short hour : 4;
unsigned short min : 9;
};
typedef struct time time_tt;
struct order
{
time_tt time;
unsigned short obj:3;
unsigned short action:13;
};
typedef struct order order_t; //4字节
static int do_object(char *p)
{
int obj = -1;
if (strstr(p, "天气"))
{
obj = 1;
}
if (strstr(p, "空调"))
{
obj = 2;
}
if (strstr(p, "蓝牙"))
{
obj = 3;
}
return obj;
}
static int do_action(char *p)
{
int action = -1;
if (strstr(p, "打开") || strstr(p, "设置"))
{
action = 1;
}
if (strstr(p, "关闭"))
{
action = 0;
}
return action;
}
static time_tt do_time(char *p)
{
time_tt t;
if (strstr(p, "明天"))
{
t.day = 1;
}
if (strstr(p, "后天"))
{
t.day = 2;
}
if (strstr(p, "今天"))
{
t.day = 0;
}
if (strstr(p, "早上"))
{
t.sig = 0;
}
if (strstr(p, "下午") || strstr(p, "晚上"))
{
t.sig = 1;
}
if (strstr(p, "点"))
{
char numstr[3] = {0};
char *w = numstr;
char *r = strstr(p, "点") - 2;
if (*r > 47 && *r < 58)
{
*w = *r;
w++;
}
r++;
*w = *r;
t.hour = atoi(numstr);
printf("%d点", t.hour);
}
if (strstr(p, "分"))
{
char numstr[3] = {0};
char *w = numstr;
char *r = strstr(p, "分") - 2;
if (*r > 47 && *r < 58)
{
*w = *r;
w++;
}
r++;
*w = *r;
t.min = atoi(numstr);
printf("%d分", t.min);
}
return t;
}
order_t etymology(char *s)
{
order_t ord;
ord.obj = do_object(s);
ord.action = do_action(s);
ord.time = do_time(s);
return ord;
}
int main()
{
char *s = "明天早上8点30分关闭空调";
order_t ord=etymology(s);
printf("%d %d %d %d", ord.time.day, ord.time.sig, ord.time.hour, ord.time.min);
return 1;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。