Skip to main content

module analysis::text::search::LuceneTest

rascal-0.40.16

Usage

import analysis::text::search::LuceneTest;

Dependencies

import analysis::text::search::Grammars;
import lang::pico::\syntax::Main;
import util::FileSystem;
import IO;
import List;

syntax WordSplitter

lexical WordSplitter = Word* words;

syntax Word

lexical Word 
= [A-Za-z0-9\-]+ !>> [A-Za-z0-9]
| ![A-Za-z0-9\-]+ !>> ![A-Za-z0-9]
;

data Document

data Document (loc comments = |unknown:///|, str extra = "")

data Analyzer

data Analyzer (Analyzer comments = standardAnalyzer(), Analyzer extra = standardAnalyzer())

function abFilter

str abFilter(str token)

function utFilter

bool utFilter(str token)

function lauSplitDanda

list[str] lauSplitDanda("laudanda")

function an

Analyzer  an()

function commentAnalyzer

Analyzer  commentAnalyzer()

function wordSplitFilter

Filter wordSplitFilter()

function extraAnalyzer

Analyzer  extraAnalyzer()

function indexAnalyzer

Analyzer indexAnalyzer()

function picoIndex

void picoIndex()

function picoSearch

void picoSearch(str term)

function extraSearch

void extraSearch()

function main

void main()

Tests

test extraTermsTest

test bool extraTermsTest() = listTerms(indexFolder, "extra") == {
<"est",2>,
<"tbmen",2>,
<"vires",2>,
<"dbndb",2>,
<"voluntbs",2>,
<"desint",2>,
<"lbu",2>
};

test identifierTest

test bool identifierTest() = document(loc l) <- searchIndex(indexFolder, "src:repnr") && l == |std:///demo/lang/Pico/programs/Fac.pico|;

test analyzerTest1

test bool analyzerTest1() = size(analyzeDocument(|std:///demo/lang/Pico/programs/Fac.pico|, analyzer=an())) == 25;

test analyzerTest2

test bool analyzerTest2() = size(analyzeDocument(|std:///demo/lang/Pico/programs/Fac.pico|, analyzer=commentAnalyzer())) == 7;

test searchDocTest1

test bool searchDocTest1() = size(searchDocument(|std:///demo/lang/Pico/programs/Fac.pico|, "repnr", analyzer=an())) == 5;

test searchDocTest2

test bool searchDocTest2() = size(searchDocument(|std:///demo/lang/Pico/programs/Fac.pico|, "repnr", analyzer=commentAnalyzer())) == 0;

test searchDocTest3

test bool searchDocTest3() = size(searchDocument(|std:///demo/lang/Pico/programs/Fac.pico|, "check", analyzer=commentAnalyzer())) == 1;