如酒如糖句子?

时间:2024-08-21 08:49 人气:0 编辑:招聘街

一、如酒如糖句子?

出自宋诗人苏轼的《岐亭五首》

  酸酒如虀汤,甜酒如蜜汁。

  三年黄州城,饮酒但饮湿。

  我如更拣择,一醉岂易得。

  几思压茅柴,禁网日夜急。

  西邻椎瓮盎,醉倒猪与鸭。

  君家大如掌,破屋无遮幂。

  何从得此酒,冷面妒君赤。

  定应好事人,千石供李白。

  为君三日醉,蓬发不暇帻。

  夜深欲踰垣,卧想春瓮泣。

  君奴亦笑我,鬓齿行秃缺。

  三年已四至,岁岁遭恶客。

  人生几两屐,莫厌频来集。

二、有嗜糖如命吗?

有的。我看见我同事整天吃糖不住,我劝他少吃糖,他还嗨嗨一下就应付一下你。吃糖多了对牙齿.肥胖,可是大大的不利。我建议大家少吃糖,以免有害健康。

三、似糖如蜜、用来形容什么?

似糖如蜜用来形容夫妻或者情侣之间关系很好,很幸福快乐,和如胶似漆意思相近,主要还是还是描写感情深厚互相深情相爱。

四、潮如糖铺怎么样?

潮如糖铺是一家以甜品为主打的餐饮店,店内装修时尚现代,环境舒适宜人。他们提供各种口味的甜品,从经典的奶茶、冰淇淋到创意的甜品拼盘,种类繁多,口味丰富。甜品制作精细,口感丰富,让人回味无穷。服务态度亲切周到,价格实惠。总的来说,潮如糖铺是一家值得推荐的甜品店,无论是与朋友聚会还是休闲时光,都是一个不错的选择。

五、烈火如歌雪歌发糖集数?

玉师兄这五级掉线了,银雪作为伪男主总算心疼我们,在40集发了高能甜糖。

六、嗜糖如命的意思是什么?

嗜糖如命指一个人喜欢吃糖,喜欢到就像爱惜自己的生命一样。

七、各种糖果的寓意?如:奶糖,棉花糖?

冰糖,棉花糖,水晶糖,麦芽糖,口香糖,泡泡糖,跳跳糖,葡萄糖,草莓糖,奶糖,喜糖, 棒棒糖,水果糖,什锦糖,爆炸糖,大白兔奶糖, 喔喔奶糖, 金丝猴奶糖 ,QQ糖, 香橙味硬糖 ,棒棒糖 ,清凉薄荷糖, 水果糖 ,棉花糖, 咖啡糖, 玉米软糖, 话梅糖, 椰子糖,太妃糖 ,酥糖, 玉米糖 ,石榴糖,咖啡糖 ,哨子糖,戒指糖,波板塘,清口糖,薄荷糖,清凉糖,柠檬牛奶棒棒糖,草莓酸奶棒棒糖,可乐糖,雪碧糖,酸奶糖,乌龙茶糖,绿茶糖,红茶糖,橡皮糖,绿箭口香糖,黄箭口香糖,白箭口香糖,益达口香糖,朱古力牛奶糖旺仔牛奶糖, 原味椰子糖,鲜奶椰子糖,奶油椰子糖,咖啡椰子糖,跳跳巧克力糖,酒芯巧克力糖,蹦蹦糖 ,白糖,红糖,白砂糖,单晶冰糖

八、各种糖果的寓意?如:奶糖,棉花糖?

糖代表甜蜜,吃在嘴里甜在心里!那种感觉只有吃过的人才知道!就如恋爱!每个恋爱阶段都是不同味道的糖,爱情越浓密感情越真糖就越香浓。。。初恋是酸酸夹心糖,外面虽有一点酸涩但越到后面越觉得甜蜜!就如初恋那个时候的羞涩!热恋是水果糖,满嘴的各色香甜想的只是闭上眼睛回味那一丝一丝的美好!结婚是咖啡糖,时间久了就更是香浓,可现实的残酷让爱情多多少少有了苦涩!但那却更是应该值得细细品味的香甜!糖可以甜如蜜,但是不能沉醉其中,因为理智是预防蛀牙的最好办法。。

1. 橡皮糖 轻视的人

2. 水果糖 好朋友

3. 巧克力糖 深爱的人

4. 棉花糖 重视的人

5. 薄荷糖 陌生人

6. 棒棒糖 喜欢的人

