INNER CODE UNIT · Python

candidate_generator

R1j1t/contextualSpellCheck · contextualSpellCheck/contextualSpellCheck.py:268

    def candidate_generator(self, doc, misspellings, top_n=10):
        """Returns Candidates for misspell words

        This function is responsible for generating candidate list for misspell
        using BERT. The misspell is masked with a token (eg [MASK]) and the
        model tries to predict `n` candidates for that mask. The `doc` is used
         to provide sentence (context) for the mask


        Args:
            doc {`Spacy.Doc`}: Spacy Doc object, used to provide context to
                               the model misspellings
           {List(`Spacy.Token`)}: Contains List of `Token` object types from
                                  spacy to preserve meta information of the
                                  token

        Keyword Args:
            top_n {int}:  # suggestions to be considered (default: {10})

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…