Giter Site home page Giter Site logo

title-capitalization's Issues

Breaks with IndexError on "(m/w/d)" string

Amazing Project! However when using the text enhancer I'll have to do extensive text cleanup. When running

input_text = "aushilfe (m/w/d) als reinigungskraft"
output_text = apply_te(input_text, lan='de')

python errors with

IndexError                                Traceback (most recent call last)

[<ipython-input-9-11b317305bd2>](https://localhost:8080/#) in <module>()
      1 # input_text = model.examples[0]
      2 input_text = "aushilfe (m/w/d) als reinigungskraft"
----> 3 output_text = apply_te(input_text, lan='de')
      4 print(f"Input: \n{input_text}\nOutput:\n{output_text}")

[<ipython-input-2-196122d4e396>](https://localhost:8080/#) in apply_te(text, lan)
     15 
     16 def apply_te(text, lan='en'):
---> 17     return model.enhance_text(text, lan)

<torch_package_0>.release_module.py in enhance_text(self, text, lan, len_limit)
    118 
    119         if len(text.split()) < len_limit:
--> 120             enhanced = self.enhance_textblock(text, lan_id)
    121         else:
    122             enhanced = self.enhance_long_textblock(text, lan_id, len_limit)

<torch_package_0>.release_module.py in enhance_textblock(self, text, lan_id)
     73                                                                       punct[0][1:-1],
     74                                                                       capital[0][1:-1],
---> 75                                                                       self.index2punct))
     76 
     77     def count_occurrences(self, text, char):

<torch_package_0>.release_module.py in enhance_tokens(tokens, punct, capital, index2punct)
    163                 if len(token) < 2:
    164                     print(token)
--> 165                 token = '##' + token[2].upper() + token[3:]
    166         if c == 2:
    167             token = token.upper()

IndexError: string index out of range

The same text without the (m/w/d) works as expected

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.