【Boost】:阶段性测试和阶段性代码合集(五)

news2024/10/5 16:30:52

阶段性测试和阶段性代码合集

  • 一.编写测试程序-server.cc
  • 二.一些问题
  • 三.完整源代码

在这里添加了一些打印信息,方便我们观察,由于比较分散就不一一列举,可以看下面的完整源代码。

一.编写测试程序-server.cc

1.原版

只是简单的测试,就不写过程了。

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

可以看到它把所有包含filename的文档直接打印出来了,很明显并不方便我们进行查阅,所以进行修改,让content只显示一部分即可。

2.修改版本

在searcher里建立获取摘要的过程。

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

二.一些问题

1.坑一:读取

这里我们直接使用cin读取是会出现问题的,因为当cin遇到空格时就会停止,所以如果一句话里有空格的话就会多次读取。下面进行修改,使用getline进行读取。

在这里插入图片描述

2.坑二:size_t是无符号整型

我们在取摘要时,用的是size_t,如果减数大于被减数它就会得出一个很大的数,所以我们把它改为加法比较。

在这里插入图片描述

3.坑三:大小写

我们在建立倒排索引时是忽略了大小写的,但是我们使用string.find()查找词时又是区分了大小写的,所以会导致查找错误。

在这里插入图片描述

在这里插入图片描述

进行改正,可以使用Boost库里提供的方法,这里我使用search。

在这里插入图片描述

在这里插入图片描述

三.完整源代码

在这里插入图片描述

index.hpp

#include <vector>
#include <iostream>
#include <string>
#include <unordered_map>
#include <fstream>
#include <mutex>
#include "util.hpp"

namespace ns_index
{
  // 正排索引
  struct DocInfo
  {
    std::string title;
    std::string content;
    std::string url;
    uint64_t id;
  };

  // 倒排索引
  struct InvertedElem
  {
    uint64_t id;
    std::string word; // 关键词
    int weight;       // 权重
  };

  typedef std::vector<InvertedElem> InvertedList;
  class Index
  {
  private:
    // 正排索引用数组,数组下标天然就是文档ID
    std::vector<DocInfo> forward_index; // 正排索引
    // 倒排索引是映射关系,一个关键字和一个(组)InvertedElem对应
    std::unordered_map<std::string, std::vector<InvertedElem>> inverted_index; // 倒排索引
  private:
    Index() {}
    Index(const Index &) = delete;
    Index &operator=(const Index &) = delete;

    static std::mutex mtx;  // 锁
    static Index *instance; // 单例指针
  public:
    static Index *GetInstance() // 获取单例接口
    {
      if (nullptr == instance) // 该判段是为了加速,防止堵塞
      {
        mtx.lock(); // 上锁
        if (nullptr == instance)
        {
          instance = new Index();
        }
        mtx.unlock(); // 解锁
      }
      return instance;
    }

    ~Index()
    {
    }

  public:
    // 根据doc_id找到文档内容
    DocInfo *GetForwardIndex(uint64_t doc_id)
    {
      if (doc_id >= forward_index.size())
      {
        std::cerr << "doc_id is not range!" << std::endl;
        return nullptr;
      }
      return &forward_index[doc_id];
    }
    // 根据关键字string,获得倒排拉链
    std::vector<InvertedElem> *GetInvertedList(const std::string &word)
    {
      auto iter = inverted_index.find(word);
      if (iter == inverted_index.end())
      {
        std::cerr << word << "have no Inverted" << std::endl;
        return nullptr;
      }

      return &(iter->second);
    }
    // 根据文档构建索引
    bool BuildIndex(const std::string &input)
    {
      // 构建读取文件对象
      std::ifstream in(input);
      if (!in.is_open())
      {
        std::cerr << input << " open err!!!!!" << std::endl;
        return false;
      }

      std::string line;
      int count = 0;
      while (getline(in, line))
      {
        DocInfo *doc = BuildForwardIndex(line); // 构建正排索引
        if (nullptr == doc)
        {
          std::cerr << "build:" << line << "error!" << std::endl;
          continue;
        }

        BuildInvertedIndex(*doc);
        count++;
        if (count % 50 == 0)
        {
          std::cout << "已经建立的索引文档:" << count << std::endl;
        }
      }
      return true;
    }

