伪原创智能改写api百度【php源码】

用百度自家的产品来生成的文章,原创度和收录相当理想,伪原创智能改写api百度,以毒攻毒。

 从全球趋势来看,信息化、智能化、智能化是建设智慧城市的必由之路。2022年,德勤发布《超级智慧城市报告》。

伪原创智能改写api百度【php源码】暂时只有php,其他语言欢迎补充

<?php


set_time_limit(270);
error_reporting(E_ERROR | E_WARNING | E_PARSE);

define('TITLE_SEPAR', 'xxx**xxx');
define('TITLE_SEPAR2', '262661');


$url = 'http://www.xiaofamao.com/api.php?json=0&v=1&key=abcccc';

$content_tag_name = '内容';


$headdd = '';
$taill = '';



switch($LabelArray['PageType'])
{
    case 'List'://处理列表页,只能处理html
        break;
    case 'Pages'://处理多页,只能处理html
        break;
    case 'Content'://处理默认页,只能处理html
        break;
    case 'Save'://只有保存时是可以处理标签值的
        // 保存原文

    try {
    /**********************************************************************/
    // 这一步用来获取伪原创文章
    /**********************************************************************/
    $title = $LabelArray['标题'];
    $title = '标题:'.$title;

    $content = $LabelArray[$content_tag_name];
    #$content = str_replace('2020/', '2020_', $content);

    $article_src = compose_article($title, $content);
    $article_src_b = $article_src;

    $article_new = get_wyc_article($article_src);


    $title_wyc = trim($article_new[0]);
    $content_wyc = trim($article_new[1]);

    $content_wyc = fix_newline($content_wyc);
    $content_wyc = str_replace('标签:', '标签:', $content_wyc);
    $LabelArray[$content_tag_name] = $headdd. $content_wyc. $taill;

    $title_wyc = str_replace(array('。',',','%'), array(' ',' ',' '), $title_wyc);
    $LabelArray['标题'] = $title_wyc;
    }
    catch (Exception $e) {
        $LabelArray['标题'] .= $e->getMessage();
        $LabelArray[$content_tag_name] .= $e->getMessage();
    }
        break;
    default:
        //$LabelArray[$content_tag_name]=curl_request($url, array('wenzhang'=>$LabelArray[$content_tag_name] ));
}

echo serialize($LabelArray);



function compose_article($title, $content) {
    $separator = compose_separator();
    return $title.$separator.$content;
}

function compose_separator() {
    return PHP_EOL.'('.TITLE_SEPAR2.')'.PHP_EOL;
}


function fix_separator($article) {
    return $article;
}


function get_wyc_article($str) {
    global $url;
    $separator = compose_separator();
    $separator = str_replace(PHP_EOL, '', $separator);
    $wyc = curl_request($url, array('wenzhang'=>$str));

    $wyc_f = $wyc;
    $wyc = fix_separator($wyc);
    $wyc = explode($separator, $wyc);

    if (isset($wyc[0])){
        $wyc[0] = str_replace('标题:', '', $wyc[0]);
        $wyc[0] = str_replace('标题:', '', $wyc[0]);
        $wyc[0] = str_replace('目:', '', $wyc[0]);
        $wyc[0] = str_replace('目:', '', $wyc[0]);
        $wyc[0] = 'xx`xx'.$wyc[0];
        $wyc[0] = str_replace('xx`xx题', '', $wyc[0]);
        $wyc[0] = str_replace('xx`xx', '', $wyc[0]);
    }

    //if (isset($wyc[1])) $wyc[1] = trim($wyc[1]);
    //$wyc[1] = $wyc_f.'jjjjjjjj'.$wyc[1];
    return $wyc;
}


function get_wyc_title($str) {
    $title = get_wyc_article($str.PHP_EOL.PHP_EOL.PHP_EOL.$str.PHP_EOL.PHP_EOL.PHP_EOL.$str);
    $title = fix_newline($title);
    $title = explode(PHP_EOL, $title);
    return $title[0];
}

function get_keywords($title, $contents) {
    $url_kw = 'http://www.78tp.com/nlp/kws.php?appid=';
    $kws = curl_request($url_kw, array(
    'title'=>$title,
    'len'=>100,
    'text'=>$contents));

    return $kws;
}


function remove_alt($contents) {
    $contents = preg_replace('/alt=\"(.*)\"/', '', $contents);
    return $contents;
}


function fix_title($contents) {
    $punctuation_symbol = array('。', '?', ',', ':', ';', '、', '!',
                                '.',  '?',  ',',  ':',  ';', '!');

     $contents = str_replace($punctuation_symbol, '', $contents);
    return $contents;
}