7. 口香糖 讨厌的人

8. 泡泡糖 不爱的人

9. 奶糖 情人

九、沉香如屑糖周第几集变回帝君?

男主会在下周一18点后更新,第47集开头就要恢复帝君应渊,颜淡先是刺了唐周一剑,因为要先死后生,才会历劫归位,目前预告片里,颜淡报着牺牲自己的性命,也要让应渊归位,恢复仙力 ,颜淡最后把自己另外一半的心,也渡给了应渊,应渊就恢复了,后面剧情就得看星期一的正片了

十、mahout面试题?

之前看了Mahout官方示例 20news 的调用实现;于是想根据示例的流程实现其他例子。网上看到了一个关于天气适不适合打羽毛球的例子。

训练数据:

Day Outlook Temperature Humidity Wind PlayTennis

D1 Sunny Hot High Weak No

D2 Sunny Hot High Strong No

D3 Overcast Hot High Weak Yes

D4 Rain Mild High Weak Yes

D5 Rain Cool Normal Weak Yes

D6 Rain Cool Normal Strong No

D7 Overcast Cool Normal Strong Yes

D8 Sunny Mild High Weak No

D9 Sunny Cool Normal Weak Yes

D10 Rain Mild Normal Weak Yes

D11 Sunny Mild Normal Strong Yes

D12 Overcast Mild High Strong Yes

D13 Overcast Hot Normal Weak Yes

D14 Rain Mild High Strong No

检测数据:

sunny,hot,high,weak

结果:

Yes=》 0.007039

No=》 0.027418

于是使用Java代码调用Mahout的工具类实现分类。

基本思想:

1. 构造分类数据。

2. 使用Mahout工具类进行训练,得到训练模型。

3。将要检测数据转换成vector数据。

4. 分类器对vector数据进行分类。

接下来贴下我的代码实现=》

1. 构造分类数据:

在hdfs主要创建一个文件夹路径 /zhoujainfeng/playtennis/input 并将分类文件夹 no 和 yes 的数据传到hdfs上面。

数据文件格式,如D1文件内容: Sunny Hot High Weak

2. 使用Mahout工具类进行训练,得到训练模型。

3。将要检测数据转换成vector数据。

4. 分类器对vector数据进行分类。

这三步,代码我就一次全贴出来;主要是两个类 PlayTennis1 和 BayesCheckData = =》

package myTesting.bayes;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.fs.FileSystem;

import org.apache.hadoop.fs.Path;

import org.apache.hadoop.util.ToolRunner;

import org.apache.mahout.classifier.naivebayes.training.TrainNaiveBayesJob;

import org.apache.mahout.text.SequenceFilesFromDirectory;

import org.apache.mahout.vectorizer.SparseVectorsFromSequenceFiles;

public class PlayTennis1 {

private static final String WORK_DIR = "hdfs://192.168.9.72:9000/zhoujianfeng/playtennis";

/*

* 测试代码

*/

public static void main(String[] args) {

//将训练数据转换成 vector数据

makeTrainVector();

//产生训练模型

makeModel(false);

//测试检测数据

BayesCheckData.printResult();

}

public static void makeCheckVector(){

//将测试数据转换成序列化文件

try {

Configuration conf = new Configuration();

conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));

String input = WORK_DIR+Path.SEPARATOR+"testinput";

String output = WORK_DIR+Path.SEPARATOR+"tennis-test-seq";

Path in = new Path(input);

Path out = new Path(output);

FileSystem fs = FileSystem.get(conf);

if(fs.exists(in)){

if(fs.exists(out)){

//boolean参数是,是否递归删除的意思

fs.delete(out, true);

}

SequenceFilesFromDirectory sffd = new SequenceFilesFromDirectory();

String[] params = new String[]{"-i",input,"-o",output,"-ow"};

ToolRunner.run(sffd, params);

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

System.out.println("文件序列化失败!");

System.exit(1);

}

//将序列化文件转换成向量文件

try {

Configuration conf = new Configuration();

conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));

String input = WORK_DIR+Path.SEPARATOR+"tennis-test-seq";

String output = WORK_DIR+Path.SEPARATOR+"tennis-test-vectors";

Path in = new Path(input);

Path out = new Path(output);

FileSystem fs = FileSystem.get(conf);

