id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
20c527cb-ebea-41eb-8911-691e11b15f39 | protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String action = request.getParameter("do");
Dao dao = new Dao();
if ("delete".equals(action)) {
try {
dao.deleteRow(request.getParameter("id"));
} catch (SQLException e) {
e.prin... |
a7715424-709a-45f3-b741-d55eb0710035 | protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
} |
e861c535-ac71-42e9-881d-2eca121e64db | protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("WEB-INF/jsp/Add.jsp").forward(request,
response);
} |
1df0c6a8-7cbe-4012-bf55-495ea96c324c | protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String name = request.getParameter("name");
String code = request.getParameter("code");
if(name != null && code != null){
try {
new Dao().addRow(name, code);
} catch (SQLExcept... |
4a5f215e-23ed-4d63-8269-d482f22c69b6 | public Word(String string) {
this.setWs(string);
setPossibleTypes(string);
this.setWordType(this.possibleTypes);
} |
a45d1567-2858-4f62-8990-237d1a0e9fc5 | public Word(Word w) {
this.setWs(w.ws);
for (Iterator<WordType> iterator = w.possibleTypes.iterator(); iterator.hasNext();) {
WordType wt = iterator.next();
this.possibleTypes.add(wt);
}
this.setWordType(this.possibleTypes);
} |
4bfe54e5-90d4-4c3c-94f9-5e9bc33b2e58 | private void setPossibleTypes(String string) {
// getClosedClassTypes(string);
// getOpenClassTypes(string);
possibleTypes.addAll(WiktionaryParser.getTypes(string));
if(possibleTypes.isEmpty()){
possibleTypes.addAll(WiktionaryParser.getTypes(string.toLowerCase()));
}
if(possibleTypes.isEmpty() & Character.... |
53d81308-6590-4f5a-b5fa-8d33037e9ac3 | private Collection<? extends WordType> getWiktionaryTypes(String string) {
LinkedHashSet<WordType> lhs = new LinkedHashSet<WordType>();
try {
Document doc = Jsoup.connect("http://en.wiktionary.org/wiki/"+string).get();
Elements h2 = doc.getElementsByTag("h2");
for (Iterator<Element> i... |
43cf9993-8cc2-4ddf-b382-ea243f6d3ce2 | public int possibleTypesSize() {
return this.possibleTypes.size();
} |
a34a4469-ee84-4566-8db2-c3ff16d86dba | public void removeFirstWordType() {
if(!this.possibleTypes.isEmpty()){
remove(this.possibleTypes.iterator().next());
}
} |
b148fa2e-17c6-42c8-8587-e08196d29301 | public void remove(WordType wt) {
this.possibleTypes.remove(wt);
setWordType(this.possibleTypes);
} |
a8b9bff5-4fe4-4455-b861-9179cb2dac15 | public WordType getWordType() {
return wt;
} |
ddf774e7-f94d-4c64-9c4c-4a1678561222 | public void setWordType(Set<WordType> pt) {
if(!pt.isEmpty()){
wt = pt.iterator().next();
}
} |
4611914a-ddf2-43b9-bbad-570652a56ae1 | public String getWs() {
return ws;
} |
272889e6-615c-4fbe-a498-cc933a06861e | public void setWs(String ws) {
this.ws = ws;
} |
ada59acc-1d5f-4f38-8205-b7454e7436fa | public String printPossibleTypes(){
String s = "";
for (Iterator<WordType> iterator = this.possibleTypes.iterator(); iterator.hasNext();) {
WordType type = (WordType) iterator.next();
if(s.length()>0){
s += "/";
}
s += type.getClass().getSimpleName();
}
return s;
} |
363a7cc7-4573-4a46-8a4c-14d146e2ef3a | public static void main(String[] args) {
Word w = new Word("Through");
System.out.println(w.printPossibleTypes());
if(w.wt != null){
System.out.println(w.wt.getClass().getName());
}
} |
cc7742d3-cbd8-492d-8986-f186fe47725d | public Sentence(String string) {
type = getSentenceType(string);
String s = removePunctuation(string);
s = separatePunctuation(s);
s = fixConjunctions(s);
List<Word> words = separateWords(s);
// this.fixAmbiguity((ArrayList<Word>) this.words);
seperateSubjectObject(words);
} |
f2b44743-7517-432e-9b4b-95bcbb855c14 | private String removePunctuation(String s) {
s = s.replaceAll("\\.", "");
s = s.replaceAll("!", "");
s = s.replaceAll("\\?", "");
return s;
} |
b2887ac9-d641-45de-847d-ea277e9c3a13 | private SentenceType getSentenceType(String string) {
if(string.endsWith("?")){
return SentenceType.INTERROGATIVE;
} else if(string.endsWith("!")){
return SentenceType.EXCLAMATORY;
} else {
return SentenceType.DECLARATIVE;
}
} |
4eba9888-8a1e-49ea-9bff-95bcaeb44096 | public Sentence(Sentence sentence) {
for (Iterator<Word> iterator = sentence.subject.iterator(); iterator.hasNext();) {
Word w = iterator.next();
this.subject.add(new Word(w));
}
this.verb = sentence.verb;
for (Iterator<Word> iterator = sentence.object.iterator(); iterator.hasNext();) {
Word w = iterat... |
c5a97aab-a137-49c7-a051-8e1698c67a4d | private String separatePunctuation(String s) {
s = s.replaceAll(",", " ,");
return s;
} |
4cbe4526-8a79-4733-aa24-0e8ce6b63bb5 | private String fixConjunctions(String s) {
Scanner sc = new Scanner(s);
String ns = new String();
while (sc.hasNext()) {
String w = sc.next();
if(w.contains("'")){
w=w.replaceAll("ain't$", "is not");
w=w.replaceAll("n't$", " not");
w=w.replaceAll("^let's$", "let us");
w=w.replaceAll("'m$", "... |
2b7f38a4-ed7e-4dce-83f5-d579b95486b8 | private List<Word> separateWords(String string) {
List<Word> words = new ArrayList<Word>();
Scanner s = new Scanner(string);
while (s.hasNext()) {
String w = s.next();
words.add(new Word(w));
}
s.close();
return words;
} |
b68c3c47-d1ce-4e95-8709-de7d2b3c90d2 | private List<Word> joinSubjectObject() {
List<Word> words = new ArrayList<Word>();
words.addAll(subject);
words.add(verb);
words.addAll(object);
return words;
} |
a277de69-a7da-460e-8695-d67c7fff628e | private void seperateSubjectObject(List<Word> words) {
int verbIndex = getVerbIndex(words);
for (int i = 0; i < verbIndex; i++) {
this.subject.add(words.get(i));
}
if(verbIndex>=0){
this.verb = words.get(verbIndex);
}
for (int i = verbIndex+1; i < words.size(); i++) {
this.object.add(words.get(i));... |
22b6bdde-5056-48d0-9b87-8212a3768931 | private int getVerbIndex(List<Word> words) {
for (int i = 0; i < words.size(); i++) {
WordType wordType = words.get(i).getWordType();
if(wordType==null){
continue;
}
if(wordType.getClass().getName().contains("Verb")){
return i;
}
}
return -1;
} |
8096d5a4-0365-4392-9164-11d320d4fc46 | public Sentence reverseSentence() {
Sentence reverseSentence = new Sentence(this);
if(((Verb)reverseSentence.verb.getWordType()).getBaseForm().matches("do")){
reverseSentence.verb = null;
}
List<Word> temp = reverseSentence.object;
reverseSentence.object = reverseSentence.subject;
reverseSentence.subject... |
d91e705a-4482-4fa4-bd93-5df6badb68f2 | public Sentence replaceWH(String info) {
List<Word> words = joinSubjectObject();
String s = this.printWords(words,1);
String [] wh = {"What","Where","When","Why","How","Who","Which"};
for (int i = 0; i < wh.length; i++) {
s = s.replace(wh[i], "").trim();
}
String[] ss = info.split("([\\.!?])\\s+");
... |
a8763b75-98c1-4193-9028-88fadb805bdc | public String printWords(List<Word> wl, int width) {
String s = "";
for (int i = 0; i < wl.size(); i++) {
Word word = wl.get(i);
String wordString = "";
if(word!=null){
wordString = word.getWs();
}
s += String.format("%"+width+"s", wordString);
s += " ";
}
return s;
} |
b4cceb38-57af-4e46-adbe-2c680fe667bb | public String printWordTypes(List<Word> wl, int width) {
String s = "";
for (int i = 0; i < wl.size(); i++) {
Word word = wl.get(i);
String wordTypeString = "Null";
if(word!=null){
WordType wt = word.getWordType();
if(wt != null){
wordTypeString = wt.getClass().getSimpleName();
}
}
s... |
66a43650-6365-4854-8cd1-0d4442d19f02 | public String printWordPossibleTypes(List<Word> wl,int width) {
String s = "";
for (int i = 0; i < wl.size(); i++) {
Word word = wl.get(i);
String wordTypesString = "Null";
if(word!=null){
wordTypesString = word.printPossibleTypes();
}
s += String.format("%"+width+"s", wordTypesString);
s += "... |
455e4172-b95e-4960-acfe-1992728c829b | @Override
public String toString() {
String s = "";
List<Word> words = joinSubjectObject();
int width = -25;
s+=printWords(words,width)+"\n";
s+=printWordTypes(words,width)+"\n";
s+=printWordPossibleTypes(words,width)+"\n";
return s;
} |
22b18fe0-1e50-455c-b32a-27f3ff3c2ce0 | public ArrayList<Sentence> getNextPossibleSenses() {
ArrayList<Sentence> sl = new ArrayList<Sentence>();
List<Word> words = joinSubjectObject();
for (int i = 0; i < words.size(); i++) {
if(words.get(i).possibleTypesSize() > 1){
Sentence s = new Sentence(this);
List<Word> sWords = s.joinSubjectObject();... |
18625c5a-7857-4abe-a747-e4f6cabaf83b | public static Collection<? extends WordType> getTypes(String string) {
LinkedHashSet<WordType> lhs = new LinkedHashSet<WordType>();
try {
Document doc = Jsoup.connect("http://en.wiktionary.org/wiki/"+string).get();
Element english = doc.getElementById("English");
if(english == null){
return lhs;
... |
503eed8b-7ab3-45d3-8c14-d9d4102e1de6 | private static String getBaseForm(Elements verbContent) {
String baseForm = "";
for (Element element : verbContent) {
if(element.tagName() == "ol"){
String definition = element.child(0).text();
if(definition.matches(".* form of \\w+")){
baseForm = definition.replaceAll("^.*? (\\w+)$", "$1");
}
... |
3ed85d0d-e52b-44b4-908f-8a5679338565 | private static Elements getContent(Element title) {
if(title == null){
return null;
}
Element el = title.nextElementSibling();
Elements els = new Elements();
while(el!=null && tagLevel(el)>tagLevel(title)){
els.add(el);
el = el.nextElementSibling();
}
return els;
} |
a483ac58-98d0-4269-9568-458f1037c3bc | private static int tagLevel(Element el) {
Pattern p = Pattern.compile("\\d");
Matcher m = p.matcher(el.tagName());
if(m.find()){
return Integer.parseInt(m.group());
} else {
return Integer.MAX_VALUE;
}
} |
8a7c56d7-50af-4397-b8e4-9938ccc7d8b1 | public static Sentence findGoodSentence(Sentence s, int credits){
List<Sentence> sl = new ArrayList<Sentence>();
List<Sentence> nsl = new ArrayList<Sentence>();
sl.add(s);
for (int i = 0; i < credits; i++) {
System.out.println("credit: "+i);
if(sl.size() == 0){
System.out.println("No more senses fou... |
1ea57d7b-b6f5-4a3e-aff2-0ae3b521f9ce | private static boolean checkGrammar(Sentence sentence) {
// System.out.println(sentence);
return true;
} |
90102562-02ad-44f2-bb32-dbb9f8f1fcb3 | private static Sentence answer(Sentence question, String info){
// reverse sentence: what is that -> that is what
Sentence answer = question.reverseSentence();
System.out.println(answer);
// replace interrogative word
answer = answer.replaceWH(info);
return answer;
} |
1de5a890-51c5-4278-b655-7da9fdb976af | public static void main(String[] args) {
Sentence s;
String st;
// st = "Dani ate the apple that stood on the table";
// s = new Sentence(st);
// findGoodSentence(s, 1);
// System.out.println(st);
//// System.out.println(s);
// System.out.println(findGoodSentence(s, 1));
// st = "he did the thing and was o... |
b07b1579-69ae-490c-bb8c-a00365033ee1 | public Verb() {
} |
a17b5b3e-2d45-48bb-8f21-a5062b7d00d3 | public void setBaseForm(String s) {
baseForm = s;
} |
826f9594-d38a-4784-8e45-04d1b0a8978b | public String getBaseForm() {
return baseForm;
} |
bfeb864d-b834-42ce-a258-307ea4da98e4 | public Noun() {
} |
6316c55d-c15f-437f-acb3-c71fa89801ad | public Prep() {
} |
5c2c24aa-66b6-4a5c-b872-94910ed4bb14 | public Pron() {
} |
080c9d59-a7d1-4bcd-92e5-ae59a702883a | public Adj() {
} |
f39a7419-199e-4bf6-b738-92246fe27384 | public Conj() {
} |
4ca85def-6c79-40e2-9ae6-db37ef2ea64e | public Adv() {
} |
68bc64f9-2160-4916-bd99-7e9d985d9146 | public Det() {
} |
c09afc1a-2ec1-487a-97a1-95b60e092e11 | public TwitchTVChannelLinks(final String username) throws FetchLinksException {
if (username == null || username.isEmpty()) {
throw new IllegalArgumentException("username cannot be null or \"\"");
}
this.TWITCH_USERNAME = username;
try {
this.RES... |
0ae61c04-6fd1-4e64-a581-8fd8c8cc15f4 | private String extractProperty(String propertyName) throws FetchLinksException {
JsonParser parser = new JsonParser();
try {
JsonObject responseJson = (JsonObject) parser.parse(this.RESPONSE);
if (!responseJson.isJsonNull()) {
JsonObject link... |
c0a878d3-efcc-42ed-9144-09fb98e72359 | public String getTwitchUsername() {
return this.TWITCH_USERNAME;
} |
0f874fde-a833-4bf5-b27f-4baeccc3c035 | public String getFollowsUrl() {
return this.FOLLOWS_URL;
} |
909d9f86-eaca-418b-8ec2-25df3f78538f | public String getTeamsUrl() {
return this.TEAMS_URL;
} |
819c640e-e5c7-4a93-8639-6f39a87f5287 | public String getChannelUrl() {
return this.CHANNEL_URL;
} |
64fd8d70-dd3b-4357-87c9-0c227ecdfb02 | public String getCommercialUrl() {
return this.COMMERCIAL_URL;
} |
a99aa54f-4df4-4bb1-9189-90fce95bec1a | public String getStreamKeyUrl() {
return this.STREAM_KEY_URL;
} |
9a1c438c-6922-407b-95ed-322d44e2a68e | public String getChatUrl() {
return this.CHAT_URL;
} |
e08297c7-a822-4de9-ad15-45d7c821d833 | public String getFeaturesUrl() {
return this.FEATURES_URL;
} |
c0a63fc7-da9a-430d-9404-3bd5965ebb5f | public String getSubscriptionsUrl() {
return this.SUBSCRIPTIONS_URL;
} |
383b84e7-a453-40ae-9001-0167b4cdae4a | public String getEditorsUrl() {
return this.EDITORS_URL;
} |
b0f5a1f3-52e4-4ebb-b504-d19c8c348da1 | public String getVideosUrl() {
return this.VIDEOS_URL;
} |
d1ffb84e-836f-4e9c-89e7-faaea06003b5 | public TwitchTVStream(final String username) {
if (username == null || username.isEmpty()) {
throw new IllegalArgumentException("username cannot be null or empty");
}
this.TWITCH_USERNAME = username;
} |
9d6e8570-031e-4c6a-8bb4-ec22c1bed6cb | public boolean isLive() throws IOException, MimeTypeParseException {
String response = HttpRequest.performRequest(this.TWITCH_API_STREAM_BASE_URL + this.TWITCH_USERNAME, this.MIME_TYPE);
JsonParser parser = new JsonParser();
JsonObject streamJson = (JsonObject) parser.parse(response... |
da014843-0d21-4cfa-8712-3dc2e30f5086 | public String getViewers() {
if (this.STREAM_VIEWERS_VALUE == null) {
throw new IllegalStateException("isLive() method has to be called first");
}
return this.STREAM_VIEWERS_VALUE;
} |
297b46b3-69bb-48a8-bf58-f73680b4f306 | public String getTitle() {
if (this.STREAM_VIEWERS_VALUE == null) {
throw new IllegalStateException("isLive() method has to be called first");
}
return this.STREAM_TITLE_VALUE;
} |
f805193e-c489-4470-824a-c27c28d84da3 | public String getGame() {
if (this.STREAM_VIEWERS_VALUE == null) {
throw new IllegalStateException("isLive() method has to be called first");
}
return this.STREAM_GAME_VALUE;
} |
bce85965-dc65-4a7d-9b80-26608a216bae | public String getUrl() {
if (this.STREAM_VIEWERS_VALUE == null) {
throw new IllegalStateException("isLive() method has to be called first");
}
return this.STREAM_URL_VALUE;
} |
384de011-4b00-48ce-94e9-d7c2d6bf890f | public String getDisplayName() {
if (this.TWITCH_DISPLAYNAME_VALUE == null) {
throw new IllegalStateException("isLive() method has to be called first");
}
return this.TWITCH_DISPLAYNAME_VALUE;
} |
63be756a-91a3-46bc-a0e8-043a217bf215 | public String getPreviewSmall() {
if (this.STREAM_PREVIEW_SMALL_VALUE == null) {
throw new IllegalStateException("isLive() method has to be called first");
}
return this.STREAM_PREVIEW_SMALL_VALUE;
} |
9208df17-0e56-4c1f-abca-03836bf820ae | public String getPreviewMedium() {
if (this.STREAM_PREVIEW_MEDIUM_VALUE == null) {
throw new IllegalStateException("isLive() method has to be called first");
}
return this.STREAM_PREVIEW_MEDIUM_VALUE;
} |
3e56ecf5-57f2-4622-848b-c6f95b8890d7 | public String getPreviewLarge() {
if (this.STREAM_PREVIEW_LARGE_VALUE == null) {
throw new IllegalStateException("isLive() method has to be called first");
}
return this.STREAM_PREVIEW_LARGE_VALUE;
} |
7dfe720f-1994-474d-b63b-bec9c1a0a734 | public static String performRequest(URL url, MimeType mime) throws IOException {
HttpURLConnection conn = null;
BufferedReader br = null;
try {
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Acc... |
0ecdd789-1590-48c8-9595-5668071fe96d | public static String performRequest(String url, String mime) throws IOException, MimeTypeParseException {
return performRequest(new URL(url), new MimeType(mime));
} |
67178118-2d43-4a24-8ec0-5aa4d2ee082b | public static String performRequest(URL url, String mime) throws MimeTypeParseException, IOException {
return performRequest(url, new MimeType(mime));
} |
6b0a335f-612a-4ce6-8a95-9021cdf324d8 | public static String performRequest(String url, MimeType mime) throws IOException {
return performRequest(new URL(url), mime);
} |
e14889f8-8d91-4fce-8bda-76fa0e357482 | @Override
public String getMessage() {
return "Could not fetch links.";
} |
a6123ed1-e429-4ef3-b8aa-ec7f93c61aa1 | @Override
public String getLocalizedMessage() {
return "Could not fetch links.";
} |
8ba7dbd2-c23a-4f93-aaac-8b1401b1659d | public TwitchTVAppGUI() {
initComponents();
lblUrlValue.setCursor(new Cursor(Cursor.HAND_CURSOR));
} |
37f6ea82-ca67-4b56-aa99-600dff56f90d | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
lblChannelName = new javax.swing.JLabel();
tfChannelName = new javax.swing.JTextField();
btnCheckLive = new javax.swing.JButton();
... |
98d1eae6-1dc7-462a-b74b-a348eba9a079 | public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCheckLiveActionPerformed(evt);
} |
dfadef3c-d39f-4719-91f0-ab4eec20d0b2 | private void btnCheckLiveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheckLiveActionPerformed
if (this.isLiveThreadRunning == true)
return;
Thread thread = new Thread(() -> {
// THREAD BEGIN
this.isLiveThreadRunning = tr... |
f837678d-7f9c-4928-98de-41d1ecf80721 | @Override
public void mouseClicked(MouseEvent me) {
if (Desktop.isDesktopSupported() == true) {
try {
Desktop.getDesktop().browse(new URI(url));
} catch (IOException | ... |
f26e688d-63c0-45db-b002-096cb3785bc5 | @Override
public void mousePressed(MouseEvent me) {
} |
cf823a48-f414-4ab3-9b70-6c86c59409ce | @Override
public void mouseReleased(MouseEvent me) {
} |
8f0ab104-ad7f-4db8-adbb-bcdf9b1b0367 | @Override
public void mouseEntered(MouseEvent me) {
} |
70db9f2f-4d1f-4488-9ae1-4137e622d765 | @Override
public void mouseExited(MouseEvent me) {
} |
8cb90a0b-a419-42d2-904a-a42a65ca8345 | private void printErrorToStreamStatusLbl() {
this.lblStreamStatus.setForeground(Color.BLACK);
this.lblStreamStatus.setText("Something went wrong...");
} |
8750222b-9f4b-4a88-bdf4-b8ddbfd74e63 | private void clearLabels() {
this.lblTitleValue.setText("");
this.lblGameValue.setText("");
this.lblViewersValue.setText("");
this.lblUrlValue.setText("");
for (MouseListener listener : this.lblUrlValue.getMouseListeners()) {
this.lblUrlValue.removeMouseListen... |
bd24a309-d776-4cd3-a749-1b61350f9558 | public static void main(String args[]) {
/* Set the Windows look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://dow... |
9e69a7ff-ceee-4bb9-8700-64b3244e39a5 | public ImageProxy( URL imageURL )
{
this.imageURL = imageURL;
} |
ca5b9a26-4c5e-47f5-a60b-2dcdc744c216 | @Override
public void paintIcon( final Component c, Graphics g, int x, int y )
{
if ( imageIcon != null )
{
imageIcon.paintIcon( c, g, x, y );
}
else
{
g.drawString( "Loading Stream Preview, please wait...", x, y );
if ( !retrieving )
{
... |
cba34394-26f1-4a06-897f-09a8da816d09 | @Override
public int getIconWidth()
{
if ( imageIcon != null )
{
return imageIcon.getIconWidth();
}
else
{
return 320;
}
} |
78eea594-16b2-498f-adf2-e9a5f2d6c493 | @Override
public int getIconHeight()
{
if ( imageIcon != null )
{
return imageIcon.getIconHeight();
}
else
{
return 200;
}
} |
643546fb-e5f5-49d3-8a73-da99bed3f554 | public ImageComponent( Icon icon )
{
this.icon = icon;
} |
b4594dce-54e8-4f1f-a652-a01e6c17e001 | public void setIcon( Icon icon )
{
this.icon = icon;
} |
8f84610d-486c-4deb-8aac-4f2b2493d26f | @Override
public void paintComponent( Graphics g )
{
super.paintComponent( g );
int x = 0;
int y = 0;
icon.paintIcon( this, g, x, y );
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.