Posts

Lucene search result -

i have below data index in lucene 4.8 , code. finance expense admin expenses transaction expense salary expenses indexing: try { writer = createwriter(ramdirectory); for(string line : readfile(file_path)) { string[] split = line.split(","); document doc = new document(); doc.add(new textfield("id", split[0].trim(), field.store.yes)); doc.add(new textfield("name", split[1].trim(), field.store.yes)); writer.adddocument(doc); } writer.commit(); } { if(writer != null) { writer.close(); } } search indexsearcher searcher = new indexsearcher(directoryreader.open(ramdirectory)); queryparser nameqparser = new queryparser(version.lucene_48, "name", new standardanalyzer(version.lucene_48)); query query = nameqparser.parse("expense"); topdocs queryresults = searcher.search(query, 10); above c...

javascript - onInit, onAfterRendering not being called when returning back to the page -

i have developed 2 views view1.xml , view2.xml in both implemented oninit() , onafterrendering() . implemented button use router.navto() method. when come view2 view1, view1's oninit/onafterrendering not called. same happens if press browser's button. please help! oninit , called once, that's how defined! furthermore, instead of relying on onafterrendering should listen matched events of routes, see navigation , routing tutorial of sdk! never know when view gets rerendered, make sure understand when makes sense it, i.e. modify dom after rerendering has happened or if need register third party libs somewhere in dom...

Definition of conversation in botframework -

i bit confused on definition of "conversationid". can explain conversation exactly? use case needs state group conversation, long bot group, want maintain state. i want know how differentiate group conversation vs conversation 1 user. the message types documentation explains messages begin , end conversation users , bots. page indicates messages channel specific, meaning channels send conversation message , others might not. so, once choose channels, you'll need experiment or read channel specific documentation see if send messages start , end conversation. prepare, bot framework emulator has drop-down list send button can test how code handles these messages.

Python for loop control variable accessed before declaration -

this question has answer here: python for-in loop preceded variable 4 answers i'm new python, , i'm trying understand following line: "".join(char char in input if not unicodedata.category(char).startswith('p')) source: https://stackoverflow.com/a/11066443/3818487 this code removes unicode punctuation input. don't understand why works. far can tell, iterates on characters in input ignoring punctuation characters. how can access char before declared in loop? come java background, confusing me. this comprehension more following, in regular code (using list store our non-punctuation characters). #input defined somewhere prior loop output = [] char in input: if not unicodedata.category(char).startswith('p'): output.append(char) ''.join(output) comprehensions iterate on loop portion first, va...

python - Python3: What this "%" means in this code? -

this question has answer here: what significance of % in python [closed] 5 answers i'm study python 3, , % in code, see below: def main(): maxwidth = 100 # limita o numero de caracteres numa célula print_start() # chama função print_start count = 0 # cria uma variavel cont while true: try: line = input() if count == 0: color = "lightgreen" elif count % 2: color = "white" else: color = "lightyellow" print_line(line, color, maxwidth) count += 1 except eoferror: break print_end() # chama função print_end what elif count % 2: line means? this called modulo or modulus operator . it divides "left" value "right" value , returns remainder (the amount left on after division). it's commonl...

c# - Operator To Return if one and ONLY One Argument is True -

i'm making if statement in c# return true if 1 of parameters true. i'll use || in example because that's closest thing can think of: int = 1; int b = 2; int c = 3; if(a == 1 || b == 2) { console.log("the first statement true") } if(a == 1 || b == 3) { console.log("the second statement true") } if(a == 0 || b == 0 || c == 3) { console.log("the third statement true") } if(a == 1 || b == 0 || c == 3) { console.log("the fourth statement true") } //output: //the second statement true //the third statement true again, think of || operator i'm looking for. such operator exist, or should define own boolean function? for 2 expressions, can use xor: if (a == 1 ^ b == 0) for more two, like: if (new[] { == 1, b == 0, c == 2 }.count(x => x) == 1) that counts "true" elements of array constructed expressions, , checks count 1. admittedly evaluate conditions first, , count of them if first 2 true (so...

can python and php access same mysqldb? -

is possible access same mysql database using python , php.beacause developing video searching website based on semantics. purposely have use python , javaee. have make datbase store video data. should accessed through both python , javaee, can use php interfacing between javaee mysql database. problem python can access same database.? i new here , developing. appreciate kindness. think can best solution it's database. doesn't care language or application you're using access it. that's 1 of benefits of having standards mysql protocol, sql in general, or things tcp/ip: allow different systems seamlessly inter-operate.