function br2newline($contents) {
    $contents = str_replace('<br>', PHP_EOL, $contents);
    $contents = str_replace('<br/>', PHP_EOL, $contents);
    $contents = str_replace('<br />', PHP_EOL, $contents);
    $contents = str_replace('<BR/>', PHP_EOL, $contents);
    $contents = str_replace('<BR>', PHP_EOL, $contents);
    $contents = str_replace('<BR />', PHP_EOL, $contents);

    return $contents;
}

function newline2br($contnets) {
    $contnets = str_replace(PHP_EOL, "<br>", $contnets);
//    $contnets = str_replace('><br><', '><', $contnets);
    $contnets = str_replace('<p><br>', '<p>', $contnets);
    return $contnets;
}


function delete_newline($contents) {
    $contents = fix_newline($contents);
//    $contents = str_replace(PHP_EOL.PHP_EOL, PHP_EOL, $contents);
//    $contents = str_replace('>'.PHP_EOL, '>', $contents);
    return $contents;
}

function reset_newline_win($contents) {
    // 优化换行符
    $contents = str_replace("\r\n", "\n", $contents);
    $contents = str_replace("\r", "\n", $contents);
    $contents = str_replace("\n", PHP_EOL, $contents);

    return $contents;
}

function fix_newline($data) {
    $data = str_replace("\r", "\n", $data);
    while(strpos($data, "\n\n") !== false) {
        $data = str_replace("\n\n", "\n", $data);
    }
    $data = str_replace("\n", PHP_EOL, $data);

    return $data;
}

function clean_contents($contents) {
//    $str = preg_replace('#<([^>\s/]+)[^>]*>#','<$1>', $contents);
//    return $str;
    $sa = new cleanHtml;  
    $sa->allow = array( 'src' );    
    $sa->exceptions = array(  
    'img' => array( 'src', 'alt' ),  
    //'a' => array( 'href', 'title' ),  
    'iframe'=>array('src','frameborder'),  
    ); 
    $str = $sa->strip( $contents );   

    return $str;
}


function xfm_strong_str_replace_once($search, $replace, $subject) {
    $firstChar = strpos($subject, $search);
    if($firstChar !== false) {
        $beforeStr = substr($subject,0,$firstChar);
        $afterStr = substr($subject, $firstChar + strlen($search));
        return $beforeStr.$replace.$afterStr;
    } else {
        return $subject;
    }
}

//参数1:访问的URL,参数2:post数据(不填则为GET),参数3:提交的$cookies,参数4:是否返回$cookies
function curl_request($url,$post='',$cookie='', $returnCookie=0){
    if (! extension_loaded('curl')) {
        file_exists('./ext/php_curl.dll') && dl('php_curl.dll'); // 加载扩展
    }
    
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)');
    if (ini_get('open_basedir') == '' && strtolower(ini_get('safe_mode')) != 'on'){ 
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    }
        curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
        curl_setopt($curl, CURLOPT_REFERER, "http://XXX");
        if($post) {
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
        }
        if($cookie) {
            curl_setopt($curl, CURLOPT_COOKIE, $cookie);
        }
        curl_setopt($curl, CURLOPT_HEADER, $returnCookie);
        curl_setopt($curl, CURLOPT_TIMEOUT, 150);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        $data = curl_exec($curl);
        if (curl_errno($curl)) {
            return curl_error($curl);
        }
        curl_close($curl);
        if($returnCookie){
            list($header, $body) = explode("\r\n\r\n", $data, 2);
            preg_match_all("/Set\-Cookie:([^;]*);/", $header, $matches);
            $info['cookie']  = substr($matches[1][0], 1);
            $info['content'] = $body;
            return $info;
        }else{
            return $data;
        }
}

//echo $tag;
// 计算中文字符串长度
function utf8_strlen($string = null) {
// 将字符串分解为单元
preg_match_all("/./us", $string, $match);
// 返回单元个数
return count($match[0]);
}


function reg_escape( $str )  
{  
    $conversions = array( "^" => "\^", "[" => "\[", "." => "\.", "$" => "\$", "{" => "\{", "*" => "\*", "(" => "\(", "\\" => "\\\\", "/" => "\/", "+" => "\+", ")" => "\)", "|" => "\|", "?" => "\?", "<" => "\<", ">" => "\>" );  
    return strtr( $str, $conversions );  
}  
  
/** 
* Strip attribute Class 
* Remove attributes from XML elements 
* @author David (semlabs.co.uk) 
* @version 0.2.1 
*/  
  
class cleanHtml{  
      
    public $str         = '';  
    public $allow       = array();  
    public $exceptions  = array();  
    public $ignore      = array();  
      
    public function strip( $str )  
    {  
        $this->str = $str;  
          
        if( is_string( $str ) && strlen( $str ) > 0 )  
        {  
            $res = $this->findElements();  
            if( is_string( $res ) )  
                return $res;  
            $nodes = $this->findAttributes( $res );  
            $this->removeAttributes( $nodes );  
        }  
          
        return $this->str;  
    }  
      
