from org.apache.lucene.util import Version from org.apache.lucene.analysis.miscellaneous import PerFieldAnalyzerWrapper from java.util import HashMap from lxml import etree from search import Searcher from index import Indexer, CustomAnalyzer INDEX_DIR = 'index' # DATA_DIR = 'data/dblp.xml' DATA_DIR = 'data/dblp_small.xml' if __name__ == "__main__": # user inputs topN = 10 lucene.initVM() # index documents config = {'lowercase': True, 'stemming': True, 'stopwords': True} title_analyzer = CustomAnalyzer(config) per_field = HashMap() per_field.put("title", title_analyzer) analyzer = PerFieldAnalyzerWrapper( StandardAnalyzer(Version.LUCENE_CURRENT), per_field) Indexer(DATA_DIR, INDEX_DIR, context, analyzer) searcher = Searcher(INDEX_DIR, analyzer) # # q = raw_input("Query: ") # # searcher.search(q, N=topN) searcher.run(topN)
from search import Searcher from connectionist import Connectionist from vertex import Vertex n_vertices = 10 # number of elements/nodes g = Generator(n_vertices) searcher = Searcher() connector = Connectionist() n = 20 # number of runs for i in range(n): g.generate() belief_network = g.get_belief_network() neural_network = g.get_neural_network() coherence, (true, false) = searcher.run(belief_network) print 'coherence search:', coherence print 'accepted propositions:', sorted(true, key=lambda v: v.n) print 'rejected propositions:', sorted(false, key=lambda v: v.n) print '-----------------------------------------------' activations, harmony = connector.run(neural_network) print 'harmony', harmony true = [] false = [] for i, a in enumerate(activations): if a == 1: true.append(Vertex(i)) else: false.append(Vertex(i)) print 'accepted propositions:', sorted(true, key=lambda v: v.n)
from java.util import HashMap from search import Searcher from index import CustomAnalyzer from utils import check_config CONFIG_DIR = 'config.json' INDEX_DIR = 'index' DATA_DIR = 'data/dblp.xml' # run search on command line # see ui_search.py to use the search via web UI if __name__ == "__main__": with open(CONFIG_DIR) as f: config = json.load(f) config = check_config(config) lucene.initVM() # start JVM for Lucene # index documents # use different analyzer for title field title_analyzer = CustomAnalyzer(config['titleAnalyzer']) per_field = HashMap() per_field.put("title", title_analyzer) analyzer = PerFieldAnalyzerWrapper( StandardAnalyzer(Version.LUCENE_CURRENT), per_field) searcher = Searcher(INDEX_DIR, analyzer) # q = raw_input("Query: ") # searcher.search(q, N=config['topN']) searcher.run(config['topN'])