if(fs.exists(in)){

if(fs.exists(out)){

//boolean参数是,是否递归删除的意思

fs.delete(out, true);

}

SparseVectorsFromSequenceFiles svfsf = new SparseVectorsFromSequenceFiles();

String[] params = new String[]{"-i",input,"-o",output,"-lnorm","-nv","-wt","tfidf"};

ToolRunner.run(svfsf, params);

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

System.out.println("序列化文件转换成向量失败!");

System.out.println(2);

}

}

public static void makeTrainVector(){

//将测试数据转换成序列化文件

try {

Configuration conf = new Configuration();

conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));

String input = WORK_DIR+Path.SEPARATOR+"input";

String output = WORK_DIR+Path.SEPARATOR+"tennis-seq";

Path in = new Path(input);

Path out = new Path(output);

FileSystem fs = FileSystem.get(conf);

if(fs.exists(in)){

if(fs.exists(out)){

//boolean参数是,是否递归删除的意思

fs.delete(out, true);

}

SequenceFilesFromDirectory sffd = new SequenceFilesFromDirectory();

String[] params = new String[]{"-i",input,"-o",output,"-ow"};

ToolRunner.run(sffd, params);

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

System.out.println("文件序列化失败!");

System.exit(1);

}

//将序列化文件转换成向量文件

try {

Configuration conf = new Configuration();

conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));

String input = WORK_DIR+Path.SEPARATOR+"tennis-seq";

String output = WORK_DIR+Path.SEPARATOR+"tennis-vectors";

Path in = new Path(input);

Path out = new Path(output);

FileSystem fs = FileSystem.get(conf);

if(fs.exists(in)){

if(fs.exists(out)){

//boolean参数是,是否递归删除的意思

fs.delete(out, true);

}

SparseVectorsFromSequenceFiles svfsf = new SparseVectorsFromSequenceFiles();

String[] params = new String[]{"-i",input,"-o",output,"-lnorm","-nv","-wt","tfidf"};

ToolRunner.run(svfsf, params);

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

System.out.println("序列化文件转换成向量失败!");

System.out.println(2);

}

}

public static void makeModel(boolean completelyNB){

try {

Configuration conf = new Configuration();

conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));

String input = WORK_DIR+Path.SEPARATOR+"tennis-vectors"+Path.SEPARATOR+"tfidf-vectors";

String model = WORK_DIR+Path.SEPARATOR+"model";

String labelindex = WORK_DIR+Path.SEPARATOR+"labelindex";

Path in = new Path(input);

Path out = new Path(model);

Path label = new Path(labelindex);

FileSystem fs = FileSystem.get(conf);

if(fs.exists(in)){

if(fs.exists(out)){

//boolean参数是,是否递归删除的意思

fs.delete(out, true);

}

if(fs.exists(label)){

//boolean参数是,是否递归删除的意思

fs.delete(label, true);

}

TrainNaiveBayesJob tnbj = new TrainNaiveBayesJob();

String[] params =null;

if(completelyNB){

params = new String[]{"-i",input,"-el","-o",model,"-li",labelindex,"-ow","-c"};

}else{

params = new String[]{"-i",input,"-el","-o",model,"-li",labelindex,"-ow"};

}

ToolRunner.run(tnbj, params);

}

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

System.out.println("生成训练模型失败!");

System.exit(3);

}

}

}

package myTesting.bayes;

import java.io.IOException;

import java.util.HashMap;

import java.util.Map;

import org.apache.commons.lang.StringUtils;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.fs.Path;

import org.apache.hadoop.fs.PathFilter;

import org.apache.hadoop.io.IntWritable;

import org.apache.hadoop.io.LongWritable;

import org.apache.hadoop.io.Text;

import org.apache.mahout.classifier.naivebayes.BayesUtils;

import org.apache.mahout.classifier.naivebayes.NaiveBayesModel;

import org.apache.mahout.classifier.naivebayes.StandardNaiveBayesClassifier;

import org.apache.mahout.common.Pair;

import org.apache.mahout.common.iterator.sequencefile.PathType;

import org.apache.mahout.common.iterator.sequencefile.SequenceFileDirIterable;

import org.apache.mahout.math.RandomAccessSparseVector;

import org.apache.mahout.math.Vector;

import org.apache.mahout.math.Vector.Element;

import org.apache.mahout.vectorizer.TFIDF;

import com.google.common.collect.ConcurrentHashMultiset;

import com.google.common.collect.Multiset;