    private function findElements()  
    {  
        # Create an array of elements with attributes  
        $nodes = array();  
        preg_match_all( "/<([^ !\/\>\n]+)([^>]*)>/i", $this->str, $elements );  
        foreach( $elements[1] as $el_key => $element )  
        {  
            if( $elements[2][$el_key] )  
            {  
                $literal = $elements[0][$el_key];  
                $element_name = $elements[1][$el_key];  
                $attributes = $elements[2][$el_key];  
                if( is_array( $this->ignore ) && !in_array( $element_name, $this->ignore ) )  
                    $nodes[] = array( 'literal' => $literal, 'name' => $element_name, 'attributes' => $attributes );  
            }  
        }  
          
        # Return the XML if there were no attributes to remove  
        if( !$nodes[0] )  
            return $this->str;  
        else  
            return $nodes;  
    }  
      
    private function findAttributes( $nodes )  
    {  
          
        # Extract attributes  
        foreach( $nodes as &$node )  
        {  
            preg_match_all( "/([^ =]+)\s*=\s*[\"|']{0,1}([^\"']*)[\"|']{0,1}/i", $node['attributes'], $attributes );  
            if( $attributes[1] )  
            {  
                foreach( $attributes[1] as $att_key => $att )  
                {  
                    $literal = $attributes[0][$att_key];  
                    $attribute_name = $attributes[1][$att_key];  
                    $value = $attributes[2][$att_key];  
                    $atts[] = array( 'literal' => $literal, 'name' => $attribute_name, 'value' => $value );  
                }  
            }  
            else  
                $node['attributes'] = null;  
              
            $node['attributes'] = $atts;  
            unset( $atts );  
        }  
          
        return $nodes;  
    }  
      
    private function removeAttributes( $nodes )  
    {  
          
        # Remove unwanted attributes  
        foreach( $nodes as $node )  
        {  
              
            # Check if node has any attributes to be kept  
            $node_name = $node['name'];  
            $new_attributes = '';  
            if( is_array( $node['attributes'] ) )  
            {  
                foreach( $node['attributes'] as $attribute )  
                {  
                    if( ( is_array( $this->allow ) && in_array( $attribute['name'], $this->allow ) ) || $this->isException( $node_name, $attribute['name'], $this->exceptions ) )  
                        $new_attributes = $this->createAttributes( $new_attributes, $attribute['name'], $attribute['value'] );  
                }  
            }  
            $replacement = ( $new_attributes ) ? "<$node_name $new_attributes>" : "<$node_name>";  
            $this->str = preg_replace( '/'. reg_escape( $node['literal'] ) .'/', $replacement, $this->str );  
        }  
          
    }  
      
    private function isException( $element_name, $attribute_name, $exceptions )  
    {  
        if( array_key_exists($element_name, $this->exceptions) )  
        {  
            if( in_array( $attribute_name, $this->exceptions[$element_name] ) )  
                return true;  
        }  
          
        return false;  
    }  
      
    private function createAttributes( $new_attributes, $name, $value )  
    {  
        if( $new_attributes )  
            $new_attributes .= " ";  
        $new_attributes .= "$name=\"$value\"";  
          
        return $new_attributes;  
    }  
  
}  

?>

当时全球已经有1000多个智慧城市上马或在建,中国有500个智慧城市在建。根据最新情况,我国智慧城市发展至今,已经进入“数字化转型”融合的新阶段。

1、智能伪原创生成软件

此外,《智能制造发展规划》还提出,到2025年,智能制造支撑体系基本建立,重点行业初步实现数字化、智能化转型。

业内人士表示,对于城市和各行各业的数字化,包括5G、云计算、大数据、人工智能、区块链等多项技术。其中人工智能是核心,是城市数字化转型过程中实现智能化、智能化的核心技术。
这意味着对AI的争夺将是关键。早在2017年,李彦宏就在两会提案中表示:“随着人工智能技术的逐渐成熟,谁率先实现应用上的突破,谁就有可能在智能时代的竞争中占据优势。”

这个重任与每一个中国AI企业息息相关。为此,百度此前部署了新一代智能政务云基地,构建了“云智融合”的城市大脑,在城市洞察、城市治理、产业发展、服务惠民四大智慧应用场景进行深度赋能。再加上百度的智能运营体系和安全体系,打造了“1 5 N”智慧城市全景图,上述案例落地。

2、十年研发超千亿,多项领先全球

