Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void
- gen_uniqterms_gt_doclen_db(Xapian::WritableDatabase& db, const string&)
- {
- Xapian::Document doc;
- Xapian::TermGenerator termgenerator;
- termgenerator.set_document(doc);
- termgenerator.set_stemmer(Xapian::Stem("en"));
- termgenerator.index_text("What is AI (Artificial Intelligence) - "
- "Definition from WhatIs", 1, "S");
- termgenerator.index_text("AI (pronounced AYE-EYE) or artificial "
- "intelligence is the simulation of human "
- "intelligence processes by machines, especially "
- "computer systems. These processes include "
- "learning (the acquisition of information and "
- "rules for using the information), reasoning "
- "(using the rules to reach approximate or "
- "definite conclusions), and self-correction. "
- "Particular applications of AI include expert "
- "systems, speech recognition and machine vision.",
- 1, "XD");
- termgenerator.index_text("What is AI (Artificial Intelligence) - "
- "Definition from WhatIs");
- termgenerator.increase_termpos();
- termgenerator.index_text("AI (pronounced AYE-EYE) or artificial "
- "intelligence is the simulation of human "
- "intelligence processes by machines, especially "
- "computer systems. These processes include "
- "learning (the acquisition of information and "
- "rules for using the information), reasoning "
- "(using the rules to reach approximate or "
- "definite conclusions), and self-correction. "
- "Particular applications of AI include expert "
- "systems, speech recognition and machine vision");
- db.add_document(doc);
- doc.clear_terms();
- termgenerator.index_text("Artificial Intelligence-Wikipedia", 1, "S");
- termgenerator.index_text("Artificial intelligence (AI) is intelligence "
- "exhibited by machines. In computer science, the "
- "field of AI research defines itself as the study "
- "of intelligent agents: any device that perceives "
- "its environment and takes actions that maximize "
- "its chance of success at some goal. "
- "Colloquially, the term artificial intelligence "
- "is applied when a machine mimics cognitive "
- "functions that humans associate with other human "
- "minds, such as learning and problem solving.", 1,
- "XD");
- termgenerator.index_text("Artificial Intelligence-Wikipedia");
- termgenerator.increase_termpos();
- termgenerator.index_text("Artificial intelligence (AI) is intelligence "
- "exhibited by machines. In computer science, the "
- "field of AI research defines itself as the study "
- "of intelligent agents: any device that perceives "
- "its environment and takes actions that maximize "
- "its chance of success at some goal. "
- "Colloquially, the term artificial intelligence "
- "is applied when a machine mimics cognitive "
- "functions that humans associate with other human "
- "minds, such as learning and problem solving.");
- db.add_document(doc);
- }
- DEFINE_TESTCASE(ranker1, generated) {
- Xapian::Ranker *ranker = new Xapian::ListNETRanker();
- Xapian::Database db = get_database("apitest_ranker1",
- gen_uniqterms_gt_doclen_db);
- Xapian::Enquire enquire(db);
- enquire.set_query(Xapian::Query("artificial"));
- Xapian::MSet mymset = enquire.get_mset(0, 10);
- string query ="20001 'artificial'";
- string qrel = "20001 Q0 1 1\n20001 Q0 2 2";
- std::ofstream myfile;
- myfile.open("query.txt");
- myfile << query;
- myfile.close();
- myfile.open("qrel.txt");
- myfile << qrel;
- myfile.close();
- Xapian::prepare_training_file(get_database_path("apitest_ranker1").c_str(),
- "query.txt","qrel.txt",10);
- //ranker->set_database_path(get_database_path("apitest_ranker"));
- //ranker->set_query(Xapian::Query("and"));
- delete ranker;
- return true;
- }
Add Comment
Please, Sign In to add comment