  private:
    // 建立正排索引
    DocInfo *BuildForwardIndex(const std::string &line)
    {
      std::vector<std::string> results;
      std::string sep = "\3";
      ns_util::StringUtil::Split(line, &results, sep); // 分割字符串
      if (results.size() != 3)
        return nullptr;

      // 进行填充
      DocInfo doc;
      doc.title = results[0];
      doc.content = results[1];
      doc.url = results[2];
      doc.id = forward_index.size(); // 用数组下标代表id

      forward_index.push_back(std::move(doc)); // 细节:加move避免拷贝
      return &(forward_index.back());
    }
    // 建立倒排索引
    bool BuildInvertedIndex(DocInfo &doc)
    {
      // 分词
      std::unordered_map<std::string, int> word_map; // 进行权重统计
      // 1.分title
      std::vector<std::string> title;
      ns_util::JiebaUtil::CutString(doc.title, &title);

      for (auto &s : title) // 标题为10
      {
        boost::to_lower(s); // 忽略大小写
        word_map[s] += 10;
      }

      // 2.分content
      std::vector<std::string> content;
      ns_util::JiebaUtil::CutString(doc.content, &content);

      for (auto &s : content) // 内容为1
      {
        boost::to_lower(s); // 忽略大小写
        word_map[s]++;
      }

      // 3.放入hash表中
      for (auto &word_pair : word_map)
      {
        InvertedElem item;
        item.id = doc.id;
        item.word = word_pair.first;
        item.weight = word_pair.second;

        inverted_index[word_pair.first].push_back(std::move(item)); // 细节避免拷贝
      }
    }
  };
  Index *Index::instance = nullptr; // 在类外初始化
  std::mutex Index::mtx;
}

makefile

.PHONY:all
all:parser search

search:server.cc
	g++ -o $@ $^ -ljsoncpp -std=c++11
parser:parser.cc
	g++ -o $@ $^ -lboost_system -lboost_filesystem -std=c++11 
.PHONY:clean
clean:
	rm -f parser search

parser.cc

include <iostream>
#include <vector>
#include <string>
#include <boost/filesystem.hpp>
#include "util.hpp"

const std::string src_path = "data/input/";         // 要读取的文件路径
const std::string output = "data/raw_html/raw.txt"; // 存放处理后文件路径

typedef struct DocInfo
{
  std::string title;   // 文档标题
  std::string content; // 文档内容
  std::string url;     // 文档路径
} DocInfo_t;

// const &:表示输入
//&:输入输出
//*:输出
bool EnumFile(const std::string &src_path, std::vector<std::string> *files_lists);
bool ParseHtml(const std::vector<std::string> &files_lists, std::vector<DocInfo_t> *results);
bool SaveHtml(const std::vector<DocInfo_t> &results, const std::string &output);

int main()
{
  // 第一步:读取目标文件的路径和文件名
  std::vector<std::string> files_lists;
  if (!EnumFile(src_path, &files_lists))
  {
    std::cerr << "enum file error" << std::endl;
    return 1;
  }

  // 第二步:把读取的文件按照格式进行解析
  std::vector<DocInfo_t> results;
  if (!ParseHtml(files_lists, &results))
  {
    std::cerr << "parse html error" << std::endl;
    return 2;
  }

  // 第三步:把解析后的文件输出到output路径里
  if (!SaveHtml(results, output))
  {
    std::cerr << "save html error" << std::endl;
    return 3;
  }
  return 0;
}

bool EnumFile(const std::string &src_path, std::vector<std::string> *files_lists)
{
  // 定义一个path对象,从当前路径开始查找
  boost::filesystem::path root_path(src_path);
  if (!boost::filesystem::exists(root_path)) // 如果当前路径不存在就返回false
  {
    std::cerr << src_path << "not exists" << std::endl;
    return false;
  }

  // 定义一个空的迭代器,判断是否结束
  boost::filesystem::recursive_directory_iterator end;
  // 开始递归搜索
  for (boost::filesystem::recursive_directory_iterator iter(root_path); iter != end; iter++)
  {
    // 如果不是普通文件,跳过
    if (!boost::filesystem::is_regular_file(*iter))
    {
      continue;
    }
    // 如果不是以html结尾,跳过
    if (iter->path().extension() != ".html")
    {
      continue;
    }

    // 测试代码,之后删除
    // std::cout<<"debug"<<iter->path().string()<<std::endl;

    // 将满足条件的网页的路径存入
    files_lists->push_back(iter->path().string());
  }

  return true;
}