为百度AI产品和产业解决方案提供全面技术支持的,是刚刚迭代升级到7.0的百度大脑。此外,百度自主研发的第二代百度昆仑AI芯片——昆仑Core  2也已实现量产,采用7nm工艺,性能较一代提升2-3倍。未来将广泛应用于互联网核心算法、智慧城市、智慧行业等领域。
其中,作为百度大脑的核心基地,飞桨格外引人关注。飞桨是国内最早开源、功能丰富的百度自主研发的工业级深度学习平台。自2016年正式开源以来,通过降低应用门槛,各行各业都被推到了价值链的中心。
最新数据显示,飞桨通过开源聚集了超过360万各行各业的开发者,开发了40万个AI模型,累计服务13万家企事业单位,覆盖工业、农业、医疗、城管、交通、金融等诸多领域。
这个数据在世界上是数一数二的。2019年,IDC发布《深度学习框架和平台市场份额》报告显示,在深度学习平台市场,谷歌、脸书、百度三家厂商地位稳固,市场份额接近80%。其中,百度市场份额快速增长,AWS、微软等国外平台份额下滑明显。最新IDC调查显示,百度在中国深度学习平台市场的综合份额持续增长,排名第一。相比自动驾驶平台Apollo,飞桨的关注度不算太高。但从核心来看,飞桨是中国第一个也是唯一一个开源、功能齐全的工业级深度学习平台。百度也因此成为继脸书、谷歌、IBM之后,全球又一家拥有开源深度学习框架的科技公司。
“在AI领域,百度最引以为傲的有两点。一个是Apollo,奠定了百度在全球自动驾驶生态中的核心地位;是飞桨,把国外巨头垄断的深度学习平台市场份额撕开了一个口子。”此前,一位业内人士在这篇文章中评论道。
据此前业内人士透露,飞桨的开发是完全自主知识产权的逐行代码。自主开发深度学习平台几乎和自主编写操作系统一样困难,因此被称为“中国自主研发样本”。
在AI专利数量上,百度也位居国内第一。据国家工业信息安全发展研究中心发布的《2020人工智能中国专利技术分析报告》显示,在人工智能的专利申请量和授权量方面,百度分别以9364件专利申请量和2682件专利授权量位居第一。
这意味着,无论从哪个角度看,百度都是当之无愧的中国AI的领导者。
对于从留学开始就有AI梦的李彦宏来说,很难带领百度走到这一步。投入并坚持AI研发超过10年。
“人工智能的概念提出已经60多年了。我在美国读书的时候很喜欢这门课,但是老师告诉我业内没有人认可。”李彦宏曾经说过,那个时候信息技术还没有那么普及,数据少,算法低,人工智能也没有展现出很大的前景。但是他没有听老师的话,从此开始关注和研究人工智能。
2010年,百度开始AI布局,成为国内最早深度AI布局的先锋企业;2013年,百度深度学习研究院成立,这是全球企业界第一个以“深度学习”命名的研究院。自动驾驶研发;d项目于今年启动;2014年4月,大数据实验室成立,同年5月,硅谷人工智能实验成立。同年,“百度无人驾驶汽车”研发;d计划正式启动。
2015年以来,人工智能在国家层面被反复提及。同年,百度成立自动驾驶事业部,大规模投入研发;2017年新增商业智能实验室、机器人和自动驾驶实验室,完成AI各细分领域的研究布局。同年7月,百度Apollo发布1.0版本,正式对外开源。2018年底,《哈佛商业评论》发布了“全球最受关注的10大AI领袖”榜单。李彦宏是唯一入选的中国面孔,被称为“中国AI产业的发起者和设计者”、“中国唯一拥有完整AI技术和产业能力的CEO”。
从某种程度上来说,这一评价不仅是对李彦宏在几乎所有公共场所推动AI的描述,也是对李彦宏在引领中国AI产业方面的作用的评价。
"三年前,我们的年总收入刚刚超过1000亿元,而在过去的10年里,我们的研发;d支出已超过1000亿元。”在今年3月的股东信中,李彦宏透露:“然而,如果我们选择了技术战略,我们必须抵制短期机会的诱惑,坚定地面对长期投资的挑战。”
或许,正是在长期的“疯狂”投入中,从“汽车机器人”到“萝卜跑”,从不断循环迭代的“小度”到“AI产业赋能”.这些曾经看似“疯狂”的想法,慢慢从“梦想”变成了现实。
然而,无论对于中国还是百度,人工智能的艰辛探索,一条坎坷泥泞的路,才刚刚开始。
2020年6月,百度宣布未来五年预计培养500万AI人才,为中国智能经济和智能社会的发展提供AI人才保障。2021年8月18日,百度正式宣布成立郭颂学院,通过提供基础课程、技术竞赛、产业培训、科研经费等资源,推动AI人才培养。
这一切,或许就像李彦宏写给刷屏股东的信:科技创新的前沿没有尽头。对于一个技术信徒来说,还有什么比这个时代的机遇更令人激动的呢?

猜你喜欢

转载自blog.csdn.net/mynote/article/details/125844543