Editorial Workflows

Syntax Inspector

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Uses the new `linguistictagger` module to highlight lexical classes (nouns, verbs, adjectives...) in the current document — very similar to the syntax highlighting in Agile Tortoise's Phraseology app (but not editable).

Shared by: @olemoritz

Comments: Comment Feed (RSS)

@the_buch — 05 Sep 2014
Does anybody know a way to do this on the Mac? Either something that utilizes this linguistic tagging in Python, or an app -- other than Writer Pro (or the excellent Marked 2's somewhat relatively limited similar feature)? I'd really like some good looking way to inspect parts of speech in text/markdown writing along the lines of this, phraseology, or Writer Pro, but on the Mac and without spending all that money on Writer Pro just for a single feature. I don't even know if this could be ported to Mac or what. Anybody sees this and has some ideas please do enlighten me. Thanks.

+ Add Comment

Workflow Preview
Selected Text ?
Entire Line(s)
OFF
Empty Selection Output
  • No Output
  • All Text
  • Closest Word
Folded Text
  • Include
  • Replace with:
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import linguistictagger
from StringIO import StringIO

action_in = workflow.get_input()
# Noun, Verb, Adjective, Adverb, Pronoun, Determiner, Preposition, Conjunction, Number

out = StringIO()
tags = linguistictagger.tag_string(action_in, linguistictagger.SCHEME_LEXICAL_CLASS)
for tag in tags:
	lex = tag[0]
	word = tag[1]
	out.write('<span class="%s">%s</span>' % (lex, word))
html = out.getvalue().replace('\n', '<p/>')

workflow.set_output(html)
Show HTML ?
HTML
<!DOCTYPE html> <html> <head><meta charset="utf-8"/> <style> body { font-family: "Source Sans Pro"; font-size: 20px; color: #bbb; } .header-button { text-decoration: none; display: inline-block; background-color: white; border: 1px solid #ccc; padding: 2px 4px 2px 4px; margin: 2px 2px 4px 0; border-radius: 4px; color: black; -webkit-tap-highlight-color: rgba(0,0,0,0); } .selected { background-color: #eee; } #header { padding: 5px; } #container { margin: 10px; } </style> </head> <body> <div id="container"> <p id="header"> <span style="color:black; font-size: 16px;">Select the lexical class(es) to highlight:</span><br> <a href="#" class="header-button">Noun</a> <a href="#" class="header-button">Verb</a> <a href="#" class="header-button">Adjective</a> <a href="#" class="header-button">Adverb</a> <a href="#" class="header-button">Pronoun</a> <a href="#" class="header-button">Determiner</a> <a href="#" class="header-button">Preposition</a> <a href="#" class="header-button">Conjunction</a> </p> Input </div> <script type="text/javascript"> var colors = {"Noun": "#5083c6", "Verb": "#6050c6", "Adjective": "#9c50c6", "Adverb": "#cd529d", "Pronoun": "#e05a5c", "Determiner": "#e18e5a", "Preposition": "#e1c55a", "Conjunction": "#53c750", "Number": "#b6d555"}; var buttons = document.getElementsByClassName("header-button"); for (var i=0; i<buttons.length; i++) { var btn = buttons[i]; btn.ontouchstart = function() { var isSelected = this.classList.contains("selected"); var sel = this.innerText; var spans = document.getElementsByTagName("span"); for (var j=0; j<spans.length; j++) { var span = spans[j]; if (span.className == sel) { span.style.color = isSelected ? "" : colors[sel]; } } this.classList.toggle("selected"); this.style.color = isSelected ? "" : colors[sel] }; } </script> </body> </html>
Title
Syntax
Base URL
None