static bool ParaseTitle(const std::string &file, std::string *title)
{
  std::size_t begin = file.find("<title>");
  if (begin == std::string::npos)
    return false;
  begin += 7;

  std::size_t end = file.find("</title>");
  if (end == std::string::npos)
    return false;

  if (begin > end)
    return false;

  *title = file.substr(begin, end - begin);
  return true;
}

static bool ParseContent(const std::string &file, std::string *content)
{
  // 一个简易的状态机
  enum state
  {
    LABEL,
    CONTENT
  };
  // 初始化为LABEL
  enum state s = LABEL;
  for (char c : file)
  {
    switch (s)
    {
    case LABEL:
      if (c == '>')
        s = CONTENT;
      break;
    case CONTENT:
      if (c == '<')
        s = LABEL;
      else
      {
        // 我们不想要原始文档里的换行符,因为我们想用\n作为之后文档分隔符
        if (c == '\n')
          c = ' ';
        content->push_back(c);
      }
      break;
    default:
      break;
    }
  }
  return true;
}

static bool ParseUrl(const std::string &file, std::string *url)
{
  std::string head = "https://www.boost.org/doc/libs/1_84_0/doc/html/";
  std::string tail = file.substr(src_path.size());

  *url = head + tail;
  return true;
}

bool ParseHtml(const std::vector<std::string> &files_lists, std::vector<DocInfo_t> *results)
{
  for (const std::string &file : files_lists)
  {
    // 1.读取文件
    std::string result;
    if (!ns_util::FillUtil::ReadFile(file, &result))
    {
      continue;
    }

    DocInfo_t doc;
    // 提取title
    if (!ParaseTitle(result, &doc.title))
    {
      continue;
    }
    // 提取content
    if (!ParseContent(result, &doc.content))
    {
      continue;
    }

    // 提取URL
    if (!ParseUrl(file, &doc.url))
    {
      continue;
    }

    // 放入结果
    results->push_back(std::move(doc));//细节;因为直接使用push_back会发生拷贝,为了提高效率使用move

    // 测试代码
    //  std::cout<<"title:"<<doc.title<<std::endl;
    //  std::cout<<"content:"<<doc.content<<std::endl;
    //  std::cout<<"url:"<<doc.url<<std::endl;
    //  break;
  }
  return true;
}
bool SaveHtml(const std::vector<DocInfo_t> &results, const std::string &output)
{
  // 创建输出对象
  std::ofstream out(output);
  if (!out.is_open())
  {
    std::cerr << "open:" << output << "failed!" << std::endl;
    return false;
  }

  // 将其格式化
  for (auto &item : results)
  {
    std::string result;
    result += item.title;
    result += '\3';
    result += item.content;
    result += '\3';
    result += item.url;
    result += '\n';

    out.write(result.c_str(), result.size());
  }
  out.close();

  return true;
}


searcher.hpp

#include "index.hpp"
#include <algorithm>
#include <jsoncpp/json/json.h>

namespace ns_searcher
{
  class Searcher
  {
  private:
    ns_index::Index *index; // 供系统查找的接口
  public:
    Searcher()
    {
    }
    ~Searcher()
    {
    }

