This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import java.awt.event.*; | |
import java.awt.GridLayout; | |
import java.util.*; | |
class CalculatorFrame extends JFrame implements ActionListener{ | |
JTextField screen; | |
JPanel buttonPanel; | |
String operation; | |
Integer result; | |
List<String> operations = Arrays.asList("+","-","*","/","%","C","="); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
import java.awt.*; | |
import java.awt.event.*; | |
class Light extends JPanel implements ActionListener { | |
private JRadioButton r1,r2,r3; | |
private Color color1,color2,color3,bgcolor; | |
Light() { | |
setBounds(0, 0, 640, 480); | |
r1 = new JRadioButton("Red"); |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ann\src\main\java\com\twitter\ann\faiss\NativeUtils.java | |
NativeUtils | |
unpackLibraryFromJarInternal(String path) -> File | |
unpackLibraryFromJar(String path) -> void | |
Unpack library from JAR into temporary path | |
* | |
@param path The path of file inside JAR as absolute path (beginning with | |
'/'), e.g. /package/File.ext | |
@throws IOException If temporary file creation or read/write | |
operation fails |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.\ann\src\main\scala\com\twitter\ann\annoy\AnnoyCommon.scala | |
object AnnoyCommon | |
def apply(scalaParams: AnnoyRuntimeParams): ServiceRuntimeParams | |
def invert(thriftParams: ServiceRuntimeParams): Try[AnnoyRuntimeParams] = | |
thriftParams match | |
class AnnoyRuntimeParams( | |
/* Number of vectors to evaluate while searching. A larger value will give more accurate results, but will take longer time to return. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import nltk | |
import numpy as np | |
from nltk.stem import PorterStemmer | |
from nltk.text import TextCollection | |
from nltk.corpus import stopwords as sw | |
from nltk.tokenize import word_tokenize, sent_tokenize | |
stem = PorterStemmer().stem | |
nltk.download('stopwords') | |
stopWords = sw.words('english') | |
normalize = lambda array: np.divide(array, np.max(array)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# Define constants for the grid world | |
GRID_SIZE = 5 | |
NUM_ACTIONS = 4 | |
NUM_EPISODES = 500 | |
MAX_STEPS_PER_EPISODE = 50 | |
# Define states (representing positions on the grid) | |
STATES = [(i, j) for i in range(GRID_SIZE) for j in range(GRID_SIZE)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zlib from 'zlib'; | |
import sbd from 'sbd'; | |
function calculateZScore(arr) { | |
const mean = arr.reduce((sum, value) => sum + value, 0) / arr.length; | |
const stdDeviation = Math.sqrt(arr.reduce((sum, value) => sum + Math.pow(value - mean, 2), 0) / arr.length); | |
return arr.map(value => (value - mean) / stdDeviation); | |
} | |
function scoreSentence(text) { | |
const sentences = sbd.sentences(text); |