code stringlengths 146 466k | prompt stringlengths 54 1.5k |
|---|---|
Of course, here is the Java code you requested:
```java
public static <TERM> Map<TERM, Double> tfIdf(Map<TERM, Double> tf, Map<TERM, Double> idf)
{
return tfIdf(tf, idf, Normalization.NONE);
}
```
Hope this helps! | Create a Java method that does the following: "Get the TF IDF map.". |
Of course, here is the Java code you requested:
```java
public static <TERM> Map<TERM, Double> idfFromTfs(Iterable<Map<TERM, Double>> tfs, boolean smooth, boolean addOne)
{
return idf(new KeySetIterable<TERM, Double>(tfs), smooth, addOne);
}
```
Hope this helps! | Create a Java method that does the following: "Create a IDF from a Iterable of TFS.". |
Of course, here is the Java code you requested:
```java
public static Pinyin[] convert2Array(String complexText, boolean removeTone)
{
return PinyinUtil.convertList2Array(convert(complexText, removeTone));
}
```
Hope this helps! | Create a Java method that does the following: "Convert a string to an array of Pinyin objects.". |
Of course, here is the Java code you requested:
```java
public static List<Pinyin> convert(String complexText)
{
List<Pinyin> pinyinList = new LinkedList<Pinyin>();
Collection<Token> tokenize = trie.tokenize(complexText);
// System.out.println(tokenize);
for (Token token : tokenize)
... | Create a Java method that does the following: "Convert a text into a list of Pinyin objects.". |
Of course, here is the Java code you requested:
```java
public static Pair<List<Pinyin>, List<Boolean>> convert2Pair(String complexText, boolean removeTone)
{
List<Pinyin> pinyinList = new LinkedList<Pinyin>();
List<Boolean> booleanList = new LinkedList<Boolean>();
Collection<Token> tokeniz... | Create a Java method that does the following: "Convert a text to a pair of Pinyin objects.". |
Of course, here is the Java code you requested:
```java
public static Pinyin convertSingle(String single)
{
Pinyin pinyin = map.get(single);
if (pinyin == null) return Pinyin.none5;
return pinyin;
}
```
Hope this helps! | Create a Java method that does the following: "Convert a single string to a Pinyin object.". |
Of course, here is the Java code you requested:
```java
public static List<Pinyin> makeToneToTheSame(List<Pinyin> pinyinList)
{
ListIterator<Pinyin> listIterator = pinyinList.listIterator();
while (listIterator.hasNext())
{
listIterator.set(convert2Tone5(listIterator.next()));
... | Create a Java method that does the following: "Make the Tone to the same.". |
Of course, here is the Java code you requested:
```java
public IDependencyParser setDeprelTranslater(String deprelTranslatorPath)
{
deprelTranslater = GlobalObjectPool.get(deprelTranslatorPath);
if (deprelTranslater != null) return this;
IOUtil.LineIterator iterator = new IOUtil.LineIterat... | Create a Java method that does the following: "Set the deprel translator.". |
Of course, here is the Java code you requested:
```java
public int get(String suffix)
{
suffix = reverse(suffix);
Integer length = trie.get(suffix);
if (length == null) return 0;
return length;
}
```
Hope this helps! | Create a Java method that does the following: "Gets the length of a sequence of tokens that have the specified suffix.". |
Of course, here is the Java code you requested:
```java
public boolean endsWith(String word)
{
word = reverse(word);
return trie.commonPrefixSearchWithValue(word).size() > 0;
}
```
Hope this helps! | Create a Java method that does the following: "Returns true if the sequence contains the word.". |
Of course, here is the Java code you requested:
```java
public int getLongestSuffixLength(String word)
{
word = reverse(word);
LinkedList<Map.Entry<String, Integer>> suffixList = trie.commonPrefixSearchWithValue(word);
if (suffixList.size() == 0) return 0;
return suffixList.getLast(... | Create a Java method that does the following: "Gets the longest suffix length of a word.". |
Of course, here is the Java code you requested:
```java
public Set<Map.Entry<String, Integer>> entrySet()
{
Set<Map.Entry<String, Integer>> treeSet = new LinkedHashSet<Map.Entry<String, Integer>>();
for (Map.Entry<String, Integer> entry : trie.entrySet())
{
treeSet.add(new Abstr... | Create a Java method that does the following: "Get a Set of Entry objects from the map.". |
Of course, here is the Java code you requested:
```java
public static CoreDictionary.Attribute getAttribute(String word)
{
CoreDictionary.Attribute attribute = CoreDictionary.get(word);
if (attribute != null) return attribute;
return CustomDictionary.get(word);
}
```
Hope this helps! | Create a Java method that does the following: "Get the attribute for a word.". |
Of course, here is the Java code you requested:
```java
public static int getFrequency(String word)
{
CoreDictionary.Attribute attribute = getAttribute(word);
if (attribute == null) return 0;
return attribute.totalFrequency;
}
```
Hope this helps! | Create a Java method that does the following: "Gets the frequency of a word.". |
Of course, here is the Java code you requested:
```java
public static boolean setAttribute(String word, CoreDictionary.Attribute attribute)
{
if (attribute == null) return false;
if (CoreDictionary.trie.set(word, attribute)) return true;
if (CustomDictionary.dat.set(word, attribute)) retur... | Create a Java method that does the following: "Sets the attribute for a word.". |
Of course, here is the Java code you requested:
```java
public static boolean setAttribute(String word, Nature... natures)
{
if (natures == null) return false;
CoreDictionary.Attribute attribute = new CoreDictionary.Attribute(natures, new int[natures.length]);
Arrays.fill(attribute.frequen... | Create a Java method that does the following: "Sets the attribute for a CIS tag word.". |
Of course, here is the Java code you requested:
```java
public static boolean setAttribute(String word, String... natures)
{
if (natures == null) return false;
Nature[] natureArray = new Nature[natures.length];
for (int i = 0; i < natureArray.length; i++)
{
natureArray[... | Create a Java method that does the following: "Sets the attribute of the CRASS". |
Of course, here is the Java code you requested:
```java
public static boolean setAttribute(String word, String natureWithFrequency)
{
CoreDictionary.Attribute attribute = CoreDictionary.Attribute.create(natureWithFrequency);
return setAttribute(word, attribute);
}
```
Hope this helps! | Create a Java method that does the following: "Sets the attribute for a CID .". |
Of course, here is the Java code you requested:
```java
public static Nature convertStringToNature(String name, LinkedHashSet<Nature> customNatureCollector)
{
Nature nature = Nature.fromString(name);
if (nature == null)
{
nature = Nature.create(name);
if (customNatur... | Create a Java method that does the following: "Convert string to a Nature object.". |
Of course, here is the Java code you requested:
```java
public Integer getLargestValueId()
{
if (emits == null || emits.size() == 0) return null;
return emits.iterator().next();
}
```
Hope this helps! | Create a Java method that does the following: "Gets the largest value id of the sequence.". |
Of course, here is the Java code you requested:
```java
private State nextState(Character character, boolean ignoreRootState)
{
State nextState = this.success.get(character);
if (!ignoreRootState && nextState == null && this.depth == 0)
{
nextState = this;
}
retu... | Create a Java method that does the following: "Get the next state for a given character.". |
Of course, here is the Java code you requested:
```java
public static IWord compile(IWord word)
{
String label = word.getLabel();
if ("nr".equals(label)) return new Word(word.getValue(), TAG_PEOPLE);
else if ("m".equals(label) || "mq".equals(label)) return new Word(word.getValue(), TAG_NUMB... | Create a Java method that does the following: "Compiles a CRS word into a CRS word.". |
Of course, here is the Java code you requested:
```java
public static List<List<IWord>> convert2CompatibleList(List<List<Word>> simpleSentenceList)
{
List<List<IWord>> compatibleList = new LinkedList<List<IWord>>();
for (List<Word> wordList : simpleSentenceList)
{
compatibleList... | Create a Java method that does the following: "Convert a list of lists of lists of words to a list of lists of lists of lists of lists of lists of words.". |
Of course, here is the Java code you requested:
```java
public static List<Term> segment(String text)
{
List<Term> termList = new LinkedList<Term>();
Matcher matcher = WEB_URL.matcher(text);
int begin = 0;
int end;
while (matcher.find())
{
end = matcher.s... | Create a Java method that does the following: "segment Method.". |
Of course, here is the Java code you requested:
```java
public static String get(String fromWord, String fromPos, String toWord, String toPos)
{
String dependency = get(fromWord + "@" + toWord);
if (dependency == null) dependency = get(fromWord + "@" + WordNatureWeightModelMaker.wrapTag(toPos));
... | Create a Java method that does the following: "Get the dependency from the two words.". |
Of course, here is the Java code you requested:
```java
public List<String> getKeywords(String document, int size)
{
return getKeywords(defaultSegment.seg(document), size);
}
```
Hope this helps! | Create a Java method that does the following: "Get the words of a document.". |
Of course, here is the Java code you requested:
```java
public void read(LineHandler handler, int size) throws Exception
{
File rootFile = new File(root);
File[] files;
if (rootFile.isDirectory())
{
files = rootFile.listFiles(new FileFilter()
{
... | Create a Java method that does the following: "Read a sequence of lines from the root directory.". |
Of course, here is the Java code you requested:
```java
public static List<String> parseOrExit(Object target, String[] args)
{
try
{
return parse(target, args);
}
catch (IllegalArgumentException e)
{
System.err.println(e.getMessage());
Arg... | Create a Java method that does the following: "Parses the target object or exits with an error if an exception occurs.". |
Of course, here is the Java code you requested:
```java
public static ValueCreator byStaticMethodInvocation(final Class<?> compatibleType, final String methodName)
{
return new ValueCreator()
{
public Object createValue(Class<?> type, String value)
{
Object v... | Create a Java method that does the following: "Create a ValueCreator that creates an object from a String value.". |
Of course, here is the Java code you requested:
```java
public static List<EnumItem<NR>> roleObserve(List<Vertex> wordSegResult)
{
List<EnumItem<NR>> tagList = new LinkedList<EnumItem<NR>>();
Iterator<Vertex> iterator = wordSegResult.iterator();
iterator.next();
tagList.add(new Enum... | Create a Java method that does the following: "roleObserve method.". |
Of course, here is the Java code you requested:
```java
public static List<NR> viterbiCompute(List<EnumItem<NR>> roleTagList)
{
return Viterbi.computeEnum(roleTagList, PersonDictionary.transformMatrixDictionary);
}
```
Hope this helps! | Create a Java method that does the following: "Compute the Viterbi formula.". |
Of course, here is the Java code you requested:
```java
public static List<NR> viterbiComputeSimply(List<EnumItem<NR>> roleTagList)
{
return Viterbi.computeEnumSimply(roleTagList, PersonDictionary.transformMatrixDictionary);
}
```
Hope this helps! | Create a Java method that does the following: "Compute the viterbi formula.". |
Of course, here is the Java code you requested:
```java
public static <V> LinkedList<ResultTerm<V>> segment(String text, AhoCorasickDoubleArrayTrie<V> trie)
{
return segment(text.toCharArray(), trie);
}
```
Hope this helps! | Create a Java method that does the following: "segment a string into a list of terms.". |
Of course, here is the Java code you requested:
```java
void resize(int size, byte value)
{
if (size > _capacity)
{
resizeBuf(size);
}
while (_size < size)
{
_buf[_size++] = value;
}
}
```
Hope this helps! | Create a Java method that does the following: "Resize the buffer to a given size.". |
Of course, here is the Java code you requested:
```java
private void resizeBuf(int size)
{
int capacity;
if (size >= _capacity * 2)
{
capacity = size;
}
else
{
capacity = 1;
while (capacity < size)
{
cap... | Create a Java method that does the following: "Resize the buffer to a given size.". |
Of course, here is the Java code you requested:
```java
public static boolean loadMainDictionary(String mainPath, String path[], DoubleArrayTrie<CoreDictionary.Attribute> dat, boolean isCache)
{
logger.info("自定义词典开始加载:" + mainPath);
if (loadDat(mainPath, dat)) return true;
TreeMap<String, C... | Create a Java method that does the following: "Load main dictionary.". |
Of course, here is the Java code you requested:
```java
public static boolean insert(String word, String natureWithFrequency)
{
if (word == null) return false;
if (HanLP.Config.Normalization) word = CharTable.convert(word);
CoreDictionary.Attribute att = natureWithFrequency == null ? new Co... | Create a Java method that does the following: "Insert a word into the database.". |
Of course, here is the Java code you requested:
```java
public static boolean loadDat(String path, String customDicPath[], DoubleArrayTrie<CoreDictionary.Attribute> dat)
{
try
{
if (isDicNeedUpdate(path, customDicPath))
{
return false;
}
... | Create a Java method that does the following: "Load the data from a file.". |
Of course, here is the Java code you requested:
```java
public static void remove(String key)
{
if (HanLP.Config.Normalization) key = CharTable.convert(key);
if (trie == null) return;
trie.remove(key);
}
```
Hope this helps! | Create a Java method that does the following: "Removes a key from the cache.". |
Of course, here is the Java code you requested:
```java
public static LinkedList<Map.Entry<String, CoreDictionary.Attribute>> commonPrefixSearch(char[] chars, int begin)
{
return trie.commonPrefixSearchWithValue(chars, begin);
}
```
Hope this helps! | Create a Java method that does the following: "Returns a list of entries that are common prefixes of the specified characters.". |
Of course, here is the Java code you requested:
```java
public static boolean contains(String key)
{
if (dat.exactMatchSearch(key) >= 0) return true;
return trie != null && trie.containsKey(key);
}
```
Hope this helps! | Create a Java method that does the following: "Check if a key is in the cache.". |
Of course, here is the Java code you requested:
```java
public static void parseText(char[] text, AhoCorasickDoubleArrayTrie.IHit<CoreDictionary.Attribute> processor)
{
if (trie != null)
{
trie.parseText(text, processor);
}
DoubleArrayTrie<CoreDictionary.Attribute>.Searc... | Create a Java method that does the following: "Parse text into a Aho Corasick Double Array Trie.". |
Of course, here is the Java code you requested:
```java
public static StringDictionary load(String path, String separator)
{
StringDictionary dictionary = new StringDictionary(separator);
if (dictionary.load(path)) return dictionary;
return null;
}
```
Hope this helps! | Create a Java method that does the following: "Load a StringDictionary from a file path.". |
Of course, here is the Java code you requested:
```java
public static StringDictionary combine(StringDictionary... args)
{
StringDictionary[] dictionaries = args.clone();
StringDictionary mainDictionary = dictionaries[0];
for (int i = 1; i < dictionaries.length; ++i)
{
m... | Create a Java method that does the following: "Combine the specified StringDictionary objects into one.". |
Of course, here is the Java code you requested:
```java
protected BaseFeatureData selectFeatures(IDataSet dataSet)
{
ChiSquareFeatureExtractor chiSquareFeatureExtractor = new ChiSquareFeatureExtractor();
logger.start("使用卡方检测选择特征中...");
//FeatureStats对象包含文档中所有特征及其统计信息
BaseFeatureDat... | Create a Java method that does the following: "Select features from the data set.". |
Of course, here is the Java code you requested:
```java
byte getKeyByte(int keyId, int byteId)
{
if (byteId >= _keys[keyId].length)
{
return 0;
}
return _keys[keyId][byteId];
}
```
Hope this helps! | Create a Java method that does the following: "Gets the byte value of a key.". |
Of course, here is the Java code you requested:
```java
public Matrix copy()
{
Matrix X = new Matrix(m, n);
double[][] C = X.getArray();
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
C[i][j] = A[i][j];
}
}
... | Create a Java method that does the following: "Copy the matrix.". |
Of course, here is the Java code you requested:
```java
public double[][] getArrayCopy()
{
double[][] C = new double[m][n];
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
C[i][j] = A[i][j];
}
}
return C;
}
... | Create a Java method that does the following: "Get an array of double values.". |
Of course, here is the Java code you requested:
```java
public double[] getRowPackedCopy()
{
double[] vals = new double[m * n];
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
vals[i * n + j] = A[i][j];
}
}
retu... | Create a Java method that does the following: "Get a row packed copy of the A matrix.". |
Of course, here is the Java code you requested:
```java
public Matrix getMatrix(int i0, int i1, int j0, int j1)
{
Matrix X = new Matrix(i1 - i0 + 1, j1 - j0 + 1);
double[][] B = X.getArray();
try
{
for (int i = i0; i <= i1; i++)
{
for (int j =... | Create a Java method that does the following: "Gets the matrix of the matrix of the submatrix.". |
Of course, here is the Java code you requested:
```java
public Matrix getMatrix(int[] r, int[] c)
{
Matrix X = new Matrix(r.length, c.length);
double[][] B = X.getArray();
try
{
for (int i = 0; i < r.length; i++)
{
for (int j = 0; j < c.length... | Create a Java method that does the following: "Get a matrix of the 2D matrix.". |
Of course, here is the Java code you requested:
```java
public Matrix getMatrix(int i0, int i1, int[] c)
{
Matrix X = new Matrix(i1 - i0 + 1, c.length);
double[][] B = X.getArray();
try
{
for (int i = i0; i <= i1; i++)
{
for (int j = 0; j < c.... | Create a Java method that does the following: "Get a matrix of the matrix of the submatrix.". |
Of course, here is the Java code you requested:
```java
public Matrix getMatrix(int[] r, int j0, int j1)
{
Matrix X = new Matrix(r.length, j1 - j0 + 1);
double[][] B = X.getArray();
try
{
for (int i = 0; i < r.length; i++)
{
for (int j = j0; j... | Create a Java method that does the following: "Get a matrix of the 2D matrix of the specified indices.". |
Of course, here is the Java code you requested:
```java
public void setMatrix(int i0, int i1, int[] c, Matrix X)
{
try
{
for (int i = i0; i <= i1; i++)
{
for (int j = 0; j < c.length; j++)
{
A[i][c[j]] = X.get(i - i0, j);
... | Create a Java method that does the following: "Sets the matrix of a single element.". |
Of course, here is the Java code you requested:
```java
public double norm1()
{
double f = 0;
for (int j = 0; j < n; j++)
{
double s = 0;
for (int i = 0; i < m; i++)
{
s += Math.abs(A[i][j]);
}
f = Math.max(f, s);
... | Create a Java method that does the following: "Norm1 function.". |
Of course, here is the Java code you requested:
```java
public Matrix times(Matrix B)
{
if (B.m != n)
{
throw new IllegalArgumentException("Matrix inner dimensions must agree.");
}
Matrix X = new Matrix(m, B.n);
double[][] C = X.getArray();
double[] Bcolj... | Create a Java method that does the following: "Returns the product of this matrix with B.". |
Of course, here is the Java code you requested:
```java
public static Matrix identity(int m, int n)
{
Matrix A = new Matrix(m, n);
double[][] X = A.getArray();
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
X[i][j] = (i == j ? 1.0... | Create a Java method that does the following: "Identity Matrix.". |
Of course, here is the Java code you requested:
```java
public void print(int w, int d)
{
print(new PrintWriter(System.out, true), w, d);
}
```
Hope this helps! | Create a Java method that does the following: "Print a sequence of words to System. out.". |
Of course, here is the Java code you requested:
```java
public void print(NumberFormat format, int width)
{
print(new PrintWriter(System.out, true), format, width);
}
```
Hope this helps! | Create a Java method that does the following: "Print the sequence of tokens to stdout.". |
Of course, here is the Java code you requested:
```java
public void print(PrintWriter output, NumberFormat format, int width)
{
output.println(); // start on new line.
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
String s = format.form... | Create a Java method that does the following: "Print a matrix from a buffered reader.". |
Of course, here is the Java code you requested:
```java
void refresh_stack_information()
{
int sz = stack.size();
if (0 == sz)
{
top0 = -1;
top1 = -1;
}
else if (1 == sz)
{
top0 = stack.get(sz - 1);
top1 = -1;
}... | Create a Java method that does the following: "refresh_stack_information This method is called to refresh the information in the application.". |
Of course, here is the Java code you requested:
```java
boolean shift(State source)
{
if (!source.can_shift())
{
return false;
}
this.copy(source);
stack.add(this.buffer);
refresh_stack_information();
++this.buffer;
this.last_action = Ac... | Create a Java method that does the following: "Shifts the state to the next entry in the sequence.". |
Of course, here is the Java code you requested:
```java
void get_possible_actions(State source,
List<Action> actions)
{
if (0 == L || -1 == R)
{
System.err.println("decoder: not initialized, please check if the root dependency relation is correct set by --r... | Create a Java method that does the following: "Get possible actions from the source state.". |
Of course, here is the Java code you requested:
```java
void transit(State source, Action act, State target)
{
int deprel = 0;
int[] deprel_inference = new int[]{deprel};
if (ActionUtils.is_shift(act))
{
target.shift(source);
}
else if (ActionUtils.is_lef... | Create a Java method that does the following: "Transit method.". |
Of course, here is the Java code you requested:
```java
int transform(Action act)
{
int deprel = 0;
int[] deprel_inference = new int[]{deprel};
if (ActionUtils.is_shift(act))
{
return 0;
}
else if (ActionUtils.is_left_arc(act, deprel_inference))
{... | Create a Java method that does the following: "Transform a Action into a C". |
Of course, here is the Java code you requested:
```java
Action transform(int act)
{
if (act == 0)
{
return ActionFactory.make_shift();
}
else if (act < 1 + L)
{
return ActionFactory.make_left_arc(act - 1);
}
else if (act < 1 + 2 * L)
... | Create a Java method that does the following: "Transform an int to an action.". |
Of course, here is the Java code you requested:
```java
public void add(int line, Vertex vertex)
{
for (Vertex oldVertex : vertexes[line])
{
// 保证唯一性
if (oldVertex.realWord.length() == vertex.realWord.length()) return;
}
vertexes[line].add(vertex);
++... | Create a Java method that does the following: "Add a new CRS element to a line of the CRS.". |
Of course, here is the Java code you requested:
```java
public void insert(int line, Vertex vertex, WordNet wordNetAll)
{
for (Vertex oldVertex : vertexes[line])
{
// 保证唯一性
if (oldVertex.realWord.length() == vertex.realWord.length()) return;
}
vertexes[line].... | Create a Java method that does the following: "Insert a single entry into the list.". |
Of course, here is the Java code you requested:
```java
public void addAll(List<Vertex> vertexList)
{
int i = 0;
for (Vertex vertex : vertexList)
{
add(i, vertex);
i += vertex.realWord.length();
}
}
```
Hope this helps! | Create a Java method that does the following: "Add all the CIS terms from a list of Vertices to this CIS.". |
Of course, here is the Java code you requested:
```java
public Vertex getFirst(int line)
{
Iterator<Vertex> iterator = vertexes[line].iterator();
if (iterator.hasNext()) return iterator.next();
return null;
}
```
Hope this helps! | Create a Java method that does the following: "Get the first CIDCTYPE in a line.". |
Of course, here is the Java code you requested:
```java
public Vertex get(int line, int length)
{
for (Vertex vertex : vertexes[line])
{
if (vertex.realWord.length() == length)
{
return vertex;
}
}
return null;
}
```
Hope thi... | Create a Java method that does the following: "Get a CCSCTYPE vertex from the line and length.". |
Of course, here is the Java code you requested:
```java
public void add(int line, List<AtomNode> atomSegment)
{
// 将原子部分存入m_segGraph
int offset = 0;
for (AtomNode atomNode : atomSegment)//Init the cost array
{
String sWord = atomNode.sWord;//init the word
Nat... | Create a Java method that does the following: "Add a list of AtomNodes to the array of Vertex objects.". |
Of course, here is the Java code you requested:
```java
public void clean()
{
for (List<Vertex> vertexList : vertexes)
{
for (Vertex vertex : vertexList)
{
vertex.from = null;
}
}
}
```
Hope this helps! | Create a Java method that does the following: "Clean up the RAID SEGMENTS.". |
Of course, here is the Java code you requested:
```java
private int searchFreeBase(SortedSet<Integer> children)
{
int minChild = children.first();
int maxChild = children.last();
int current = 0;
while (getCheck(current) != 0) // 循环链表回到了头,说明没有符合要求的“连续”区间
{
if (cu... | Create a Java method that does the following: "Search free base.". |
Of course, here is the Java code you requested:
```java
public List<String> prefixMatch(String prefix)
{
int curState = 1;
IntArrayList bytes = new IntArrayList(prefix.length() * 4);
for (int i = 0; i < prefix.length(); i++)
{
int codePoint = prefix.charAt(i);
... | Create a Java method that does the following: "Returns a list of strings that match the prefix.". |
Of course, here is the Java code you requested:
```java
public int[] findLongest(CharSequence query, int start)
{
if ((query == null) || (start >= query.length()))
{
return new int[]{0, -1};
}
int state = 1;
int maxLength = 0;
int lastVal = -1;
fo... | Create a Java method that does the following: "Find the longest value of the sequence in the sequence.". |
Of course, here is the Java code you requested:
```java
public List<int[]> commonPrefixSearch(String query, int start)
{
List<int[]> ret = new ArrayList<int[]>(5);
if ((query == null) || (start >= query.length()))
{
return ret;
}
int curState = 1;
for (in... | Create a Java method that does the following: "Common prefix search.". |
Of course, here is the Java code you requested:
```java
public int get(String key, int start)
{
assert key != null;
assert 0 <= start && start <= key.length();
int state = 1;
int[] ids = charMap.toIdList(key.substring(start));
state = transfer(state, ids);
if (state ... | Create a Java method that does the following: "Gets the value of a single attribute from a key.". |
Of course, here is the Java code you requested:
```java
public int getEmptySize()
{
int size = 0;
for (int i = 0; i < getBaseArraySize(); i++)
{
if (isEmpty(i))
{
++size;
}
}
return size;
}
```
Hope this helps! | Create a Java method that does the following: "Get the size of the empty array.". |
Of course, here is the Java code you requested:
```java
public void update(Instance instance)
{
int[] guessLabel = new int[instance.length()];
viterbiDecode(instance, guessLabel);
TagSet tagSet = featureMap.tagSet;
for (int i = 0; i < instance.length(); i++)
{
in... | Create a Java method that does the following: "Update the n - grams of a single instance.". |
Of course, here is the Java code you requested:
```java
public void combine(SimpleItem other)
{
for (Map.Entry<String, Integer> entry : other.labelMap.entrySet())
{
addLabel(entry.getKey(), entry.getValue());
}
}
```
Hope this helps! | Create a Java method that does the following: "Combine two URIs.". |
Of course, here is the Java code you requested:
```java
private void initNShortPath(Graph inGraph, int nValueKind)
{
graph = inGraph;
N = nValueKind;
// 获取顶点的数目
vertexCount = inGraph.vertexes.length;
fromArray = new CQueue[vertexCount - 1][]; // 不包含起点
weightArray ... | Create a Java method that does the following: "init N short path". |
Of course, here is the Java code you requested:
```java
private void calculate(Graph inGraph, int nValueKind)
{
initNShortPath(inGraph, nValueKind);
QueueElement tmpElement;
CQueue queWork = new CQueue();
double eWeight;
for (int nCurNode = 1; nCurNode < vertexCount; ++nCu... | Create a Java method that does the following: "Calculate the nValueKind of the nValueKind". |
Of course, here is the Java code you requested:
```java
private void enQueueCurNodeEdges(CQueue queWork, int nCurNode)
{
int nPreNode;
double eWeight;
List<EdgeFrom> pEdgeToList;
queWork.clear();
pEdgeToList = graph.getEdgeListTo(nCurNode);
// Get all the edgesFrom... | Create a Java method that does the following: "EnQueueCurNodeEdges Method.". |
Of course, here is the Java code you requested:
```java
public Integer[] getBestPath()
{
assert (vertexCount > 2);
Stack<Integer> stack = new Stack<Integer>();
int curNode = vertexCount - 1, curIndex = 0;
QueueElement element;
element = fromArray[curNode - 1][curIndex].Get... | Create a Java method that does the following: "Gets the best path of the sequence.". |
Of course, here is the Java code you requested:
```java
public void addEmit(String keyword)
{
if (this.emits == null)
{
this.emits = new TreeSet<String>();
}
this.emits.add(keyword);
}
```
Hope this helps! | Create a Java method that does the following: "Add an entity to the set of entity emission keywords.". |
Of course, here is the Java code you requested:
```java
public static void normalization(char[] charArray)
{
assert charArray != null;
for (int i = 0; i < charArray.length; i++)
{
charArray[i] = CONVERT[charArray[i]];
}
}
```
Hope this helps! | Create a Java method that does the following: "Normalize the char array to a single array of tokens.". |
Of course, here is the Java code you requested:
```java
void canonical()
{
hidden_layer_size = b1.rows();
nr_feature_types = W1.cols() / E.rows();
nr_classes = W2.rows();
embedding_size = E.rows();
}
```
Hope this helps! | Create a Java method that does the following: "Canonicalizes the CID .". |
Of course, here is the Java code you requested:
```java
public static int charType(String str)
{
if (str != null && str.length() > 0)
{
if (Predefine.CHINESE_NUMBERS.contains(str)) return CT_CNUM;
byte[] b;
try
{
b = str.getBytes("GBK"... | Create a Java method that does the following: "Returns the type of the string.". |
Of course, here is the Java code you requested:
```java
public static boolean isAllNonChinese(byte[] sString)
{
int nLen = sString.length;
int i = 0;
while (i < nLen)
{
if (getUnsigned(sString[i]) < 248 && getUnsigned(sString[i]) > 175)
return false;
... | Create a Java method that does the following: "isAllNonChinese returns true if the string is all non - Chinese.". |
Of course, here is the Java code you requested:
```java
public static boolean isAllNum(String str)
{
if (str == null)
return false;
int i = 0;
/** 判断开头是否是+-之类的符号 */
if ("±+-+-—".indexOf(str.charAt(0)) != -1)
i++;
/** 如果是全角的0123456789 字符* */
w... | Create a Java method that does the following: "is all num.". |
Of course, here is the Java code you requested:
```java
public static boolean isAllLetter(String text)
{
for (int i = 0; i < text.length(); ++i)
{
char c = text.charAt(i);
if ((((c < 'a' || c > 'z')) && ((c < 'A' || c > 'Z'))))
{
return false;
... | Create a Java method that does the following: "is all letters in text". |
Of course, here is the Java code you requested:
```java
public static boolean isAllChineseNum(String word)
{// 百分之五点六的人早上八点十八分起床
String chineseNum = "零○一二两三四五六七八九十廿百千万亿壹贰叁肆伍陆柒捌玖拾佰仟∶·./点";//
String prefix = "几数上第";
String surfix = "几多余来成倍";
boolean round = false;
if (word =... | Create a Java method that does the following: "isAllChineseNum returns true if the word is all chinese numbers". |
Of course, here is the Java code you requested:
```java
public static boolean isYearTime(String snum)
{
if (snum != null)
{
int len = snum.length();
String first = snum.substring(0, 1);
// 1992年, 98年,06年
if (isAllSingleByte(snum)
... | Create a Java method that does the following: "isYearTime Method returns true if the string snum is a year time.". |
Of course, here is the Java code you requested:
```java
public static boolean isInAggregate(String aggr, String str)
{
if (aggr != null && str != null)
{
str += "1";
for (int i = 0; i < str.length(); i++)
{
String s = str.substring(i, i + 1);
... | Create a Java method that does the following: "isInAggregate This method checks if the string is in the aggregate.". |
Of course, here is the Java code you requested:
```java
public static boolean isDBCCase(String str)
{
if (str != null)
{
str += " ";
for (int i = 0; i < str.length(); i++)
{
String s = str.substring(i, i + 1);
int length = 0;
... | Create a Java method that does the following: "isDBCCase This method is used to check if the string is a DB Case.". |
Of course, here is the Java code you requested:
```java
public static boolean isDelimiter(String str)
{
if (str != null && ("-".equals(str) || "-".equals(str)))
return true;
else
return false;
}
```
Hope this helps! | Create a Java method that does the following: "isDelimiter returns true if the string is a delimiter.". |
Of course, here is the Java code you requested:
```java
public static char[] long2char(long x)
{
char[] c = new char[4];
c[0] = (char) (x >> 48);
c[1] = (char) (x >> 32);
c[2] = (char) (x >> 16);
c[3] = (char) (x);
return c;
}
```
Hope this helps! | Create a Java method that does the following: "long2char This is a utility method to convert a long to a char array.". |
Of course, here is the Java code you requested:
```java
public static String long2String(long x)
{
char[] cArray = long2char(x);
StringBuilder sbResult = new StringBuilder(cArray.length);
for (char c : cArray)
{
sbResult.append(c);
}
return sbResult.toStr... | Create a Java method that does the following: "Convert a long to a String.". |
Of course, here is the Java code you requested:
```java
public static String exceptionToString(Exception e)
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
return sw.toString();
}
```
Hope this helps! | Create a Java method that does the following: "This method is used to get a string representation of an exception.". |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.