Difference between revisions of "Documentation:How to use the Parser"

Jump to navigation Jump to search
m
28 revisions imported
m (28 revisions imported)
 
(15 intermediate revisions by the same user not shown)
Line 15: Line 15:
Let’s use US presidents as an example. Suppose you want to create a layer of US presidents (even though such layer already exists).
Let’s use US presidents as an example. Suppose you want to create a layer of US presidents (even though such layer already exists).


First, you’d go to the corresponding Wikipedia page and open its source wiki text.  
First, you’d go to the corresponding [https://en.wikipedia.org/wiki/List_of_presidents_of_the_United_States Wikipedia page] and open its source wiki text.  


[[File:EditSource.png|300px]]
[[File:EditSource.png|300px]]
Line 49: Line 49:
Now you have to manually unhighlight the ones that are not needed, by selecting parts of text with a mouse and pressing ''Option/Alt'' button.  
Now you have to manually unhighlight the ones that are not needed, by selecting parts of text with a mouse and pressing ''Option/Alt'' button.  


Once you are done, you can click ‘Move selected’ and the data will be moved into the right field with almost correct syntax.  
Once you are done, you can click ''Move selected'' button and the data will be moved into the right field with almost correct syntax.  


[[File:Presidents_Almost_Done.png|800px]]
[[File:Presidents_Almost_Done.png|800px]]
Line 59: Line 59:




Now everything looks right. Copy the result and paste it into the Editor.  
Now everything looks right. Copy the result and paste it into the Editor.


==A harder task==
==A harder task==
Line 83: Line 83:
[[File:LinkolnExample.png|600px]]
[[File:LinkolnExample.png|600px]]


I placed an asterisk <code>*</code> between dates and texts and then used ''From prefix till line end'' button after specifying asterisk as a prefix.
I placed an asterisk <code>*</code> between dates and texts. Then I specified asterisk as a prefix:
 
[[File:AsteriskAsPrefix.png|300px]]
 
Then I clicked ''From prefix till line end'' button to select all the texts.
 
==The advanced technique==
Sometimes the way the source text is organised is so unfortunate that it would take a crazy amount of time to prepare it for the Parser manually. In such cases you have to use a thing called regular expressions. You know how in many text editors you can search and replace pieces of text? Regular expressions is just a more advanced way of doing search and replace.
 
Let me give you an example of the situation where regular expressions have helped me. Open the [https://en.wikipedia.org/wiki/List_of_Roman_consuls list of Roman consuls] on Wikipedia and examine that list. You see how most of the time there were 2 or more consuls in each year. In the wiki text it looks like this:
 
<blockquote><poem><nowiki>
| align=center | 503
| [[Agrippa Menenius Lanatus (consul 503 BC)|Agrippa Menenius Lanatus]]
| [[Publius Postumius Tubertus|P. Postumius Tubertus]] II
|-
| align=center | 502
| [[Opiter Verginius Tricostus (consul 502 BC)|Opet. Verginius Tricostus]]
| [[Spurius Cassius Viscellinus|Sp. Cassius Viscellinus]]
|-
| align=center | 501
| [[Postumus Cominius Auruncus|Post. Cominius Auruncus]]
| [[Titus Lartius|T. Lartius]] (Flavus ''or'' Rufus)
|}
</nowiki></poem></blockquote>
 
What I needed to do was to turn a block of text that looks like this:<blockquote><poem><nowiki>
| align=center | 502
| [[Opiter Verginius Tricostus (consul 502 BC)|Opet. Verginius Tricostus]]
| [[Spurius Cassius Viscellinus|Sp. Cassius Viscellinus]]
</nowiki></poem></blockquote>
 
into a block of text that looks like this:<blockquote><poem><nowiki>
[[Opiter Verginius Tricostus (consul 502 BC)|Opet. Verginius Tricostus]];;;;09.01.-502;;
[[Spurius Cassius Viscellinus|Sp. Cassius Viscellinus]] (post.);;;;09.01.-502;;
</nowiki></poem></blockquote>
 
I could have done it manually, but the problem is that there is almost 500 years worth of Roman consuls (I only did consuls of Roman Republic).
 
Regular expressions allowed me to find every such block of text and do the needed replacements automatically. In this particular case I created the final syntax right in the text editor without using Parser at all. But a lot of times I use the text editor to prepare the text for the Parser. It all depends on the situation.
 
I’m not going to give you a lesson on how to use regular expressions in this article. Maybe someday I will make a video on this topic. Here I’ll just tell you what you need to get to start using regular expressions and where you may find useful information about them.
 
To use regular expressions you need a special text editor that programmers use. The one I’m using is VSCode. You can download it [https://code.visualstudio.com/ here]. Don’t worry, you don’t need to be a programmer to use it. Treat it as just a text editor. Your workflow will be:
Create new file, paste the text into it, do replacements. Before doing searching and replacing don’t forget to press the button with a dot and an asterisk to activate regular expressions:
 
[[File:SearchWithRegExp.png]]
 
To learn about regular expressions read this [https://docs.microsoft.com/en-us/visualstudio/ide/using-regular-expressions-in-visual-studio article].
 
In the article they use a different text editor, which you may probably use as well (I just never used it, so I recommend the one I’m familiar with), but the syntax of regular expressions is the same no matter which text editor you use.
 
==Converting Julian dates to Gregorian dates==
Sometimes (very rarely though) the sources that you use may provide only old style dates. In this case you work with the data the same way, but in the end, after the dates are formatted, you just click the ''Julian to Gregorian'' button. All the dates after the calendar reform of 1582 will be converted. The dates before the reform will stay the same. Just make sure you don’t accidentally convert a date that was Gregorian to begin with.
 
When testing such layer on the Timeline turn on Julian dates in the Menu. This way you'll be able to compare the dates on the Timeline with the dates in the sources that you used, as they will all be Julian dates.

Navigation menu