  public:
    // 初始化
    void InitSearcher(const std::string &input)
    {
      // 1.创建Index对象
      index = ns_index::Index::GetInstance();
      std::cout << "获取index单例成功....." << std::endl;

      // 2.创建索引
      index->BuildIndex(input);
      std::cout << "建立正排和倒排索引成功....." << std::endl;
    }
    // 查找
    void Search(const std::string &query, std::string *json_string)
    {
      // 1.分词
      std::vector<std::string> words; // 存放词
      ns_util::JiebaUtil::CutString(query, &words);

      // 2.触发:根据分词找到对应倒排拉链(注意:要忽略大小写)
      // 为了方便,这里经过了typedef,把倒排hash的second(vector<InvertedElem>)重命名成了InvertedList
      ns_index::InvertedList inverted_list_all; // 存放所有找到的文档的倒排拉链
      for (auto &s : words)
      {
        boost::to_lower(s);                                                // 忽略大小写
        ns_index::InvertedList *inverted_list = index->GetInvertedList(s); // 根据string获取倒排拉链
        if (nullptr == inverted_list)
          continue;
        inverted_list_all.insert(inverted_list_all.end(), inverted_list->begin(), inverted_list->end());
      }

      // 3.进行汇总排序
      class Less
      {
      public:
        bool operator()(const ns_index::InvertedElem &e1, const ns_index::InvertedElem &e2)
        {
          return e1.weight > e2.weight;
        }
      };
      std::sort(inverted_list_all.begin(), inverted_list_all.end(), Less());
      // std::sort(inverted_list_all.begin(), inverted_list_all.end(), [](const ns_index::InvertedElem &e1, const ns_index::InvertedElem &e2)
      //          { e1.weight > e2.weight; });

      // 4.构建jsoncpp串
      Json::Value root;
      for (auto &item : inverted_list_all)
      {
        ns_index::DocInfo *doc = index->GetForwardIndex(item.id); // 通过正排索引获取文档
        if (nullptr == doc)
          continue;
        Json::Value elem;
        elem["title"] = doc->title;
        elem["desc"] = GetDesc(doc->content, item.word); // 我们只需要展示一部分内容即可,这里以后会改
        elem["url"] = doc->url;
        
        //for DeBUG 测试权重,这里由于分词原因,所以权重可能不如我们预期
        //elem["id"]=(int)item.id;
        //elem["weight"]=item.weight;

        root.append(elem);
      }
      Json::StyledWriter writer;
      *json_string = writer.write(root); // 写入目标文件
    }

    // 截取摘要
    std::string GetDesc(const std::string &html_content, const std::string &word)
    {
      // 第一次找到word,截取word前50个字节和后100个字节,如果前面不足50个,则从起始位置开始
      const std::size_t prev_step = 50;
      const std::size_t next_step = 100;
      // 找到首次出现
      // 忽略大小写
      auto iter = std::search(html_content.begin(), html_content.end(), word.begin(), word.end(), [](int x, int y)
                              { return std::tolower(x) == std::tolower(y); });
      if (iter == html_content.end())
        return "None1";
      std::size_t pos = std::distance(html_content.begin(), iter);

      // 获取头部和尾部
      std::size_t start = 0;
      std::size_t end = html_content.size() - 1;
      if (pos > prev_step + start)
        start = pos - prev_step; // 改为加法比较
      if (pos + next_step < end)
        end = pos + next_step;
      if (start >= end)
        return "None2";

      return html_content.substr(start, end - start);
    }
  };
}

server.cc

#include"searcher.hpp"

const std::string input="data/raw_html/raw.txt";

int main()
{
  ns_searcher::Searcher *search=new ns_searcher::Searcher();
  search->InitSearcher(input);

  std::string query;
  std::string json_string;

  while(true)
  {
    std::cout<<"Plesae Enter Your Search Query:";
    getline(std::cin,query);
    search->Search(query,&json_string);
    std::cout<<json_string<<std::endl;
  }

  return 0;
}


util.hpp

#include <iostream>
#include <string>
#include <fstream>
#include <boost/algorithm/string.hpp>
#include "cppjieba/Jieba.hpp"

namespace ns_util
{
  class FillUtil
  {
  public:
    static bool ReadFile(const std::string &file_path, std::string *out)
    {
      std::ifstream in(file_path); // 创建对象,这种创建模式,默认打开文件
      // 判断文件是否打开
      if (!in.is_open())
      {
        std::cerr << "open file" << file_path << "error" << std::endl;
        return false;
      }

      // 读取文件,按行读取
      std::string line;
      while (std::getline(in, line)) // getline的返回值是istream类型,但该类内部进行了重载,所以可以直接判断
      {
        *out += line;
      }

      // 关闭文件
      in.close();
      return true;
    }
  };

  class StringUtil
  {
  public:
    static void Split(const std::string &target, std::vector<std::string> *out, const std::string &sep)
    {
      boost::split(*out, target, boost::is_any_of(sep), boost::token_compress_on);
    }
  };

