Comments (2)
SoMaJo's sentence splitter operates on tokenized input. This means you cannot do sentence splitting without tokenization.
However, you could try to detokenize the output to some extent. This will not completely restore the original input (original whitespace will be normalized to a single space, things like control characters will be removed, etc.), but maybe it is close enough for your purposes:
#!/usr/bin/env python3
from somajo import SoMaJo
def detokenize(tokens):
out = []
for token in tokens:
if token.original_spelling is not None:
out.append(token.original_spelling)
else:
out.append(token.text)
if token.space_after:
out.append(" ")
return "".join(out)
tokenizer = SoMaJo("de_CMC")
paragraphs = ["der beste Betreuer?\n-- ProfSmith! : )",
"Was machst du morgen Abend?! Lust auf Film?;-)"]
sentences = tokenizer.tokenize_text(paragraphs)
for sentence in sentences:
print(detokenize(sentence))
This produces the following output where the individual sentences are restored to their original form:
der beste Betreuer?
-- ProfSmith! : )
Was machst du morgen Abend?!
Lust auf Film?;-)
from somajo.
Thanks. Closing this again.
from somajo.
Related Issues (20)
- Failing unit test in 2.0.2 HOT 4
- Quotation Marks HOT 1
- Phonenumber and sad emoje HOT 1
- Tokenizer outputs single characters per line HOT 4
- Thread safety HOT 6
- Segmentation of sentences in lowercase HOT 2
- Apostrophe die Vokale ersetzen HOT 5
- False Positives with URLS HOT 2
- tokenize with continue multiple punctions HOT 1
- Tokenizer text recovery problem HOT 1
- Domain adaptation to law texts HOT 4
- publish on conda-forge HOT 2
- Document all possible values for `token_class`. HOT 6
- Dates at the end of sentences HOT 1
- Markdown link splitting bug. HOT 6
- Issue with Markdown style links. HOT 3
- Other issue with Markdown style links. HOT 1
- Other MD issue. HOT 2
- German text to sentence segmentation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from somajo.