public class BayesCheckData {

private static StandardNaiveBayesClassifier classifier;

private static Map<String, Integer> dictionary;

private static Map<Integer, Long> documentFrequency;

private static Map<Integer, String> labelIndex;

public void init(Configuration conf){

try {

String modelPath = "/zhoujianfeng/playtennis/model";

String dictionaryPath = "/zhoujianfeng/playtennis/tennis-vectors/dictionary.file-0";

String documentFrequencyPath = "/zhoujianfeng/playtennis/tennis-vectors/df-count";

String labelIndexPath = "/zhoujianfeng/playtennis/labelindex";

dictionary = readDictionnary(conf, new Path(dictionaryPath));

documentFrequency = readDocumentFrequency(conf, new Path(documentFrequencyPath));

labelIndex = BayesUtils.readLabelIndex(conf, new Path(labelIndexPath));

NaiveBayesModel model = NaiveBayesModel.materialize(new Path(modelPath), conf);

classifier = new StandardNaiveBayesClassifier(model);

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

System.out.println("检测数据构造成vectors初始化时报错。。。。");

System.exit(4);

}

}

/**

* 加载字典文件,Key: TermValue; Value:TermID

* @param conf

* @param dictionnaryDir

* @return

*/

private static Map<String, Integer> readDictionnary(Configuration conf, Path dictionnaryDir) {

Map<String, Integer> dictionnary = new HashMap<String, Integer>();

PathFilter filter = new PathFilter() {

@Override

public boolean accept(Path path) {

String name = path.getName();

return name.startsWith("dictionary.file");

}

};

for (Pair<Text, IntWritable> pair : new SequenceFileDirIterable<Text, IntWritable>(dictionnaryDir, PathType.LIST, filter, conf)) {

dictionnary.put(pair.getFirst().toString(), pair.getSecond().get());

}

return dictionnary;

}

/**

* 加载df-count目录下TermDoc频率文件,Key: TermID; Value:DocFreq

* @param conf

* @param dictionnaryDir

* @return

*/

private static Map<Integer, Long> readDocumentFrequency(Configuration conf, Path documentFrequencyDir) {

Map<Integer, Long> documentFrequency = new HashMap<Integer, Long>();

PathFilter filter = new PathFilter() {

@Override

public boolean accept(Path path) {

return path.getName().startsWith("part-r");

}

};

for (Pair<IntWritable, LongWritable> pair : new SequenceFileDirIterable<IntWritable, LongWritable>(documentFrequencyDir, PathType.LIST, filter, conf)) {

documentFrequency.put(pair.getFirst().get(), pair.getSecond().get());

}

return documentFrequency;

}

public static String getCheckResult(){

Configuration conf = new Configuration();

conf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));

String classify = "NaN";

BayesCheckData cdv = new BayesCheckData();

cdv.init(conf);

System.out.println("init done...............");

Vector vector = new RandomAccessSparseVector(10000);

TFIDF tfidf = new TFIDF();

//sunny,hot,high,weak

Multiset<String> words = ConcurrentHashMultiset.create();

words.add("sunny",1);

words.add("hot",1);

words.add("high",1);

words.add("weak",1);

int documentCount = documentFrequency.get(-1).intValue(); // key=-1时表示总文档数

for (Multiset.Entry<String> entry : words.entrySet()) {

String word = entry.getElement();

int count = entry.getCount();

Integer wordId = dictionary.get(word); // 需要从dictionary.file-0文件(tf-vector)下得到wordID,

if (StringUtils.isEmpty(wordId.toString())){

continue;

}

if (documentFrequency.get(wordId) == null){

continue;

}

Long freq = documentFrequency.get(wordId);

double tfIdfValue = tfidf.calculate(count, freq.intValue(), 1, documentCount);

vector.setQuick(wordId, tfIdfValue);

}

// 利用贝叶斯算法开始分类,并提取得分最好的分类label

Vector resultVector = classifier.classifyFull(vector);

double bestScore = -Double.MAX_VALUE;

int bestCategoryId = -1;

for(Element element: resultVector.all()) {

int categoryId = element.index();

double score = element.get();

System.out.println("categoryId:"+categoryId+" score:"+score);

if (score > bestScore) {

bestScore = score;

bestCategoryId = categoryId;

}

}

classify = labelIndex.get(bestCategoryId)+"(categoryId="+bestCategoryId+")";

return classify;

}

public static void printResult(){

System.out.println("检测所属类别是:"+getCheckResult());

}

}

相关资讯
热门频道

Copyright © 2024 招聘街 滇ICP备2024020316号-38