idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
12,800 | private Set < String > getSet ( boolean isInflected ) { Set < String > set = new HashSet < > ( ) ; for ( PatternToken patternToken : patternTokens ) { boolean acceptInflectionValue = isInflected ? patternToken . isInflected ( ) : ! patternToken . isInflected ( ) ; if ( acceptInflectionValue && ! patternToken . getNegat... | tokens that just refer to a word - no regex and optionally no inflection etc . |
12,801 | public Query buildRelaxedQuery ( AbstractPatternRule rule ) throws UnsupportedPatternRuleException { BooleanQuery . Builder builder = new BooleanQuery . Builder ( ) ; for ( PatternToken patternToken : rule . getPatternTokens ( ) ) { try { BooleanClause clause = makeQuery ( patternToken ) ; builder . add ( clause ) ; } ... | Iterate over all elements ignore those not supported add the other ones to a BooleanQuery . |
12,802 | List < Language > getLanguages ( ) throws IllegalAccessException , InstantiationException { List < Language > languages = new ArrayList < > ( ) ; for ( File ruleFile : ruleFiles ) { if ( ruleFile != null ) { Language newLanguage = LanguageBuilder . makeAdditionalLanguage ( ruleFile ) ; languages . add ( newLanguage ) ;... | Return all external Languages . |
12,803 | public List < RuleMatchApplication > applySuggestionsToOriginalText ( RuleMatch match ) { List < String > replacements = new ArrayList < > ( match . getSuggestedReplacements ( ) ) ; boolean hasRealReplacements = replacements . size ( ) > 0 ; if ( ! hasRealReplacements ) { String plainText = textMapping . getPlainText (... | Applies the suggestions from the rule to the original text . For rules that have no suggestion a pseudo - correction is generated that contains the same text as before . |
12,804 | String [ ] tokenize ( String sentence ) { TokenizerME tokenizer = new TokenizerME ( tokenModel ) ; String cleanString = sentence . replace ( '’', ' ''); return tokenizer . tokenize ( cleanString ) ; } | non - private for test cases |
12,805 | public void checkSimpleXMLString ( String xml ) throws IOException { Pattern pattern = Pattern . compile ( "(<error.*?/>)" , Pattern . DOTALL | Pattern . MULTILINE ) ; Matcher matcher = pattern . matcher ( xml ) ; int pos = 0 ; while ( matcher . find ( pos ) ) { String errorElement = matcher . group ( ) ; pos = matcher... | Check some limits of our simplified XML output . |
12,806 | public void validateXMLString ( String xml , String dtdFile , String docType ) throws SAXException , IOException , ParserConfigurationException { validateInternal ( xml , dtdFile , docType ) ; } | Validate XML with the given DTD . Throws exception on error . |
12,807 | public void validateWithDtd ( String filename , String dtdPath , String docType ) throws IOException { try ( InputStream xmlStream = this . getClass ( ) . getResourceAsStream ( filename ) ) { if ( xmlStream == null ) { throw new IOException ( "Not found in classpath: " + filename ) ; } try { String xml = StringTools . ... | Validate XML file in classpath with the given DTD . Throws exception on error . |
12,808 | public void activateNeuralNetworkRules ( File modelDir ) throws IOException { ResourceBundle messages = getMessageBundle ( language ) ; List < Rule > rules = language . getRelevantNeuralNetworkModels ( messages , modelDir ) ; userRules . addAll ( rules ) ; } | Activate rules that depend on pretrained neural network models . |
12,809 | public void activateLanguageModelRules ( File indexDir ) throws IOException { LanguageModel languageModel = language . getLanguageModel ( indexDir ) ; if ( languageModel != null ) { ResourceBundle messages = getMessageBundle ( language ) ; List < Rule > rules = language . getRelevantLanguageModelRules ( messages , lang... | Activate rules that depend on a language model . The language model currently consists of Lucene indexes with ngram occurrence counts . |
12,810 | public void activateWord2VecModelRules ( File indexDir ) throws IOException { Word2VecModel word2vecModel = language . getWord2VecModel ( indexDir ) ; if ( word2vecModel != null ) { ResourceBundle messages = getMessageBundle ( language ) ; List < Rule > rules = language . getRelevantWord2VecModelRules ( messages , word... | Activate rules that depend on a word2vec language model . |
12,811 | public RuleMatch adjustRuleMatchPos ( RuleMatch match , int charCount , int columnCount , int lineCount , String sentence , AnnotatedText annotatedText ) { int fromPos = match . getFromPos ( ) + charCount ; int toPos = match . getToPos ( ) + charCount ; if ( annotatedText != null ) { fromPos = annotatedText . getOrigin... | Change RuleMatch positions so they are relative to the complete text not just to the sentence . |
12,812 | static int countLineBreaks ( String s ) { int pos = - 1 ; int count = 0 ; while ( true ) { int nextPos = s . indexOf ( '\n' , pos + 1 ) ; if ( nextPos == - 1 ) { break ; } pos = nextPos ; count ++ ; } return count ; } | non - private only for test case |
12,813 | public Map < CategoryId , Category > getCategories ( ) { Map < CategoryId , Category > map = new HashMap < > ( ) ; for ( Rule rule : getAllRules ( ) ) { map . put ( rule . getCategory ( ) . getId ( ) , rule . getCategory ( ) ) ; } return map ; } | Get all rule categories for the current language . |
12,814 | public List < Rule > getAllActiveOfficeRules ( ) { List < Rule > rules = new ArrayList < > ( ) ; List < Rule > rulesActive = new ArrayList < > ( ) ; rules . addAll ( builtinRules ) ; rules . addAll ( userRules ) ; for ( Rule rule : rules ) { if ( ! ignoreRule ( rule ) && ! rule . isOfficeDefaultOff ( ) ) { rulesActive ... | Works like getAllActiveRules but overrides defaults by officeefaults |
12,815 | private boolean matchPreservesCase ( List < Match > suggestionMatches , String msg ) { if ( suggestionMatches != null && ! suggestionMatches . isEmpty ( ) ) { int sugStart = msg . indexOf ( SUGGESTION_START_TAG ) + SUGGESTION_START_TAG . length ( ) ; for ( Match sMatch : suggestionMatches ) { if ( ! sMatch . isInMessag... | Checks if the suggestion starts with a match that is supposed to preserve case . If it does not perform the default conversion to uppercase . |
12,816 | private int translateElementNo ( int i ) { if ( ! useList || i < 0 ) { return i ; } int j = 0 ; PatternRule rule = ( PatternRule ) this . rule ; for ( int k = 0 ; k < i ; k ++ ) { j += rule . getElementNo ( ) . get ( k ) ; } return j ; } | Gets the index of the element indexed by i adding any offsets because of the phrases in the rule . |
12,817 | private static String [ ] combineLists ( String [ ] [ ] input , String [ ] output , int r , Language lang ) { List < String > outputList = new ArrayList < > ( ) ; if ( r == input . length ) { StringBuilder sb = new StringBuilder ( ) ; for ( int k = 0 ; k < output . length ; k ++ ) { sb . append ( output [ k ] ) ; if ( ... | Creates a Cartesian product of the arrays stored in the input array . |
12,818 | private Language getLanguageForLocalizedName ( String languageName ) { for ( Language element : Languages . get ( ) ) { if ( languageName . equals ( element . getTranslatedName ( messages ) ) ) { return element ; } } return null ; } | Get the Language object for the given localized language name . |
12,819 | private XLinguServiceManager GetLinguSvcMgr ( XComponentContext xContext ) { try { XMultiComponentFactory xMCF = UnoRuntime . queryInterface ( XMultiComponentFactory . class , xContext . getServiceManager ( ) ) ; if ( xMCF == null ) { printText ( "XMultiComponentFactory == null" ) ; return null ; } XPropertySet props =... | Get the LinguServiceManager to be used for example to access spell checker thesaurus and hyphenator |
12,820 | private XThesaurus GetThesaurus ( XLinguServiceManager mxLinguSvcMgr ) { try { if ( mxLinguSvcMgr != null ) { return mxLinguSvcMgr . getThesaurus ( ) ; } } catch ( Throwable t ) { printMessage ( t ) ; } return null ; } | Get the Thesaurus to be used . |
12,821 | private XHyphenator GetHyphenator ( XLinguServiceManager mxLinguSvcMgr ) { try { if ( mxLinguSvcMgr != null ) { return mxLinguSvcMgr . getHyphenator ( ) ; } } catch ( Throwable t ) { printMessage ( t ) ; } return null ; } | Get the Hyphenator to be used . |
12,822 | private XSpellChecker GetSpellChecker ( XLinguServiceManager mxLinguSvcMgr ) { try { if ( mxLinguSvcMgr != null ) { return mxLinguSvcMgr . getSpellChecker ( ) ; } } catch ( Throwable t ) { printMessage ( t ) ; } return null ; } | Get the SpellChecker to be used . |
12,823 | public List < String > getSynonyms ( String word , Language lang ) { return getSynonyms ( word , getLocale ( lang ) ) ; } | Get all synonyms of a word as list of strings . |
12,824 | public boolean isCorrectSpell ( String word , Language lang ) { return isCorrectSpell ( word , getLocale ( lang ) ) ; } | Returns true if the spell check is positive |
12,825 | public int getNumberOfSyllables ( String word , Language lang ) { return getNumberOfSyllables ( word , getLocale ( lang ) ) ; } | Returns the number of syllable of a word Returns - 1 if the word was not found or anything goes wrong |
12,826 | public boolean isMisspelled ( String word ) { for ( MorfologikSpeller speller : spellers ) { if ( ! speller . isMisspelled ( word ) ) { return false ; } } return true ; } | Accept the word if at least one of the dictionaries accepts it as not misspelled . |
12,827 | public final void setToken ( AnalyzedTokenReadings [ ] tokens , int index , int next ) { int idx = index ; if ( index >= tokens . length ) { idx = tokens . length - 1 ; } setToken ( tokens [ idx ] ) ; IncludeRange includeSkipped = match . getIncludeSkipped ( ) ; if ( next > 1 && includeSkipped != IncludeRange . NONE ) ... | Sets the token to be formatted etc . and includes the support for including the skipped tokens . |
12,828 | public final String getTargetPosTag ( ) { String targetPosTag = match . getPosTag ( ) ; List < String > posTags = new ArrayList < > ( ) ; Pattern pPosRegexMatch = match . getPosRegexMatch ( ) ; String posTagReplace = match . getPosTagReplace ( ) ; if ( match . isStaticLemma ( ) ) { for ( AnalyzedToken analyzedToken : m... | on the other hand many POS tags = too many suggestions? |
12,829 | final String toTokenString ( ) throws IOException { String [ ] stringToFormat = toFinalString ( null ) ; return String . join ( "|" , Arrays . asList ( stringToFormat ) ) ; } | Method for getting the formatted match as a single string . In case of multiple matches it joins them using a regular expression operator | . |
12,830 | ProofreadingResult getCheckResults ( String paraText , Locale locale , ProofreadingResult paRes , int [ ] footnotePositions , boolean isParallelThread , JLanguageTool langTool ) { try { SingleProofreadingError [ ] sErrors = null ; paraNum = getParaPos ( paraText , isParallelThread ) ; if ( numParasToCheck != 0 && paraN... | get the result for a check of a single document |
12,831 | void setConfigValues ( Configuration config ) { this . config = config ; numParasToCheck = config . getNumParasToCheck ( ) ; defaultParaCheck = numParasToCheck * PARA_CHECK_FACTOR ; doResetCheck = config . isResetCheck ( ) ; } | set values set by configuration dialog |
12,832 | void optimizeReset ( ) { FlatParagraphTools flatPara = new FlatParagraphTools ( xContext ) ; flatPara . markFlatParasAsChecked ( resetFrom + divNum , resetTo + divNum , isChecked ) ; resetCheck = false ; } | Reset only changed paragraphs |
12,833 | public void loadIsChecked ( ) { FlatParagraphTools flatPara = new FlatParagraphTools ( xContext ) ; isChecked = flatPara . isChecked ( ) ; if ( debugMode > 0 ) { int nChecked = 0 ; for ( boolean bChecked : isChecked ) { if ( bChecked ) { nChecked ++ ; } } MessageHandler . printToLogFile ( "Checked parapraphs: docID: " ... | load checked status of all paragraphs |
12,834 | private String getDocAsString ( int numCurPara ) { if ( numCurPara < 0 || allParas == null || allParas . size ( ) < numCurPara - 1 ) { return "" ; } int startPos ; int endPos ; if ( numParasToCheck < 1 ) { startPos = 0 ; endPos = allParas . size ( ) ; } else { startPos = numCurPara - numParasToCheck ; if ( textIsChange... | Gives Back the full Text as String |
12,835 | private int getStartOfParagraph ( int nPara , int checkedPara ) { if ( allParas != null && nPara >= 0 && nPara < allParas . size ( ) ) { int startPos ; if ( numParasToCheck < 1 ) { startPos = 0 ; } else { startPos = checkedPara - numParasToCheck ; if ( textIsChanged && doResetCheck ) { startPos -= numParasToCheck ; } i... | Gives Back the StartPosition of Paragraph |
12,836 | public Map < String , List < String > > loadWords ( String path ) { InputStream stream = JLanguageTool . getDataBroker ( ) . getFromRulesDirAsStream ( path ) ; Map < String , List < String > > map = new HashMap < > ( ) ; try ( Scanner scanner = new Scanner ( stream , "utf-8" ) ) { while ( scanner . hasNextLine ( ) ) { ... | Load replacement rules from a utf - 8 file in the classpath . |
12,837 | private boolean matchLemmaRegexp ( AnalyzedTokenReadings aToken , Pattern pattern ) { boolean matches = false ; for ( AnalyzedToken analyzedToken : aToken ) { final String posTag = analyzedToken . getLemma ( ) ; if ( posTag != null ) { final Matcher m = pattern . matcher ( posTag ) ; if ( m . matches ( ) ) { matches = ... | Match lemma with regular expression |
12,838 | private boolean matchLemmaList ( AnalyzedTokenReadings aToken , List < String > list ) { boolean matches = false ; for ( AnalyzedToken analyzedToken : aToken ) { if ( list . contains ( analyzedToken . getLemma ( ) ) ) { matches = true ; break ; } } return matches ; } | Match lemma with String list |
12,839 | private boolean matchRegexp ( String s , Pattern pattern ) { final Matcher m = pattern . matcher ( s ) ; return m . matches ( ) ; } | Match String with regular expression |
12,840 | private boolean isTherePronoun ( final AnalyzedTokenReadings [ ] tokens , int i , Pattern lemma , Pattern postag ) { int j = 1 ; boolean keepCounting = true ; while ( i - j > 0 && keepCounting ) { if ( matchPostagRegexp ( tokens [ i - j ] , postag ) && matchLemmaRegexp ( tokens [ i - j ] , lemma ) ) return true ; keepC... | Checks if there is a desired pronoun near the verb |
12,841 | public void stop ( ) { if ( httpHandler != null ) { httpHandler . shutdown ( ) ; } if ( server != null ) { ServerTools . print ( "Stopping server..." ) ; server . stop ( 5 ) ; isRunning = false ; ServerTools . print ( "Server stopped" ) ; } } | Stop the server . Once stopped a server cannot be used again . |
12,842 | private static List < ContextWords > loadContextWords ( String path ) { List < ContextWords > set = new ArrayList < > ( ) ; InputStream stream = JLanguageTool . getDataBroker ( ) . getFromRulesDirAsStream ( path ) ; try ( Scanner scanner = new Scanner ( stream , "utf-8" ) ) { while ( scanner . hasNextLine ( ) ) { Strin... | Load words contexts and explanations . |
12,843 | private String getFilteredText ( String filename , String encoding , boolean xmlFiltering ) throws IOException { if ( options . isVerbose ( ) ) { lt . setOutput ( System . err ) ; } try ( InputStreamReader reader = getInputStreamReader ( filename , encoding ) ) { String fileContents = readerToString ( reader ) ; if ( x... | Loads filename and filters out XML . Note that the XML filtering can lead to incorrect positions in the list of matching rules . |
12,844 | public final ProofreadingResult doProofreading ( String docID , String paraText , Locale locale , int startOfSentencePos , int nSuggestedBehindEndOfSentencePosition , PropertyValue [ ] propertyValues ) { ProofreadingResult paRes = new ProofreadingResult ( ) ; paRes . nStartOfSentencePosition = startOfSentencePos ; paRe... | Runs the grammar checker on paragraph text . |
12,845 | void endCompoundEdit ( ) { if ( ! compoundMode ) { throw new RuntimeException ( "not in compound mode" ) ; } ce . end ( ) ; undoManager . addEdit ( ce ) ; ce = null ; compoundMode = false ; } | Notify manager to stop merging undoable edits . |
12,846 | public static synchronized Hunspell getInstance ( String libDir ) throws UnsatisfiedLinkError , UnsupportedOperationException { if ( hunspell != null ) { return hunspell ; } hunspell = new Hunspell ( libDir ) ; return hunspell ; } | The instance of the HunspellManager looks for the native lib in the directory specified . |
12,847 | public static String libName ( ) throws UnsupportedOperationException { String os = System . getProperty ( "os.name" ) . toLowerCase ( ) ; if ( os . startsWith ( "windows" ) ) { return libNameBare ( ) + ".dll" ; } else if ( os . startsWith ( "mac os x" ) ) { return libNameBare ( ) + ".jnilib" ; } else { return "lib" + ... | Calculate the filename of the native hunspell lib . The files have completely different names to allow them to live in the same directory and avoid confusion . |
12,848 | public Dictionary getDictionary ( String baseFileName ) throws IOException { if ( map . containsKey ( baseFileName ) ) { return map . get ( baseFileName ) ; } else { Dictionary d = new Dictionary ( baseFileName ) ; map . put ( baseFileName , d ) ; return d ; } } | Gets an instance of the dictionary . |
12,849 | protected String formatPosTag ( String posTag , int position , int multiwordLength ) { return tagFormat != null ? String . format ( tagFormat , posTag ) : posTag ; } | Override this method if you want format POS tag differently |
12,850 | private void addTokens ( List < AnalyzedToken > taggedTokens , List < AnalyzedToken > l ) { if ( taggedTokens != null ) { for ( AnalyzedToken at : taggedTokens ) { l . add ( at ) ; } } } | please do not make protected this breaks other languages |
12,851 | static File openFileDialog ( Frame frame , FileFilter fileFilter , File initialDir ) { return openFileDialog ( frame , fileFilter , initialDir , JFileChooser . FILES_ONLY ) ; } | Show a file chooser dialog in a specified directory |
12,852 | static File openDirectoryDialog ( Frame frame , File initialDir ) { return openFileDialog ( frame , null , initialDir , JFileChooser . DIRECTORIES_ONLY ) ; } | Show a directory chooser dialog starting with a specified directory |
12,853 | public static char getMnemonic ( String label ) { int mnemonicPos = label . indexOf ( '&' ) ; while ( mnemonicPos != - 1 && mnemonicPos == label . indexOf ( "&&" ) && mnemonicPos < label . length ( ) ) { mnemonicPos = label . indexOf ( '&' , mnemonicPos + 2 ) ; } if ( mnemonicPos == - 1 || mnemonicPos == label . length... | Returns mnemonic of a UI element . |
12,854 | public static void centerDialog ( JDialog dialog ) { Dimension screenSize = Toolkit . getDefaultToolkit ( ) . getScreenSize ( ) ; Dimension frameSize = dialog . getSize ( ) ; dialog . setLocation ( screenSize . width / 2 - frameSize . width / 2 , screenSize . height / 2 - frameSize . height / 2 ) ; dialog . setLocation... | Set dialog location to the center of the screen |
12,855 | static ResultSet executeStatement ( SQL sql ) throws SQLException { try ( SqlSession session = sqlSessionFactory . openSession ( true ) ) { try ( Connection conn = session . getConnection ( ) ) { try ( Statement stmt = conn . createStatement ( ) ) { return stmt . executeQuery ( sql . toString ( ) ) ; } } } } | For unit tests only |
12,856 | public boolean isExceptionMatched ( AnalyzedToken token ) { if ( exceptionSet ) { for ( PatternToken testException : exceptionList ) { if ( ! testException . exceptionValidNext ) { if ( testException . isMatched ( token ) ) { return true ; } } } } return false ; } | Checks whether an exception matches . |
12,857 | public boolean isAndExceptionGroupMatched ( AnalyzedToken token ) { for ( PatternToken testAndGroup : andGroupList ) { if ( testAndGroup . isExceptionMatched ( token ) ) { return true ; } } return false ; } | Enables testing multiple conditions specified by multiple element exceptions . Works as logical AND operator . |
12,858 | public boolean isSentenceStart ( ) { return posToken != null && JLanguageTool . SENTENCE_START_TAGNAME . equals ( posToken . posTag ) && ! posToken . negation ; } | Checks if the token is a sentence start . |
12,859 | private boolean isPosTokenMatched ( AnalyzedToken token ) { if ( posToken == null || posToken . posTag == null ) { return true ; } if ( token . getPOSTag ( ) == null ) { return posToken . posUnknown && token . hasNoTag ( ) ; } boolean match ; if ( posToken . regExp ) { Matcher mPos = posToken . posPattern . matcher ( t... | Tests if part of speech matches a given string . Special value UNKNOWN_TAG matches null POS tags . |
12,860 | private boolean isStringTokenMatched ( AnalyzedToken token ) { String testToken = getTestToken ( token ) ; if ( stringRegExp ) { Matcher m = pattern . matcher ( new InterruptibleCharSequence ( testToken ) ) ; return m . matches ( ) ; } if ( caseSensitive ) { return stringToken . equals ( testToken ) ; } return stringTo... | Tests whether the string token element matches a given token . |
12,861 | public void setExceptionSpaceBefore ( boolean isWhite ) { if ( previousExceptionList != null && exceptionValidPrevious ) { previousExceptionList . get ( previousExceptionList . size ( ) - 1 ) . setWhitespaceBefore ( isWhite ) ; } else { if ( exceptionList != null ) { exceptionList . get ( exceptionList . size ( ) - 1 )... | Sets the attribute on the exception that determines matching of patterns that depends on whether there was a space before the token matching the exception or not . The same procedure is used for tokens that are valid for previous or current tokens . |
12,862 | public final AnalyzedSentence replace ( AnalyzedSentence sentence ) throws IOException { DisambiguationPatternRuleReplacer replacer = new DisambiguationPatternRuleReplacer ( this ) ; return replacer . replace ( sentence ) ; } | Performs disambiguation on the source sentence . |
12,863 | private static boolean isRemovableWhite ( AnalyzedTokenReadings token ) { return ( token . isWhitespace ( ) || StringTools . isNonBreakingWhitespace ( token . getToken ( ) ) ) && ! token . isLinebreak ( ) && ! token . getToken ( ) . equals ( "\t" ) && ! token . getToken ( ) . equals ( "\u200B" ) ; } | Removable white space are not linebreaks tabs functions or footnotes |
12,864 | private String getRomanNumber ( int num ) { String roman = "" ; int N = num ; for ( int i = 0 ; i < numbers . length ; i ++ ) { while ( N >= numbers [ i ] ) { roman += letters [ i ] ; N -= numbers [ i ] ; } } return roman ; } | Gets the Roman notation for numbers . |
12,865 | void setSelectedFont ( Font font ) { this . selectedFont = font ; fontNameList . setSelectedValue ( font . getFamily ( ) , true ) ; fontStyleList . setSelectedValue ( getStyle ( font ) , true ) ; fontSizeList . setSelectedValue ( font . getSize ( ) , true ) ; } | Sets the current font of the font chooser to the specified font . |
12,866 | public List < String > getSynonyms ( AnalyzedTokenReadings token ) { List < String > synonyms = new ArrayList < String > ( ) ; if ( linguServices == null || token == null ) { return synonyms ; } List < AnalyzedToken > readings = token . getReadings ( ) ; for ( AnalyzedToken reading : readings ) { String lemma = reading... | get synonyms for a repeated word |
12,867 | protected void lookup ( String lemma , String posTag , List < String > results ) { synchronized ( this ) { List < WordData > wordForms = stemmer . lookup ( lemma + "|" + posTag ) ; for ( WordData wd : wordForms ) { results . add ( wd . getStem ( ) . toString ( ) ) ; } } } | Lookup the inflected forms of a lemma defined by a part - of - speech tag . |
12,868 | Configuration copy ( Configuration configuration ) { Configuration copy = new Configuration ( ) ; copy . restoreState ( configuration ) ; return copy ; } | Returns a copy of the given configuration . |
12,869 | void restoreState ( Configuration configuration ) { this . configFile = configuration . configFile ; this . language = configuration . language ; this . motherTongue = configuration . motherTongue ; this . ngramDirectory = configuration . ngramDirectory ; this . word2vecDirectory = configuration . word2vecDirectory ; t... | Restore the state of this object from configuration . |
12,870 | public boolean hasPosTag ( String posTag ) { boolean found = false ; for ( AnalyzedToken reading : anTokReadings ) { if ( reading . getPOSTag ( ) != null ) { found = posTag . equals ( reading . getPOSTag ( ) ) ; if ( found ) { break ; } } } return found ; } | Checks if the token has a particular POS tag . |
12,871 | public boolean hasLemma ( String lemma ) { boolean found = false ; for ( AnalyzedToken reading : anTokReadings ) { if ( reading . getLemma ( ) != null ) { found = lemma . equals ( reading . getLemma ( ) ) ; if ( found ) { break ; } } } return found ; } | Checks if one of the token s readings has a particular lemma . |
12,872 | public boolean hasAnyLemma ( String ... lemmas ) { boolean found = false ; for ( String lemma : lemmas ) { for ( AnalyzedToken reading : anTokReadings ) { if ( reading . getLemma ( ) != null ) { found = lemma . equals ( reading . getLemma ( ) ) ; if ( found ) { return found ; } } } } return found ; } | Checks if one of the token s readings has one of the given lemmas |
12,873 | public boolean hasPartialPosTag ( String posTag ) { boolean found = false ; for ( AnalyzedToken reading : anTokReadings ) { if ( reading . getPOSTag ( ) != null ) { found = reading . getPOSTag ( ) . contains ( posTag ) ; if ( found ) { break ; } } } return found ; } | Checks if the token has a particular POS tag where only a part of the given POS tag needs to match . |
12,874 | public boolean hasPosTagStartingWith ( String posTag ) { boolean found = false ; for ( AnalyzedToken reading : anTokReadings ) { if ( reading . getPOSTag ( ) != null ) { found = reading . getPOSTag ( ) . startsWith ( posTag ) ; if ( found ) { break ; } } } return found ; } | Checks if the token has a POS tag starting with the given string . |
12,875 | public boolean matchesPosTagRegex ( String posTagRegex ) { Pattern pattern = Pattern . compile ( posTagRegex ) ; boolean found = false ; for ( AnalyzedToken reading : anTokReadings ) { if ( reading . getPOSTag ( ) != null ) { found = pattern . matcher ( reading . getPOSTag ( ) ) . matches ( ) ; if ( found ) { break ; }... | Checks if at least one of the readings matches a given POS tag regex . |
12,876 | public void addReading ( AnalyzedToken token ) { List < AnalyzedToken > l = new ArrayList < > ( Arrays . asList ( anTokReadings ) . subList ( 0 , anTokReadings . length - 1 ) ) ; if ( anTokReadings [ anTokReadings . length - 1 ] . getPOSTag ( ) != null ) { l . add ( anTokReadings [ anTokReadings . length - 1 ] ) ; } to... | Add a new reading . |
12,877 | public void leaveReading ( AnalyzedToken token ) { List < AnalyzedToken > l = new ArrayList < > ( ) ; AnalyzedToken tmpTok = new AnalyzedToken ( token . getToken ( ) , token . getPOSTag ( ) , token . getLemma ( ) ) ; tmpTok . setWhitespaceBefore ( isWhitespaceBefore ) ; for ( AnalyzedToken anTokReading : anTokReadings ... | Removes all readings but the one that matches the token given . |
12,878 | public void setParagraphEnd ( ) { if ( ! isParagraphEnd ( ) ) { AnalyzedToken paragraphEnd = new AnalyzedToken ( getToken ( ) , PARAGRAPH_END_TAGNAME , getAnalyzedToken ( 0 ) . getLemma ( ) ) ; addReading ( paragraphEnd ) ; } } | Add a reading with a paragraph end token unless this is already a paragraph end . |
12,879 | public void setSentEnd ( ) { if ( ! isSentenceEnd ( ) ) { AnalyzedToken sentenceEnd = new AnalyzedToken ( getToken ( ) , SENTENCE_END_TAGNAME , getAnalyzedToken ( 0 ) . getLemma ( ) ) ; addReading ( sentenceEnd ) ; } } | Add a SENT_END tag . |
12,880 | private boolean areLemmasSame ( ) { String previousLemma = anTokReadings [ 0 ] . getLemma ( ) ; if ( previousLemma == null ) { for ( AnalyzedToken element : anTokReadings ) { if ( element . getLemma ( ) != null ) { return false ; } } return true ; } for ( AnalyzedToken element : anTokReadings ) { if ( ! previousLemma .... | Used to configure the internal variable for lemma equality . |
12,881 | protected void addUnit ( String pattern , Unit base , String symbol , double factor , boolean metric ) { Unit unit = base . multiply ( factor ) ; unitPatterns . put ( Pattern . compile ( "\\b" + NUMBER_REGEX + "\\s{0," + WHITESPACE_LIMIT + "}" + pattern + "\\b" ) , unit ) ; unitSymbols . putIfAbsent ( unit , new ArrayL... | Associate a notation with a given unit . |
12,882 | private List < String > getFormattedConversions ( List < Map . Entry < Unit , Double > > conversions ) { List < String > formatted = new ArrayList < > ( ) ; for ( Map . Entry < Unit , Double > equivalent : conversions ) { Unit metric = equivalent . getKey ( ) ; double converted = equivalent . getValue ( ) ; long rounde... | Adds different formatted variants of the given conversions up to MAX_SUGGESTIONS . |
12,883 | public static XDesktop getCurrentDesktop ( XComponentContext xContext ) { try { if ( xContext == null ) { return null ; } XMultiComponentFactory xMCF = UnoRuntime . queryInterface ( XMultiComponentFactory . class , xContext . getServiceManager ( ) ) ; if ( xMCF == null ) { return null ; } Object desktop = xMCF . create... | Returns the current XDesktop Returns null if it fails |
12,884 | public static XComponent getCurrentComponent ( XComponentContext xContext ) { try { XDesktop xdesktop = getCurrentDesktop ( xContext ) ; if ( xdesktop == null ) { return null ; } else return xdesktop . getCurrentComponent ( ) ; } catch ( Throwable t ) { MessageHandler . printException ( t ) ; return null ; } } | Returns the current XComponent Returns null if it fails |
12,885 | public Pair < List < SuggestedReplacement > , SortedMap < String , Float > > computeFeatures ( List < String > suggestions , String word , AnalyzedSentence sentence , int startPos ) { if ( suggestions . isEmpty ( ) ) { return Pair . of ( Collections . emptyList ( ) , Collections . emptySortedMap ( ) ) ; } if ( topN <= ... | compute features for training or prediction of a ranking model for suggestions |
12,886 | public static boolean ignoreForIncompleteSentences ( String ruleId , Language lang ) { return rules . contains ( new Key ( lang . getShortCode ( ) , ruleId ) ) ; } | Whether this rule should be ignored when the sentence isn t finished yet . |
12,887 | public static String i18n ( ResourceBundle messages , String key , Object ... messageArguments ) { MessageFormat formatter = new MessageFormat ( "" ) ; formatter . applyPattern ( messages . getString ( key ) . replaceAll ( "'" , "''" ) ) ; return formatter . format ( messageArguments ) ; } | Translate a text string based on our i18n files . |
12,888 | private static List < BitextRule > getAllBuiltinBitextRules ( Language language , ResourceBundle messages ) { List < BitextRule > rules = new ArrayList < > ( ) ; try { List < Class < ? extends BitextRule > > classes = BitextRule . getRelevantRules ( ) ; for ( Class class1 : classes ) { Constructor [ ] constructors = cl... | Use reflection to add bitext rules . |
12,889 | public static void selectRules ( JLanguageTool lt , List < String > disabledRuleIds , List < String > enabledRuleIds , boolean useEnabledOnly ) { Set < String > disabledRuleIdsSet = new HashSet < > ( ) ; disabledRuleIdsSet . addAll ( disabledRuleIds ) ; Set < String > enabledRuleIdsSet = new HashSet < > ( ) ; enabledRu... | Enable and disable rules of the given LanguageTool instance . |
12,890 | public static List < BitextRule > selectBitextRules ( List < BitextRule > bRules , List < String > disabledRules , List < String > enabledRules , boolean useEnabledOnly ) { List < BitextRule > newBRules = new ArrayList < > ( bRules . size ( ) ) ; newBRules . addAll ( bRules ) ; List < BitextRule > rulesToDisable = new ... | Enable and disable bitext rules . |
12,891 | private String getNumAgreedPosTag ( String leftPosTag , String rightPosTag , boolean leftNv ) { String agreedPosTag = null ; if ( leftPosTag . contains ( ":p:" ) && SING_REGEX_F . matcher ( rightPosTag ) . find ( ) || SING_REGEX_F . matcher ( leftPosTag ) . find ( ) && rightPosTag . contains ( ":p:" ) ) { String leftCo... | right part is numr |
12,892 | public PatternTokenBuilder csToken ( String token ) { this . token = Objects . requireNonNull ( token ) ; caseSensitive = true ; return this ; } | Add a case - sensitive token . |
12,893 | static UserLimits getLimitsFromToken ( HTTPServerConfig config , String jwtToken ) { Objects . requireNonNull ( jwtToken ) ; try { String secretKey = config . getSecretTokenKey ( ) ; if ( secretKey == null ) { throw new RuntimeException ( "You specified a 'token' parameter but this server doesn't accept tokens" ) ; } A... | Get limits from the JWT key itself no database access needed . |
12,894 | public static UserLimits getLimitsByApiKey ( HTTPServerConfig config , String username , String apiKey ) { DatabaseAccess db = DatabaseAccess . getInstance ( ) ; Long id = db . getUserId ( username , apiKey ) ; return new UserLimits ( config . maxTextLengthWithApiKey , config . maxCheckTimeWithApiKeyMillis , id ) ; } | Get limits from the api key itself database access is needed . |
12,895 | public Language getLanguage ( ) { XComponent xComponent = OfficeTools . getCurrentComponent ( xContext ) ; Locale charLocale ; XPropertySet xCursorProps ; try { XModel model = UnoRuntime . queryInterface ( XModel . class , xComponent ) ; if ( model == null ) { return Languages . getLanguageForShortCode ( "en-US" ) ; } ... | Checks the language under the cursor . Used for opening the configuration dialog . |
12,896 | private void setConfigValues ( Configuration config , JLanguageTool langTool ) { this . config = config ; this . langTool = langTool ; this . noMultiReset = config . isNoMultiReset ( ) ; for ( SingleDocument document : documents ) { document . setConfigValues ( config ) ; } } | Set config Values for all documents |
12,897 | private int getNumDoc ( String docID ) { if ( goneContext != null ) { removeDoc ( docID ) ; } for ( int i = 0 ; i < documents . size ( ) ; i ++ ) { if ( documents . get ( i ) . getDocID ( ) . equals ( docID ) ) { if ( ! testMode && documents . get ( i ) . getXComponent ( ) == null ) { XComponent xComponent = OfficeTool... | Get or Create a Number from docID Return - 1 if failed |
12,898 | private void removeDoc ( String docID ) { int rmNum = - 1 ; int docNum = - 1 ; for ( int i = 0 ; i < documents . size ( ) ; i ++ ) { XComponent xComponent = documents . get ( i ) . getXComponent ( ) ; if ( xComponent != null && xComponent . equals ( goneContext ) ) { rmNum = i ; break ; } } if ( rmNum < 0 ) { MessageHa... | Delete a document number and all internal space |
12,899 | public boolean setMenuTextForSwitchOff ( XComponentContext xContext ) { boolean ret = true ; XMenuBar menubar = OfficeTools . getMenuBar ( xContext ) ; if ( menubar == null ) { MessageHandler . printToLogFile ( "Menubar is null" ) ; return ret ; } XPopupMenu toolsMenu = null ; XPopupMenu ltMenu = null ; short toolsId =... | Set or remove a check mark to the LT menu item Switch Off return true if text should be rechecked |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.