Skip to content

Commit

Permalink
Search now doesn't require 'word' dashes, cf LispSyntaxParser. avprep…
Browse files Browse the repository at this point in the history
…rocess.py audio timeslot miscounting mistake fixed
  • Loading branch information
Dominik Messinger authored and Dominik Messinger committed Jul 11, 2013
1 parent 19c48d6 commit a0d052a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

public class MainWindow extends JFrame {
private static final long serialVersionUID = 1L;
private static final String START_SEARCH = "computer";
private JTextField txtSearch;
private JList<SearchResultEntry> resultList = new JList<>();
private JLabel lblStatus = new JLabel("Loading ...");
Expand All @@ -54,7 +55,7 @@ public MainWindow(File indexFile) throws IOException {
status("Index " + indexFile.getAbsolutePath() + " loaded");

// debugging
txtSearch.setText("'dient'");
txtSearch.setText(START_SEARCH);
actSearch.actionPerformed(null);

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package edu.kit.iti.algo2.textindexing.searchengine.expr;


public class LispSyntaxParser {
private static final char LPAREN = '(';
private static final char RPAREN = ')';
private static final char WORD = '\'';
private static final String WORD_BEGIN = "[a-zA-Z0-9]";

int pos = -1;
private String input;
Expand All @@ -13,7 +13,7 @@ public class LispSyntaxParser {
public LispSyntaxParser(String query) {
input = query.trim();
consume();
if (!match(LPAREN) && !match(WORD)) {
if (!match(LPAREN) && !("" + current).matches(WORD_BEGIN)) {
throw new IllegalArgumentException(
"query should start with LPAREN or WORD");
}
Expand All @@ -31,7 +31,7 @@ public Expr parse() {
return parseParenLeft();
}

if (match(WORD)) {
if (("" + current).matches(WORD_BEGIN)) {
return parseWord();
}
consume();
Expand All @@ -40,11 +40,12 @@ public Expr parse() {
}

private Expr parseWord() {
if (!match(WORD))
throw new IllegalStateException("expected: WORD (" + WORD
+ ") got:" + current);
consume();
String w = consumeUntil(WORD);
/*
* if (!match(WORD)) throw new IllegalStateException("expected: WORD ("
* + WORD + ") got:" + current);
*/
// consume();
String w = consumeUntil(' ', ')');

if (w.contains("*")) {
return new FuzzyWordExpr(w);
Expand All @@ -69,10 +70,12 @@ private Expr parseParenLeft() {
return me;
}

private String consumeUntil(char c) {
int p = input.indexOf(c, pos);
String s = input.substring(pos, p);
pos = p;
private String consumeUntil(char... c) {
int p = pos;
while(!(new String(c).contains("" + current)) && pos < input.length()) {
consume();
}
String s = input.substring(p, pos);
consume();
return s;
}
Expand Down
4 changes: 2 additions & 2 deletions video/avpreprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def extract_audio(input_video, target_folder, deltaT):
pool = Pool(4)

for t in range(0, length, deltaT):
p = {'src': input_video, 'out': target_folder + "/" + str(t / deltaT), 'start': t, 'duration': deltaT}
p = {'src': input_video, 'out': target_folder + "/" + str((t / deltaT) + 1), 'start': t, 'duration': deltaT}
s = COMMAND_EXTRACT_AUDIO.substitute(p)
execute_with_log(s)
#pool.apply_async(os.system, s)
Expand Down Expand Up @@ -202,7 +202,7 @@ def main(inputfile, video=True, audio=True,

adocs = vdocs = []
if audio:
#extract_audio(inputfile, newAudioDir, deltaT)
extract_audio(inputfile, newAudioDir, deltaT)
audios = gather_files(newAudioDir, "*flac", deltaT)
adocs = map(sr, audios)

Expand Down

0 comments on commit a0d052a

Please sign in to comment.