id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
2c3688e9-7217-4218-b528-fbfb882815df | public void draw() {
logic();
glPushMatrix();
glTranslated(x, y, 0);
glColor3d(0.9, 0, 0);
glBegin(GL_QUADS);
glVertex2d(-8, 0);
glVertex2d(8, 0);
glVertex2d(8, 16);
glVertex2d(-8, 16);
glEnd();
glPopMatrix();
} |
e4106362-bf26-4bda-9c41-7684bd25c9d2 | public void kill() {
double coins = 4 + Math.random()*15;
for (int i = 0; i < coins; i++) Game.coinList.add(new Coin(x, y));
x = Math.random()*640 + Player.x;
kills++;
kill = true;
init();
if (kill) {
wavEffect.playAsSoundEffect(1.3f, 0.04f, false);
}
} |
dd404847-ec57-4512-86bc-7b7102e0cf1f | public static void drawString(String s, int x, int y) {
int startX = x;
GL11.glBegin(GL11.GL_POINTS);
for (char c : s.toLowerCase().toCharArray()) {
if (c == 'a') {
for (int i = 0; i < 8; i++) {
GL11.glVertex2f(x + 1, y + i);
GL11.glVert... |
3bfccf8c-4f45-4dc0-969b-e8e56da54c7d | public static void end() {
if (Enemy.kills == 10 && Player.deaths <= 10) {
Player.y = -32;
Enemy.y = 0;
glBegin(GL_QUADS);
glColor3d(0.7, 0.8, 0.9);
glVertex2d(0, 0);
glVertex2d(640, 0);
glColor3d(0.5, 0.6, 0.8);
glVertex2d(640, 480);
glVertex2d(0, 480);
glEnd();
glColo... |
8ed2a3b5-6e7f-40b5-9f79-ca64daeb0e41 | @Override
public void init(NutConfig config) {
// log.debug("config ioc:" + config.getIoc());
Dao dao = config.getIoc().get(Dao.class);
for (Class<?> clazz : Scans.me().scanPackage("com.gemas.platform")) {
if (null != clazz.getAnnotation(Table.class)) {
dao.create(clazz, false);
}
}
if (dao.count(U... |
d4198d44-6971-4f45-9cb3-2de3ad488910 | @Override
public void destroy(NutConfig config) {
} |
2969ba90-2e68-4a7e-9822-3435e5526816 | @At
public boolean login(@Param("name") String name,
@Param("passwd") String passwd, HttpSession session) {
if (Strings.isBlank(name) || Strings.isBlank(passwd)) {
return false;
}
name = name.trim().intern();
passwd = passwd.trim().intern();
User user = dao.fetch(User.class,
Cnd.where("name", "="... |
07ffe90c-9bb2-4811-a9e2-afb5be6a0fa2 | @At
@Ok(">>:/")
public void logout(HttpSession session) {
session.invalidate();
} |
801da574-6672-4843-8c53-d8899ee2cf03 | @At
public User me(@Attr("user") User user) {
return user;
} |
15baeaec-55d2-40ec-ae8c-afb0e95b3fdc | @At("/ping")
public Object ping() {
log.debug("Dao == " + dao);
Date date = new Date();
return date;
} |
bdaf9749-5137-4e65-a292-30651dd34dab | public Integer getId() {
return id;
} |
4c172177-ea5e-4e0e-b109-84b89e23d232 | public void setId(Integer id) {
this.id = id;
} |
77fdf47f-7525-471e-a74b-7f5021062c5f | public String getName() {
return name;
} |
fa5ecd64-1a54-4358-abd9-5b34e4d59280 | public void setName(String name) {
this.name = name;
} |
67626654-4dbb-458c-99bd-1c29dd9cc89a | public String getPasswd() {
return passwd;
} |
bfbd353b-e2b7-4340-b554-ba65c8f441b1 | public void setPasswd(String passwd) {
this.passwd = passwd;
} |
e4bf868b-03d5-4c0a-af62-e4f9e8fe3999 | GridLocation(int locationRow, int locationCol)
{
row = locationRow;
col = locationCol;
clear();
} |
cab6ff81-050d-4776-9c25-7f7da041dbc8 | void clear()
{
seed = Content.EMPTY;
} |
400a0d5e-5082-4655-975c-b8061a56a133 | void drawCell()
{
switch(seed)
{
case CROSS : System.out.print("X");
break;
case NOUGHT : System.out.print("O");
break;
case EMPTY : System.out.print(" ");
break;
}
} |
83f15e24-60c2-457c-a13d-adb812fb9df7 | Grid()
{
// initializing the cell array, allocating memory
cell = new GridLocation[ROWS][COLS];
emptySpacesRemaining = ROWS * COLS;
for(int i = 0 ; i<ROWS ; i++)
{
for(int j=0 ; j<COLS ; j++)
{
// initializing each cell in the array
... |
a1a0c767-892a-4210-ab57-cfd4927282bf | public void init()
{
for (int row = 0; row < ROWS; ++row)
{
for (int col = 0; col < COLS; ++col)
{
cell[row][col].clear();
}
}
} |
3d0991bb-3d37-47b0-94ca-fcf7cb4652e0 | void drawGrid()
{
for(int i=0 ; i<ROWS ; i++)
{
for(int j=0 ; j<COLS ; j++)
{
cell[i][j].drawCell();
if (j < COLS - 1) System.out.print("|");
}
System.out.println();
if (i < ROWS - 1)
{
... |
dfd25363-5ae8-4890-9cbc-4626a883f825 | boolean isDraw()
{
// the grid does not have any empty space hence the game is drawn
if(emptySpacesRemaining == 0)
return true;
else return false;
} |
0fd1170f-88cd-4359-b082-00f90d719d9e | boolean hasWon(Content thisSeed)
{ // checking rows for victory
return ( (cell[currentRow][0].seed == thisSeed &&
cell[currentRow][1].seed == thisSeed &&
cell[currentRow][2].seed == thisSeed)
|| // checking columns for victory
... |
3307939e-b63d-4911-8113-5d502f6853e0 | static void about()
{
System.out.println("About entered");
} |
59319b41-b2cf-4f17-a617-91914e4af51f | static void instructions()
{
System.out.println("Instructions entered");
} |
7741c3fa-245c-4565-b1d4-9880c6d8ac0a | public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
GameState cont = null ;
int choice;
do{
System.out.println("MENU:");
System.out.println("--------------------");
System.out.println("1) About");
System.... |
9da1bdcc-1b41-4731-b79d-ea3dd0254551 | GameWorld()
{
// creating the grib object
gameGrid = new Grid();
// initializing the world
worldInit();
do
{
// letting the current player make a move
playerMove(currentPlayer);
// updating the grid and print t... |
4cbef0b6-1dd6-4924-9622-bec8648857d6 | GameState getState()
{
return this.currentState;
} |
1e713154-ca0f-42c0-835a-a5546a684ade | void playerMove(Content thisSeed)
{
// flag that keeps track of the correctness of the input
boolean validInput = true;
do
{
// player X's turn
if(thisSeed == Content.CROSS)
System.out.println("Player X please enter the location where you want ... |
ec22b7fa-b2a9-4724-b1c5-d7b228b0d9b0 | void worldInit()
{
gameGrid.init();
currentState = GameState.PLAYING;
currentPlayer = Content.NOUGHT;
} |
cf5f516d-c2a6-47da-a8d3-b3e5320e871d | void updateGameState(Content thisSeed)
{
// updating the state of the game on the basis of who won the game or game drawn, accordingly
if(gameGrid.hasWon(thisSeed))
{
if(thisSeed == Content.CROSS)
currentState = GameState.CROSS_WON;
if(thisSeed == Con... |
1aac3a7f-c6e0-4ca8-a9fc-562451c6ede6 | proxy2()
{
createproxy();
readaddr();
Thread t=new Thread(this);
t.start();
} |
b2d3803a-1694-4532-8b53-005897264887 | void readaddr()
{
try
{
fin=new FileInputStream("tracker.txt");
while((ch=fin.read())!=-1)
trackeraddr+=(char)ch;
trackeraddr.trim();
System.out.println(trackeraddr);
fin=new FileInputStream("proxy1.txt");
while((ch=fin.read())!=-1)
proxy1addr+=(char)ch;
proxy1addr.trim();
}
catc... |
9d991833-2cba-4cb4-ad9c-5daae6a756e3 | void createproxy()
{
jf=new JFrame("PROXY_SERVER");
Container cp=jf.getContentPane();
cp.setLayout(null);
JLabel jl=new JLabel("PROXY SERVER ##2",JLabel.CENTER);
jl.setFont(new Font("Times New Roman",Font.BOLD,28));
jl.setForeground(Color.BLACK);
JLabel jl1=new JLabel("Details of Requests given to ... |
d69328ec-9a6b-472f-9ef5-aa0545347372 | public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==jbexit)
{
System.exit(0);
}
else if(ae.getSource()==proxyinfo)
{
System.out.print("System Info");
try {
JOptionPane.showMessageDialog(null,"IP Address of the System: "+InetAddress.getLocalHost().getHostAddress()+"\nHost Name:"... |
55eeb05d-89c3-457b-ac60-f0669d15f84a | public void run()
{
try
{
jta.append("Thread Started.");
Socket soc=new Socket(trackeraddr,2000);
DataOutputStream dout=new DataOutputStream(soc.getOutputStream());
dout.writeUTF("PROXY2INFO");
ObjectOutputStream oos=new ObjectOutputStream(soc.getOutputStream());
oos.writeObject(v);
oos.close(... |
021ed72e-dd7d-41d8-8ea8-a65f4ece6fac | public static void main(String args[])
{
new proxy2();
} |
64afe38d-7ec9-471c-a5c4-d5b01c7166e8 | processreqq(proxy2 obj,Socket s)
{
parent=obj;
soc=s;
//readaddr();
Thread t=new Thread(this);
t.start();
} |
188a0081-a086-40d8-a3bc-d03cf222afed | public void run()
{
try
{
String trackeraddr=parent.trackeraddr,proxy1addr=parent.proxy1addr;
DataInputStream din=new DataInputStream(soc.getInputStream());
String req=din.readUTF();
System.out.println(req);
if (req.equals("download"))
{
parent.no_of_req++;
parent.jta.append("Request ... |
1ef19a9c-83cf-400e-ba45-610f67c7ebc8 | tracker()
{
create_tracker();
Thread t=new Thread(this);
t.start();
} |
7696ead7-5c6e-4ec6-9d41-ca9d3a52bd9d | void create_tracker()
{
jf=new JFrame("Tracker");
Container cp=jf.getContentPane();
cp.setLayout(null);
JLabel jl=new JLabel("TRACKER",JLabel.CENTER);
jl.setFont(new Font("Times new Roman",Font.BOLD,28));
jl.setForeground(Color.BLACK);
JLabel jl1=new JLabel("Details of Requests given to Tracker:");... |
074d75ee-5a1e-46e3-884a-32a6cad5934f | public void run()
{
try
{
jta.append("Thread Started in Tracker\n");
ServerSocket ss=new ServerSocket(2000);//opening server port in tracker
while (true)
{
Socket soc=ss.accept();
jta.append("Request from proxy.\n");
//no_of_reqs++;
new proxyinfo(this,soc);
}
}
catch(Exceptio... |
cfe5ec54-bcea-4460-980e-6c91d6701316 | public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==exit)
System.exit(0);
else if(ae.getSource()==trackerinfo)
{
try {
JOptionPane.showMessageDialog(null,"IP Address of the System: "+InetAddress.getLocalHost().getHostAddress()+"\nHost Name:"+InetAddress.getLocalHost().getHostName()+"... |
644f7167-f9e0-4a9b-bbde-c9a2b32bddc7 | public static void main(String args[])
{
new tracker();
} |
ed18e2e8-14ec-4ced-bc18-2c1bba567a00 | proxyinfo(tracker obj,Socket s)
{
parent=obj;
soc=s;
readaddr();
Thread t=new Thread(this);
t.start();
} |
530046f3-58b5-462f-8af9-5f8f5d4d9758 | void readaddr()
{
try
{
fin=new FileInputStream("server.txt");
while((ch=fin.read())!=-1)
serveraddr+=(char)ch;
serveraddr.trim();
System.out.println(serveraddr);
fin=new FileInputStream("proxy1.txt");
while((ch=fin.read())!=-1)
proxy1addr+=(char)ch;
proxy1addr.trim();
System.out.... |
4fc0579f-d00e-4a8f-9fae-ca974e5a6751 | public void run()
{
try
{
DataInputStream din=new DataInputStream(soc.getInputStream());
String req=din.readUTF();
if (req.equals("PROXY1INFO"))
{
parent.jta.append("File names received from proxy1.\n");
ObjectInputStream oin=new ObjectInputStream(soc.getInputStream());
Vector<String> v... |
719f12f3-5dcd-437e-aa26-efa8d1e22a7b | void readaddr()
{
try
{
fin=new FileInputStream("tracker.txt");
while((ch=fin.read())!=-1)
trackeraddr+=(char)ch;
trackeraddr.trim();
fin=new FileInputStream("proxy2.txt");
while((ch=fin.read())!=-1)
proxy2addr+=(char)ch;
proxy2addr.trim();
}
catch(Exception e)
{
System.out.pri... |
14bbc715-6e98-40b7-897b-fafb5f10464c | proxyserver()
{
createproxy();
readaddr();
Thread t=new Thread(this);
t.start();
} |
e413c602-7a8e-460c-9986-2268d916f6b4 | void createproxy()
{
jf=new JFrame("PROXY_SERVER");
Container cp=jf.getContentPane();
cp.setLayout(null);
JLabel jl=new JLabel("PROXY SERVER ##1",JLabel.CENTER);
jl.setFont(new Font("Times New Roman",Font.BOLD,28));
jl.setForeground(Color.BLACK);
JLabel jl1=new JLabel("Details of Requests given to ... |
c3fc5c56-f459-4319-9a5b-24d458c7139f | public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==jbexit)
{
System.exit(0);
}
else if(ae.getSource()==proxyinfo)
{
System.out.print("System Info");
try {
JOptionPane.showMessageDialog(null,"IP Address of the System: "+InetAddress.getLocalHost().getHostAddress()+"\nHost Name:"... |
06e8821e-5e38-423f-ac5d-3bc0b562d303 | public void run()
{
try
{
jta.append("Thread Started.");
Socket soc=new Socket(trackeraddr,2000);
DataOutputStream dout=new DataOutputStream(soc.getOutputStream());
dout.writeUTF("PROXY1INFO");
ObjectOutputStream oos=new ObjectOutputStream(soc.getOutputStream());
oos.writeObject(v);
oos.close(... |
4f3e93eb-c26c-4c39-a74f-44199e346412 | public static void main(String args[])
{
new proxyserver();
} |
fe121912-daf4-4c0f-96f6-5a3296ef7a84 | processreq(proxyserver obj,Socket s)
{
parent=obj;
soc=s;
//readaddr();
Thread t=new Thread(this);
t.start();
} |
fe46776a-f65b-4013-bba3-f6201b80b035 | public void run()
{
try
{
String trackeraddr=parent.trackeraddr,proxy2addr=parent.proxy2addr;
DataInputStream din=new DataInputStream(soc.getInputStream());
String req=din.readUTF();
System.out.println(req);
if (req.equals("download"))
{
parent.no_of_req++;
parent.jta.append("Request ... |
665c4577-0d84-4763-9545-39ad6d4378a3 | server()
{
createwin();
Thread t=new Thread(this);
t.start();
} |
998068d3-b4c8-460f-abcc-b1a78983e921 | void createwin()
{
jf=new JFrame("SERVER");
Container cp=jf.getContentPane();
cp.setLayout(null);
JLabel jl=new JLabel("Server Side of the Architecture ",JLabel.CENTER);
jl.setFont(new Font("Dialog",Font.BOLD,20));
jl.setForeground(Color.BLACK);
JLabel jl1=new JLabel("Server Activity:");
jta=new ... |
4acddb51-f29b-4554-ba3f-6f68d0844c51 | public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==jbexit)
{
System.exit(0);
}
else if(ae.getSource()==info)
{
System.out.print("System Info");
try {
JOptionPane.showMessageDialog(null,"IP Address of the System: "+InetAddress.getLocalHost().getHostAddress()+"\nHost Name:"+Inet... |
a472b7ae-f709-4a91-8a05-18aa58a163ab | public void run()
{
try
{
ServerSocket ss=new ServerSocket(1900);
while(true)
{
Socket s=ss.accept();
jta.append("\nRequest recedived from tracker\n");
// no_of_req++;
new serverprocess(this,s);
}
}
catch(Exception e)
{
System.out.println(e);
e.printStackTrace();
}
} |
ff13a93e-dd8b-4b7f-ae0b-b0637a48f66c | public static void main(String args[])
{
new server();
} |
c715877e-a17d-42d4-8fd1-3fe707a98173 | serverprocess(server obj,Socket s)
{
parent=obj;
soc=s;
readaddr();
Thread t=new Thread(this);
parent.jta.append("Server Thread Started");
t.start();
} |
c191c706-92dc-4015-951d-48ca0b1fdea2 | void readaddr()
{
try
{
fin=new FileInputStream("proxy1.txt");
while((ch=fin.read())!=-1)
proxy1addr+=(char)ch;
proxy1addr.trim();
fin=new FileInputStream("proxy2.txt");
while((ch=fin.read())!=-1)
proxy2addr+=(char)ch;
proxy2addr.trim();
}
catch(Exception e)
{
System.out.printl... |
ba0f46a3-94f5-481f-bb89-c01f656bbcf9 | public void run()
{
try
{
parent.no_of_req++;
DataInputStream din=new DataInputStream(soc.getInputStream());
String req=din.readUTF();
String cip=din.readUTF();
int cport=din.readInt();
String fname=din.readUTF();
parent.jta.append("File Name is "+fname+"\n");
boolean found=false;
in... |
b9688ef9-39e5-4025-bf74-c786f47ad055 | public Query(List<QueryItem> items) {
mItems = items;
} |
e348936b-2daf-476c-a7c2-6338b8766fa8 | public List<QueryItem> getItems() {
return mItems;
} |
3e50e562-bd9c-4a77-aef3-84d8fc9afb7b | public String toString() {
StringBuilder sb = new StringBuilder();
for (QueryItem item : mItems) {
sb.append(item.toString());
sb.append(' ');
}
return sb.toString().trim();
} |
bd118f6f-388e-46ed-be1c-73afef222016 | @Test
public void testTrivialEquation() {
String expected = "2";
String actual = CalcParser.solve("1+1");
assertEquals("1+1 should equal 2", expected, actual);
} |
46e622df-c8dc-4dae-a6a2-ce8ddfce0ffd | @Test
public void testAnotherTrivialEquation() {
String expected = "4";
String actual = CalcParser.solve("2*2");
assertEquals("2*2 should equal 4", expected, actual);
} |
bbf11dca-1d0c-408e-a1ce-6b841cf06938 | @Test
public void testTrivialWithWhiteSpaceEquation() {
String expected = "4";
String actual = CalcParser.solve("2 * 2");
assertEquals("2 * 2 should equal 4", expected, actual);
} |
c2d796d7-9b90-4440-9bd3-1a17b859db49 | @Test
public void testComprehensiveStrings(){
for(String[] equationPair : testStr){
String expected = equationPair[0];
String actual = CalcParser.solve(equationPair[1]);
assertEquals(
String.format("Comprehensive test of \"%s\"", equationPair[1]),
expected,
actual);
}
} |
3ded0506-ce13-44e3-8a1c-a1b1a46da716 | public SearchEngine(String filepath) {
dataFilepath = filepath;
} |
ef56fb52-b302-46af-997a-c372a0f413f4 | public static boolean isMatch(String sentence, String query) {
SearchEngine e = new SearchEngine(PATH);
QueryParser q = new QueryParser();
Query qobj = q.parse(query);
List<String> a = new ArrayList<String>();
a.add(sentence);
for (QueryItem item : qobj.getItems()) {
a = e.searchSentence(a, item);
... |
224de425-790e-4f6a-9761-1dc9bfb8d7ac | public List<String> search(Query query) {
// load data
List<String> searchResults = DataRetriever.getData(dataFilepath);
for (QueryItem subQuery : query.getItems()) {
searchResults = searchSentence(searchResults, subQuery);
}
return searchResults;
} |
a972b388-4f58-490d-9781-89b613a1c6a9 | private List<String> searchSentence(List<String> data, QueryItem query) {
String queryWord = query.getWord();
queryWord = queryWord.toLowerCase();
switch(query.getBeforeOperator()) {
case Not:
queryNOT(data, queryWord);
break;
case Or:
queryOR(data, queryWord);
break;
case And:
que... |
44287b84-4c05-4b0f-a86c-cae43687c4b2 | private void queryNOT(List<String> data, String word) {
String[] dataAr = new String[data.size()];
for(int i = 0; i < data.size(); i++){
dataAr[i] = data.get(i);
}
for (String sentence : dataAr) {
String caseInsensitiveSentence = sentence.toLowerCase();
if (caseInsensitiveSentence.contains(word)) {... |
477dd92b-c7d7-431a-a2ff-63491a127aa5 | private void queryOR(List<String> data, String word) {
} |
81e22bc4-9a5f-4ebd-8847-b6002ec6189e | private void queryAND(List<String> data, String word, int atLeast) {
String[] dataAr = new String[data.size()];
for(int i = 0; i < data.size(); i++){
dataAr[i] = data.get(i);
}
for (String sentence : dataAr) {
String caseInsensitiveSentence = sentence.toLowerCase();
if (!queryANDHasAtLeast(caseIns... |
2b1f2280-ee57-46fc-9673-92b7224d24dd | private boolean queryANDHasAtLeast(String sentence, String word, int atLeast) {
if (atLeast < 0) {
return true;
}
else if (sentence.contains(word)) {
String strippedSentence = sentence.replaceFirst(word, "");
return queryANDHasAtLeast(strippedSentence, word, atLeast - 1);
}
return false;
} |
9bb4de75-945c-4099-97f3-7a95a16fa8aa | private void queryEXACT(List<String> data, String word) {
String[] dataAr = new String[data.size()];
for(int i = 0; i < data.size(); i++){
dataAr[i] = data.get(i);
}
for (String sentence : dataAr) {
String caseInsensitiveSentence = sentence.toLowerCase();
if (!caseInsensitiveSentence.contains(wo... |
13d4e042-af5a-45a5-8c5a-f71f0c9d843b | private void queryRANGE(List<String> data, String word) {
String[] dataAr = new String[data.size()];
for(int i = 0; i < data.size(); i++){
dataAr[i] = data.get(i);
}
for (String sentence : dataAr) {
String caseInsensitiveSentence = sentence.toLowerCase();
if (!caseInsensitiveSentence.matches("([0-9... |
570fa78c-0826-4b41-97c7-64e181309442 | public static String solve(String equation){
String cleanEqn = stripWhitespace(equation);
return pythonEval(cleanEqn);
} |
ac6e0d15-83fe-4b5a-80f2-0910460f2ee3 | private static String stripWhitespace(String equation) {
return equation.replaceAll("\\s", "");
} |
af74a4b1-28ae-4bbc-81c7-3a772d0b2db9 | private static String pythonEval(String equation){
PrintStream tempWriter = null;
BufferedReader reader = null;
try {
// create the python program
File tempFile = new File("temp.py");
tempWriter = new PrintStream(tempFile);
tempWriter.printf("print(%s)", equation);
// prepare it
Process pyth... |
6a4546f4-3fc1-4b7d-a031-b4264ece98a0 | private static void close(Closeable c){
if(c != null){
try {
c.close();
} catch (IOException e) {
// don't care!!
}
}
} |
2f637cdd-a883-432e-8814-a7001982b1a2 | public Query parse(String query) {
query = preprocess(query);
String[] tokens = tokenize(query);
List<QueryItem> items = parse(tokens);
return new Query(items);
} |
80d88d09-fe05-4222-9c11-d7f730dc866c | private String[] tokenize(String query) {
int position = 0;
boolean inQuotes = false;
ArrayList<String> words = new ArrayList<String>();
StringBuilder sb = new StringBuilder();
while (position < query.length()) {
char c = query.charAt(position++);
if (inQuotes) {
if (c == '"') {
words.ad... |
fdf21fce-7e76-4bf7-8d6b-f651dbdb54df | private List<QueryItem> parse(String[] tokens) {
ArrayList<QueryItem> items = new ArrayList<QueryItem>();
QueryOperator nextOp = QueryOperator.And;
for (String token : tokens) {
token = token.toLowerCase();
if (token.charAt(0) == '{') {
token = token.substring(1, token.length()-1);
items.get(item... |
8e29d525-b031-414b-a585-7a77d651dfe9 | private String preprocess(String query) {
// Extract CALC operations
CalcParser calc = new CalcParser();
Matcher m = RE_CALC.matcher(query);
StringBuilder sb = new StringBuilder();
int position = 0;
while (!m.hitEnd()) {
if (m.find()) {
// Add everything before the match to the StringBuilder
... |
8b501f42-a7ee-465f-8728-4d49a7b627cb | private static void main(String[] argv) {
QueryParser q = new QueryParser();
System.out.println(q.parse("The{5}"));
System.out.println(q.parse("\"the * example\"{4} {CALC 8*(8+9/3)}..{CALC 90000/10+1} OR *park NOT bench"));
System.out.println(q.parse("Test {CALC 8+1+3+5/2} oaeu {calc 4+2}"));
System.out.print... |
8f5d8d07-66a4-4a46-8153-7d50b403f388 | public static void main(String[] args) throws FileNotFoundException {
List<String> sentences = loadSentences(args[0]);
String query = args[1];
for (String sentence : sentences) {
if (SearchEngine.isMatch(sentence, query)) {
System.out.println(sentence);
}... |
453115e6-c14a-49e6-a1f1-433fd4258e78 | private static List<String> loadSentences(String filename) throws FileNotFoundException {
Scanner scanner = new Scanner(new File(filename));
scanner.useDelimiter("\n");
List<String> sentences = new ArrayList<String>();
while (scanner.hasNext()) {
sentences.add(scanner.next()... |
9f4c7be1-690a-4eb6-a263-38856b3dc301 | public QueryItem(String word, QueryOperator op) {
this.mWord = word;
mBeforeOperator = op;
} |
456141ad-44f9-4313-9394-dd0e9c3340cf | public String getWord() {
return mWord;
} |
f06676b9-41c7-486b-9bb0-c80b3554c925 | public int getAtLeast() {
return mAtLeast;
} |
e76f04ea-0660-4801-bbae-db853101815c | public void setAtLeast(int v) {
mAtLeast = v;
} |
e5d3e37b-f499-4608-a3e9-b8a83ba2bc9d | public QueryOperator getBeforeOperator() {
return mBeforeOperator;
} |
a5764a10-5b4f-48c4-904d-5b005a54afeb | public String toString() {
String r = this.mWord;
if (mWord.contains(" ")) {
r = '"' + r + '"';
}
r = mBeforeOperator.toString().toUpperCase() + " " + r;
if (mAtLeast > 0) {
r += "{" + Integer.toString(mAtLeast) + "}";
}
return r;
} |
8704f789-e22b-4a13-a4e4-fb1133a5ea41 | public static List<String> getData(String filepath) {
ArrayList<String> sentenceData = new ArrayList<String>();
try {
// get file
File rawData = new File(filepath);
// load file
FileInputStream inputStream = new FileInputStream(rawData);
StringBuilder sentence = new StringBuilder();
// read ... |
39fc5d7c-6ca1-48e3-af34-0a05b28f0a9f | public void setup() {
size(1280,520);
kinect = new Kinect(this);
kinect.start();
kinect.enableDepth(depth);
kinect.enableRGB(rgb);
int h = kinect.getVideoImage().height;
int w = kinect.getVideoImage().width;
int hd = kinect.getDepthImage().height;
int wd = kinect.getDepthImage().width;
System.out.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.