  const char *const DICT_PATH = "./dict/jieba.dict.utf8";
  const char *const HMM_PATH = "./dict/hmm_model.utf8";
  const char *const USER_DICT_PATH = "./dict/user.dict.utf8";
  const char *const IDF_PATH = "./dict/idf.utf8";
  const char *const STOP_WORD_PATH = "./dict/stop_words.utf8";

  class JiebaUtil
  {
  public:
    // 构建jieba对象
    static cppjieba::Jieba jieba;

  public:
    static void CutString(const std::string &src, std::vector<std::string> *out)
    {
      jieba.CutForSearch(src, *out);
    }
  };
  cppjieba::Jieba JiebaUtil::jieba(DICT_PATH, HMM_PATH, USER_DICT_PATH, IDF_PATH, STOP_WORD_PATH);
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1434085.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

多输入多输出 | Matlab实现PSO-LSTM粒子群优化长短期记忆神经网络多输入多输出预测

多输入多输出 | Matlab实现PSO-LSTM粒子群优化长短期记忆神经网络多输入多输出预测 目录 多输入多输出 | Matlab实现PSO-LSTM粒子群优化长短期记忆神经网络多输入多输出预测预测效果基本介绍程序设计参考资料 预测效果 基本介绍 Matlab实现PSO-LSTM粒子群优化长短期记忆神经网络…

Java Arrays 的相关操作数组排序

Java Arrays 的相关操作数组排序 package com.zhong.arrays;import java.math.BigDecimal; import java.util.Arrays; import java.util.Comparator;public class ArraysDemo {public static void main(String[] args) {int[] arr {10, 20, 40, 30, 90, 60, 10, 30, 50};// A…

ReactNative实现文本渐变

我们直接上图&#xff0c;可以看到上面文本的效果&#xff0c;使用SVG实现 1.首先还是要引入react-native-svg库 2.使用该库下面的LinearGradient和Text 好&#xff0c;话不多说&#xff0c;我们看具体代码 <Svg width{422} height{30} viewBox{0 0 422 30}><Defs&…

以真机促创新!玻色量子联合中国运筹学会共商量子生态新模式

2024年1月29日&#xff0c;中国运筹学会算法软件与应用分会的一行领导莅临北京玻色量子科技有限公司&#xff08;以下简称“玻色量子”&#xff09;&#xff0c;参观了玻色量子及光量子计算机真机“天工量子大脑”、自建的十万颗粒洁净度光量子信息技术实验室&#x1f517;&…

React 浮层组件实现思路

React 浮层组件&#xff08;也称为弹出组件或弹窗组件&#xff09;通常是指在用户界面上浮动显示的组件&#xff0c;它们脱离常规的文档流&#xff0c;并且可以在用户进行某些操作时出现在页面的最上层。React 浮层组件可以用于创建模态框&#xff08;Modal&#xff09;、下拉菜…

【TCP/IP】用户访问一个购物网站时TCP/IP五层参考模型中每一层的功能

当用户访问一个购物网站时&#xff0c;网络上的每一层都会涉及不同的协议&#xff0c;具体网络模型如下图所示。 以下是每个网络层及其相关的协议示例&#xff1a; 物理层&#xff1a;负责将比特流传输到物理媒介上&#xff0c;例如电缆或无线信号。所以在物理层&#xff0c;可…

解决hive表新增的字段查询为空null问题

Hive分区表新增字段&#xff0c;查询时数据为NULL的解决方案 由于业务拓展&#xff0c;需要往hive分区表新增新的字段&#xff0c;hive版本为2点多。 于是利用 alter table table_name add columns (col_name string )新增字段&#xff0c;然后向已存在分区中插入数据&#x…

centos间文件传输

scp /home/vagrant/minio zx192.168.56.34:/home/zx /home/vagrant/minio 是你要传输的文件而且是当前机器登录用户有权限操作的文件 zx是目标机器的用户192.168.56.34是目标机器的地址 /home/zx是要传到这个文件夹下 要确保zx有/home/zx这个文件夹的操作权限 本质就是ssh文…

黑豹程序员-ElementPlus选择图标器

ElementPlus组件提供了很多图标svg 如何在你的系统中&#xff0c;用户可以使用呢&#xff1f; 这就是图标器&#xff0c;去调用ElementPlus的icon组件库&#xff0c;展示到页面&#xff0c;用户选择&#xff0c;返回选择的组件名称。 效果 代码 <template><el-inpu…

【C语言】static关键字的使用

目录 一、静态本地变量 1.1 静态本地变量的定义 1.2 静态本地变量和非静态本地变量的区别 二、静态函数 2.1 静态函数的定义 2.2 静态函数与非静态函数的区别 三、静态全局变量 3.1 静态全局变量的定义 3.2 静态全局变量和非静态全局变量的区别 四、静态结构体变量 …

挑战杯 python+opencv+深度学习实现二维码识别

0 前言 &#x1f525; 优质竞赛项目系列&#xff0c;今天要分享的是 &#x1f6a9; pythonopencv深度学习实现二维码识别 &#x1f947;学长这里给一个题目综合评分(每项满分5分) 难度系数&#xff1a;3分工作量&#xff1a;3分创新点&#xff1a;3分 该项目较为新颖&…

两次NAT

两次NAT即Twice NAT&#xff0c;指源IP和目的IP同时转换&#xff0c;该技术应用于内部网络主机地址与外部网络上主机地址重叠的情况。 如图所示&#xff0c;两次NAT转换的过程如下: 内网Host A要访问地址重叠的外部网络Host B&#xff0c;Host A向位于外部网络的DNS服务器发送…

图文并茂讲解Travelling Salesman

题目 思路 一道lca板子题&#xff0c;不会的同学可以先康康 详解最近公共祖先(LCA)-CSDN博客 我们可以发现&#xff0c;商人是从1开始&#xff0c;旅行到第一个城镇&#xff0c;再到第二个&#xff0c;第三个…… 那么我们只需要求出1~第一个城镇的距离&#xff0c;第一个城…

爱上算法:每日算法(24-2月4号)

&#x1f31f;坚持每日刷算法&#xff0c;&#x1f603;将其变为习惯&#x1f91b;让我们一起坚持吧&#x1f4aa; 文章目录 [232. 用栈实现队列](https://leetcode.cn/problems/implement-queue-using-stacks/)思路CodeJavaC 复杂度 [225. 用队列实现栈](https://leetcode.cn/…

引入echarts环形图及显示后端数据

实现效果&#xff1a; 1.下载echarts 并引用 npm install echarts --save 或 pnpm install -S echarts 项目中引用&#xff1a; 在项目main.ts中 import * as echarts from "echarts"; //引入echarts 3.页面中使用 <div id"main" class&quo…

Maven配置笔记

1、下载Maven 在Maven的官网即可下载&#xff0c;点击访问Apache Maven。 2、配置环境变量 chcp 65001 echo off set mvnhomeE:\apache-maven-3.8.4 rem LPY echo. echo ************************************************************ echo * …

有水印的照片怎么删除水印?这几个照片去水印的方法教给你

如今社会发展迅猛&#xff0c;越来越多人用手机、相机等设备拍照和录视频&#xff0c;记录生活点滴。然而&#xff0c;这些照片和视频很多时候会因为水印而影响欣赏体验。水印不仅破坏了画面的美观&#xff0c;还可能遮挡了重要的内容。那么&#xff0c;有水印的照片怎么删除水…

私有化部署跳一跳

目录 效果 安装 1.安装httpd 2.下载跳一跳 3.启动httpd 使用 效果 安装 1.安装httpd yum -y install httpd systemctl enable httpd 2.下载跳一跳 cd /var/www/html/ git clone https://gitee.com/WangZhe168_admin/jump.git 3.启动httpd systemctl start httpd 使…

Centos7配置登录失败处理导致root被锁定处理办法

1、应用场景 root用户被系统锁定&#xff0c;无法登录系统。 2、问题现象 root锁定无法登录系统 3、原因 设置登录失败处理并对root用户生效&#xff0c;一直尝试错误的root密码或暴力破解root密码&#xff0c;导致无法自动解锁Linux的root账户 4、解决方案 1.将虚拟机开…

程序员为什么不喜欢关电脑,这回答很霸道!

在大家的生活中&#xff0c;经常会发现这样一个现象&#xff1a;程序员经常不关电脑。 至于程序员不关电脑的原因&#xff0c;众说纷纭。 其中这样的一个程序员&#xff0c;他的回答很霸道&#xff1a; “因为我是程序员&#xff0c;我有权选择不关电脑。我需要在任何时候都能够…